Words in lexicographic order (wilo)¶
The functions libsemigroups::cbegin_wilo() and
libsemigroups::cend_wilo() can be used to iterate through words in
lexicographic order in some range.
-
const_wilo_iterator libsemigroups::cbegin_wilo(size_t n, size_t upper_bound, word_type &&first, word_type &&last)¶
Returns a forward iterator pointing to the 3rd parameter
first.If incremented, the iterator will point to the next least lexicographic word after
wover annletter alphabet with length less thanupper_bound. Iterators of the type returned by this function are equal whenever they are obtained by advancing the return value of any call tocbegin_wiloby the same amount, or they are both obtained by any call tocend_wilo.See also
- Example
std::vector<word_type>(cbegin_wilo(2, 3, {0}, {1, 1, 1}), cend_wilo(2, 3, {0}, {1, 1, 1})); // {{0}, {0, 0}, {0, 1}, {1}, {1, 0}, {1, 1}};
Note
The parameter
upper_boundis required because lexicographical ordering is not a well-ordering, and there might be infinitely many words between a given pair of words.Warning
Copying iterators of this type is expensive. As a consequence, prefix incrementing
++itthe iteratoritreturned bycbegin_wilois significantly cheaper than postfix incrementingit++.Warning
Iterators constructed using different parameters may not be equal, so best not to loop over them.
- Parameters:
n – the number of letters in the alphabet;
upper_bound – only words of length less than this value are considered;
first – the starting point for the iteration;
last – the value one past the end of the last value in the iteration.
- Throws:
(None) – This function guarantees not to throw a
LibsemigroupsException.- Returns:
An iterator of type
const_wilo_iterator.
-
const_wilo_iterator libsemigroups::cend_wilo(size_t n, size_t upper_bound, word_type &&first, word_type &&last)¶
Returns a forward iterator pointing to one after the end of the range from
firsttolast.The iterator returned by this function is still dereferenceable and incrementable, but does not point to a word in the correct range.
See also
-
const_wilo_iterator libsemigroups::cbegin_wilo(size_t n, size_t upper_bound, word_type const &first, word_type const &last)¶
Returns a forward iterator pointing to the 3rd parameter
first.If incremented, the iterator will point to the next least lexicographic word after
wover annletter alphabet with length less thanupper_bound. Iterators of the type returned by this function are equal whenever they are obtained by advancing the return value of any call tocbegin_wiloby the same amount, or they are both obtained by any call tocend_wilo.See also
- Example
std::vector<word_type>(cbegin_wilo(2, 3, {0}, {1, 1, 1}), cend_wilo(2, 3, {0}, {1, 1, 1})); // {{0}, {0, 0}, {0, 1}, {1}, {1, 0}, {1, 1}};
Note
The parameter
upper_boundis required because lexicographical ordering is not a well-ordering, and there might be infinitely many words between a given pair of words.Warning
Copying iterators of this type is expensive. As a consequence, prefix incrementing
++itthe iteratoritreturned bycbegin_wilois significantly cheaper than postfix incrementingit++.Warning
Iterators constructed using different parameters may not be equal, so best not to loop over them.
- Parameters:
n – the number of letters in the alphabet;
upper_bound – only words of length less than this value are considered;
first – the starting point for the iteration;
last – the value one past the end of the last value in the iteration.
- Throws:
(None) – This function guarantees not to throw a
LibsemigroupsException.- Returns:
An iterator of type
const_wilo_iterator.
-
const_wilo_iterator libsemigroups::cend_wilo(size_t n, size_t upper_bound, word_type const &first, word_type const &last)¶
Returns a forward iterator pointing to one after the end of the range from
firsttolast.The iterator returned by this function is still dereferenceable and incrementable, but does not point to a word in the correct range.
See also