DGtal
0.6.devel
|
#include <OrderedAlphabet.h>
Public Types | |
typedef int | Integer |
typedef unsigned int | index_t |
typedef unsigned int | size_t |
Public Member Functions | |
~OrderedAlphabet () | |
OrderedAlphabet (char first, unsigned int nb) | |
std::string | orderedAlphabet () const |
void | shiftLeft () |
void | shiftRight () |
void | reverse () |
void | reverseAround12 () |
unsigned int | order (char c) const |
char | letter (unsigned int i) const |
bool | less (char c1, char c2) const |
bool | lessOrEqual (char c1, char c2) const |
bool | equal (char c1, char c2) const |
void | firstLyndonFactor (size_t &len, size_t &nb, const std::string &w, index_t s, index_t e) const |
void | firstLyndonFactorMod (size_t &len, size_t &nb, const std::string &w, index_t s, index_t e) const |
bool | duvalPP (size_t &len, size_t &nb, const std::string &w, index_t s, index_t e) const |
bool | duvalPPMod (size_t &len, size_t &nb, const std::string &w, index_t s, index_t e) const |
bool | duvalPPtoDSS (size_t &len, size_t &nb, unsigned int &n1, unsigned int &n2, unsigned int &Lf1, unsigned int &Lf2, const std::string &w, index_t s, index_t e) const |
size_t | nextEdge (size_t &nb_a1, size_t &nb_a2, std::string &w, index_t &s, bool &cvx) |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Protected Member Functions | |
OrderedAlphabet () |
Private Member Functions | |
OrderedAlphabet (const OrderedAlphabet &other) | |
OrderedAlphabet & | operator= (const OrderedAlphabet &other) |
Private Attributes | |
char | myFirst |
unsigned int | myNb |
unsigned int * | myOrder |
Aim: Describes an alphabet over an interval of (ascii) letters, where the lexicographic order can be changed (shifted, reversed, ...). Useful for the arithmetic minimum length polygon (AMLP).
Description of class 'OrderedAlphabet'
Definition at line 64 of file OrderedAlphabet.h.
typedef unsigned int DGtal::OrderedAlphabet::index_t |
The index datatype.
Definition at line 77 of file OrderedAlphabet.h.
typedef int DGtal::OrderedAlphabet::Integer |
Internal integer type to consider in the OrderdAlphabet class.
Definition at line 72 of file OrderedAlphabet.h.
typedef unsigned int DGtal::OrderedAlphabet::size_t |
The size datatype.
Definition at line 82 of file OrderedAlphabet.h.
DGtal::OrderedAlphabet::~OrderedAlphabet | ( | ) |
Destructor.
Definition at line 48 of file OrderedAlphabet.cpp.
|
inline |
Constructor from letters
first | the first letter of the alphabet. |
nb | the number of letters of the alphabet. |
Exemple: OrderedAlphabet( '0', 4 ) defines the alphabet for 4-connected freeman chains.
Definition at line 54 of file OrderedAlphabet.ih.
|
protected |
Constructor. Forbidden by default (protected to avoid g++ warnings).
|
private |
Copy constructor.
other | the object to clone. Forbidden by default. |
bool DGtal::OrderedAlphabet::duvalPP | ( | size_t & | len, |
size_t & | nb, | ||
const std::string & | w, | ||
index_t | s, | ||
index_t | e | ||
) | const |
Adaptation of Duval's algorithm to extract the first Lyndon factor (FLF). Whilst scanning the Lyndon factor, it also checks whether it is a Christoffel word or not. It returns 'true' if the FLF is indeed a Christoffel word, otherwise returns false. It starts the extraction at position [s] in the word [w].
The alphabet takes the form a0 < a1 < a2 < ... < an-1. [w] starts with a1 or a2 at position s.
See [Provencal, Lachaud 2009].
len | (returns) the length of the primitive Lyndon factor (which starts at position s). |
nb | (returns) the number of times the Lyndon factor appears. |
w | a word which starts with a1 or a2 at position s. |
s | the starting index in [w]. |
e | the index after the end in [w] (s<e). |
len | (returns) the length of the primitive Lyndon factor (which starts at position s). |
nb | (returns) the number of times the Lyndon factor appears. |
w | a word which starts with a1 or a2 at position s. |
s | the starting index in [w]. |
e | the index after the end in [w] (s<e). |
Definition at line 218 of file OrderedAlphabet.cpp.
bool DGtal::OrderedAlphabet::duvalPPMod | ( | size_t & | len, |
size_t & | nb, | ||
const std::string & | w, | ||
index_t | s, | ||
index_t | e | ||
) | const |
Adaptation of Duval's algorithm to extract the first Lyndon factor (FLF). Whilst scanning the Lyndon factor, it also checks whether it is a Christoffel word or not. It returns 'true' if the FLF is indeed a Christoffel word, otherwise returns false. It starts the extraction at position [s] in the cyclic word [w].
The alphabet takes the form a0 < a1 < a2 < ... < an-1. [w] starts with a1 or a2 at position s.
See [Provencal, Lachaud 2009].
len | (returns) the length of the primitive Lyndon factor (which starts at position s). |
nb | (returns) the number of times the Lyndon factor appears. |
w | a (cyclic) word which starts with a1 or a2 at position s. |
s | the starting index in [w]. |
e | the index after the end in [w] (s and e arbitrary). |
Definition at line 378 of file OrderedAlphabet.cpp.
References DGtal::ModuloComputer< TInteger >::cast(), DGtal::ModuloComputer< TInteger >::increment(), and DGtal::ModuloComputer< TInteger >::next().
bool DGtal::OrderedAlphabet::duvalPPtoDSS | ( | size_t & | len, |
size_t & | nb, | ||
unsigned int & | n1, | ||
unsigned int & | n2, | ||
unsigned int & | lf1, | ||
unsigned int & | lf2, | ||
const std::string & | w, | ||
index_t | s, | ||
index_t | e | ||
) | const |
Second version of the algorithm Duval++ (see OrderedAlphabet::duvalPP), this one dynamically returns extra informations in order to compute leanning points.
len | (returns) the length of the primitive Lyndon factor (which starts at position s). |
nb | (returns) the number of times the Lyndon factor appears. |
n1 | (returns) the number of occurrences of the letter a1 in the Lyndon factor |
n2 | (returns) the number of occurrences of the letter a2 in the Lyndon factor |
Lf1 | (returns) the number of occurrences of the letter a1 from 's' to the first lower leaning point. |
Lf2 | (returns) the number of occurrences of the letter a2 from 's' to the first lower leaning point. |
w | a word which starts with a1 or a2 at position s. |
s | the starting index in [w]. |
e | the index after the end in [w] (s<e). |
len | (returns) the length of the primitive Lyndon factor (which starts at position s). |
nb | (returns) the number of times the Lyndon factor appears. |
n1 | (returns) the number of occurrences of the letter a1 in the Lyndon factor |
n2 | (returns) the number of occurrences of the letter a2 in the Lyndon factor |
Lf1 | (returns) the number of occurrences of the letter a1 from 's' to the first lower leaning point. |
Lf2 | (returns) the number of occurrences of the letter a2 from 's' to the first lower leaning point. |
w | a word which starts with a1 or a2 at position s. |
s | the starting index in [w]. |
e | the index after the end in [w] (s<e). |
bool convex;
Definition at line 277 of file OrderedAlphabet.cpp.
|
inline |
c1 | a letter in the alphabet |
c2 | another letter in the same alphabet. |
Definition at line 131 of file OrderedAlphabet.ih.
void DGtal::OrderedAlphabet::firstLyndonFactor | ( | size_t & | len, |
size_t & | nb, | ||
const std::string & | w, | ||
index_t | s, | ||
index_t | e | ||
) | const |
Gives the first lyndon factor of the word [w] starting at position [s] in this alphabet.
len | (returns) the length of the primitive Lyndon factor (which starts at position s). |
nb | (returns) the number of times the Lyndon factor appears. |
w | a word |
s | the starting index in [w]. |
e | the index after the end in [w] (s<e). |
Definition at line 152 of file OrderedAlphabet.cpp.
void DGtal::OrderedAlphabet::firstLyndonFactorMod | ( | size_t & | len, |
size_t & | nb, | ||
const std::string & | w, | ||
index_t | s, | ||
index_t | e | ||
) | const |
Gives the first lyndon factor of the cyclic word [w] starting at position [s] in this alphabet.
len | (returns) the length of the primitive Lyndon factor (which starts at position s). |
nb | (returns) the number of times the Lyndon factor appears. |
w | a word |
s | the starting index in [w]. |
e | the index after the end in [w] (s and e arbitrary). |
Definition at line 186 of file OrderedAlphabet.cpp.
References DGtal::ModuloComputer< TInteger >::increment(), and DGtal::ModuloComputer< TInteger >::next().
bool DGtal::OrderedAlphabet::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Definition at line 439 of file OrderedAlphabet.cpp.
|
inline |
|
inline |
|
inline |
i | the index of some letter in the order relation, between 0 and myNb-1. |
NB: O(nb of letters in the alphabet).
Definition at line 90 of file OrderedAlphabet.ih.
DGtal::OrderedAlphabet::size_t DGtal::OrderedAlphabet::nextEdge | ( | size_t & | nb_a1, |
size_t & | nb_a2, | ||
std::string & | w, | ||
index_t & | s, | ||
bool & | cvx | ||
) |
Extracts the next edge of the minimum length polygon starting from position [s] on the word [w]. The alphabet may be modified (reversed or shifted). The output alphabet is some a0 < a1 < a2 < ...
(returns) | the number of letters a1 in the extracted edge (a1 in the output alphabet) |
(returns) | the number of letters a2 in the extracted edge (a2 in the output alphabet) |
w | the input (cyclic) word (may be modified in the process). |
s | the starting point in the word (updated). |
cvx | (updates) this boolean is flipped only if a change of convexity is detected. |
Definition at line 470 of file OrderedAlphabet.cpp.
|
private |
Assignment.
other | the object to copy. |
|
inline |
c | any valid letter in this alphabet. |
Definition at line 73 of file OrderedAlphabet.ih.
Referenced by DGtal::FreemanChain< TInteger >::findQuadrantChange(), and DGtal::FreemanChain< TInteger >::findQuadrantChange4().
string DGtal::OrderedAlphabet::orderedAlphabet | ( | ) | const |
void DGtal::OrderedAlphabet::reverse | ( | ) |
Reverse the order a0 < a1 < ... < an to an < ... < a1 < a0
Definition at line 108 of file OrderedAlphabet.cpp.
Referenced by DGtal::FreemanChain< TInteger >::findQuadrantChange(), and DGtal::FreemanChain< TInteger >::findQuadrantChange4().
void DGtal::OrderedAlphabet::reverseAround12 | ( | ) |
Reverse the order a0 < a1 < ... < an to a3 < a2 < a1 < a0 < an < ...
Definition at line 123 of file OrderedAlphabet.cpp.
void DGtal::OrderedAlphabet::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 428 of file OrderedAlphabet.cpp.
void DGtal::OrderedAlphabet::shiftLeft | ( | ) |
Shift a0 < a1 < ... < an to a1 < ... < an < a0
Definition at line 76 of file OrderedAlphabet.cpp.
Referenced by DGtal::FreemanChain< TInteger >::findQuadrantChange(), and DGtal::FreemanChain< TInteger >::findQuadrantChange4().
void DGtal::OrderedAlphabet::shiftRight | ( | ) |
|
private |
the first character.
Definition at line 340 of file OrderedAlphabet.h.
|
private |
the number of letters.
Definition at line 345 of file OrderedAlphabet.h.
Referenced by OrderedAlphabet().
|
private |
the order relation, given by the isomorphism with 0..myNb-1.
Definition at line 350 of file OrderedAlphabet.h.
Referenced by OrderedAlphabet().