DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
OrderedAlphabet.h
1 
17 #pragma once
18 
35 #if defined(OrderedAlphabet_RECURSES)
36 #error Recursive header files inclusion detected in OrderedAlphabet.h
37 #else // defined(OrderedAlphabet_RECURSES)
38 
39 #define OrderedAlphabet_RECURSES
40 
41 #if !defined OrderedAlphabet_h
42 
43 #define OrderedAlphabet_h
44 
46 // Inclusions
47 #include <iostream>
48 #include <string>
49 #include "DGtal/base/Common.h"
50 #include "DGtal/kernel/NumberTraits.h"
52 
53 namespace DGtal
54 {
55 
57  // class OrderedAlphabet
65  {
66  // ----------------------- Standard types ------------------------------
67  public:
68 
72  typedef int Integer;
73 
77  typedef unsigned int index_t;
78 
82  typedef unsigned int size_t;
83 
84  // ----------------------- Standard services ------------------------------
85  public:
86 
91 
101  OrderedAlphabet( char first, unsigned int nb );
102 
106  std::string orderedAlphabet() const;
107 
111  void shiftLeft();
112 
116  void shiftRight();
117 
121  void reverse();
122 
126  void reverseAround12();
127 
134  unsigned int order( char c ) const;
135 
144  char letter( unsigned int i ) const;
145 
151  bool less( char c1, char c2 ) const;
152 
158  bool lessOrEqual( char c1, char c2 ) const;
159 
165  bool equal( char c1, char c2 ) const;
166 
167  // ----------------------- word services ------------------------------
168  public:
169 
183  void firstLyndonFactor( size_t & len, size_t & nb,
184  const std::string & w,
185  index_t s, index_t e ) const;
186 
187 
201  void firstLyndonFactorMod( size_t & len, size_t & nb,
202  const std::string & w,
203  index_t s, index_t e ) const;
204 
205 
227  bool duvalPP( size_t & len, size_t & nb,
228  const std::string & w,
229  index_t s, index_t e
230  ) const;
231 
253  bool duvalPPMod( size_t & len, size_t & nb,
254  const std::string & w,
255  index_t s, index_t e ) const;
282  bool duvalPPtoDSS( size_t & len, size_t & nb,
283  unsigned int & n1, unsigned int & n2,
284  unsigned int & Lf1, unsigned int & Lf2,
285  const std::string & w,
286  index_t s, index_t e
287  ) const;
288 
289 
290 
291  // ----------------------- MLP services -----------------------------------
292  public:
293 
314  size_t nextEdge( size_t & nb_a1, size_t & nb_a2,
315  std::string & w, index_t & s, bool & cvx );
316 
317 
318  // ----------------------- Interface --------------------------------------
319  public:
320 
325  void selfDisplay ( std::ostream & out ) const;
326 
331  bool isValid() const;
332 
333  // ------------------------- Protected Datas ------------------------------
334  private:
335  // ------------------------- Private Datas --------------------------------
336  private:
340  char myFirst;
341 
345  unsigned int myNb;
346 
350  unsigned int* myOrder;
351 
352  // ------------------------- Hidden services ------------------------------
353  protected:
354 
359  OrderedAlphabet();
360 
361  private:
362 
368  OrderedAlphabet ( const OrderedAlphabet & other );
369 
376  OrderedAlphabet & operator= ( const OrderedAlphabet & other );
377 
378  // ------------------------- Internals ------------------------------------
379  private:
380 
381  }; // end of class OrderedAlphabet
382 
383 
390  std::ostream&
391  operator<< ( std::ostream & out, const OrderedAlphabet & object );
392 
393 
394 } // namespace DGtal
395 
396 
398 // Includes inline functions/methods if necessary.
399 #include "DGtal/base/OrderedAlphabet.ih"
400 
401 // //
403 
404 #endif // !defined OrderedAlphabet_h
405 
406 #undef OrderedAlphabet_RECURSES
407 #endif // else defined(OrderedAlphabet_RECURSES)