Class
Lexical
Comparator for lexical comparison.
Lexical<TSpec>
Include Headers
seqan/sequence.h
Parameters
TSpec
The specializing type.
This type can be used for specializations of Lexical.
Metafunctions: Spec
Default: size_t
Remarks: TSpec is by default interpreted as size-type.
Remarks
This class implement comparator objects that perform (lexical) comparisons between two sequences. The result of the comparison is stored in the data members of the instance and can be accessed by some functions, for example isLess or isEqual.
In most cases, there is no need for an explicite use of comparators, but sometimes this concept provide the opportunity to speed up the code.
Functions
compareCompares two objects.
hasPrefixTest whether a sequence is prefix of another sequence.
isEqualOperator "==".
isGreaterOperator ">".
isGreaterOrEqualOperator ">=".
isLessOperator "<".
isLessOrEqualOperator "<=".
isNotEqualOperator "!=".
isPrefixTest whether a sequence is prefix of another sequence.
lcpLengthLength of longest common prefix.
Examples
This program compares the strings str1 and str2:
if (isLess(str1, str2)) //first comparison
{
    //str1 < str2
}
else if (isGreater(str1, str2)) //second comparison
{
    //str1 > str2
}
else
{
    //str == str2
}
Using a comparator, the same program only needs one comparison instead of two:
Lexical <> comparator(str1, str2); //comparison is executed here
if (isLess(comparator))
{
    //str1 < str2
}
else if (lexGreater(comparator))
{
    //str1 > str2
}
else
{
    //str == str2
}
The state of a default constructed Lexical instance is undefined until it is set by a call of compare.
See Also
SeqAn - Sequence Analysis Library - www.seqan.de
 

Page built @2013/07/11 09:12:16