LinkedBraidStructure.h

Go to the documentation of this file.
00001 
00002 #ifndef _LinkedBraidStructure_h_
00003 #define _LinkedBraidStructure_h_
00004 
00005 
00006 #include "set"
00007 #include "map"
00008 #include "list"
00009 #include "vector"
00010 using namespace std;
00011 
00012 #include "tuples.h"
00013 
00014 
00015 //---------------------------------------------------------------------------//
00016 //------------------------------ BraidNode ----------------------------------//
00017 //---------------------------------------------------------------------------//
00018 
00019 
00020 struct BraidNode
00021 {
00022 
00024   //                                                     //
00025   //  Constructors:                                      //
00026   //                                                     //
00028     
00029   public:
00030 
00031   BraidNode( int num=0, bool tp=true, BraidNode* l=NULL, BraidNode* a=NULL, BraidNode* r=NULL, BraidNode* bl=NULL, BraidNode* b=NULL, BraidNode* br=NULL) : 
00032     theNumber( num ), type( tp ) ,
00033     left( l ), ahead( a ), right( r ),
00034     back_left( bl ), back( b ), back_right( br ) ,
00035     link( NULL ) { }
00036 
00038   //                                                     //
00039   //  Data members:                                      //
00040   //                                                     //
00042   
00043   public:
00044   
00045   BraidNode* left;
00046   BraidNode* ahead;
00047   BraidNode* right;
00048 
00049   BraidNode* back_left;
00050   BraidNode* back;
00051   BraidNode* back_right;
00052   
00053   bool type;
00054   // shows whether a crossing positive or negative
00055   
00056   mutable BraidNode* link;
00057   // auxiliary member, used in LinkedBraidStructure copy constructor and in translateIntoWord
00058   
00059   mutable int weight;
00060   // auxiliary member, used in remove Handle functions
00061   
00062   int theNumber;
00063   // a unique number associated with the node in a LBS
00064 };
00065 
00066 ostream& operator << ( ostream& os , const BraidNode& bn );
00067 
00068 
00069 
00070 //---------------------------------------------------------------------------//
00071 //---------------------- LinkedBraidStructureTransform ----------------------//
00072 //---------------------------------------------------------------------------//
00073 
00074 
00075 struct LinkedBraidStructureTransform
00076 {
00077   enum TRANSFORM{ ERASED , ADDED , CHANGE_TYPE };
00078 
00079   LinkedBraidStructureTransform( int n , int p , TRANSFORM tr , bool t=false , int l=0 , int a=0 , int r=0 , int bl=0 , int b=0 , int br=0 ) :
00080     theNumber( n ), thePosition(p), theTransform(tr), type(t), left(l), ahead(a), right(r), back_left(bl), back(b), back_right(br)
00081   { }
00082 
00083   TRANSFORM theTransform;
00084 
00085   int left;
00086   int ahead;
00087   int right;
00088 
00089   int back_left;
00090   int back;
00091   int back_right;
00092   
00093   bool type;
00094   int theNumber;
00095   int thePosition;
00096 };
00097 
00098 
00099 //---------------------------------------------------------------------------//
00100 //------------------------- LinkedBraidStructure ----------------------------//
00101 //---------------------------------------------------------------------------//
00102 
00103 
00104 class LinkedBraidStructure
00105 {
00106 
00108   //                                                     //
00109   //  Constructors:                                      //
00110   //                                                     //
00112     
00113  public:
00114 
00115   LinkedBraidStructure( int N );
00116   LinkedBraidStructure( int N , const Word& w );
00117   LinkedBraidStructure( const LinkedBraidStructure& LBS );
00118 
00119   LinkedBraidStructure& operator= ( const LinkedBraidStructure& LBS );
00120 
00121   
00123   //                                                     //
00124   //  Accessors:                                         //
00125   //                                                     //
00127 
00128  public:
00129 
00130   bool operator < ( const LinkedBraidStructure& lbs ) const;
00131   // function check if the braid-word represented by *this is shortlex smaller than the one given by lbs
00132   // usually the computation of the words is not required, so the function is often fast
00133 
00134   int size( ) const { return theNodes.size( ); }
00135   void clear( );
00136 
00137   LinkedBraidStructureTransform push_back ( int g );
00138   LinkedBraidStructureTransform push_front( int g );
00139   
00140   void removeLeftHandles ( list< LinkedBraidStructureTransform >* result = NULL );
00141   void removeRightHandles( list< LinkedBraidStructureTransform >* result = NULL );
00142   
00143   Word translateIntoWord( ) const;
00144 
00145   void undo( const list< LinkedBraidStructureTransform >& lbst_seq );
00146   void undo( const LinkedBraidStructureTransform& lbst );
00147 
00149   //                                                     //
00150   //  Internal functions:                                //
00151   //                                                     //
00153 
00154  private:
00155 
00156   LinkedBraidStructureTransform make_EraseTransform( BraidNode* bn , int pos ) const;
00157   LinkedBraidStructureTransform make_AddTransform( BraidNode* bn , int pos ) const;
00158   LinkedBraidStructureTransform make_ChangeType( BraidNode* bn , int pos ) const;
00159 
00160   int checkIfStartsLeftHandle ( int pos , BraidNode* bn );
00161   int checkIfStartsRightHandle( int pos , BraidNode* bn );
00162   void removeLeftHandle( triple< int , int , BraidNode* > node , set< triple< int , int , BraidNode* > >& to_check , list< LinkedBraidStructureTransform >* lst );
00163   void removeRightHandle(triple< int , int , BraidNode* > node , set< triple< int , int , BraidNode* > >& to_check , list< LinkedBraidStructureTransform >* lst );
00164 
00165   LinkedBraidStructureTransform removeNode( BraidNode* bn , int pos );
00166   BraidNode* insertBackRight( BraidNode* bn , int pos , bool type );
00167   BraidNode* insertBackLeft( BraidNode* bn , int pos , bool type );
00168   BraidNode* insert( const LinkedBraidStructureTransform& lbst );
00169   
00170   void processTree( int al , BraidNode* node , Word& result ) const;
00171 
00172   void clearLinks( ) const;
00173 
00175   //                                                     //
00176   //  Data members:                                      //
00177   //                                                     //
00179 
00180  private:
00181   
00183   int theIndex;
00184   vector< BraidNode* > frontNodes;
00185   vector< BraidNode* >  backNodes;
00186   map< int , BraidNode > theNodes;
00187   
00188   int maxNodeNumber;
00189 };
00190 
00191 
00192 #endif
00193 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Mon Sep 26 18:43:45 2011 for CRyptography And Groups (CRAG) by  doxygen 1.6.1