Words in short-lex order (wislo)

The functions libsemigroups::cbegin_wislo() and libsemigroups::cend_wislo() can be used to iterate through words in short-lex order in some range.

const_wislo_iterator libsemigroups::cbegin_wislo(size_t n, word_type &&first, word_type &&last)

Returns a forward iterator pointing to the 2nd parameter first.

If incremented, the iterator will point to the next least short-lex word after w over an n letter alphabet. Iterators of the type returned by this function are equal whenever they are obtained by advancing the return value of any call to cbegin_wislo by the same amount, or they are both obtained by any call to cend_wislo.

See also

cend_wislo

Example

std::vector<word_type>(cbegin_wislo(2, {0}, {0, 0, 0}),
                       cend_wislo(2,  {0}, {0, 0, 0}));
// {{0}, {1}, {0, 0}, {0, 1}, {1, 0}, {1, 1}};

Warning

Copying iterators of this type is expensive. As a consequence, prefix incrementing ++it the iterator it returned by cbegin_wislo is significantly cheaper than postfix incrementing it++.

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;

  • first – the starting point for the iteration;

  • last – the ending point for the iteration.

Throws

(None) – This function guarantees not to throw a LibsemigroupsException.

Returns

An iterator of type const_wislo_iterator.

const_wislo_iterator libsemigroups::cend_wislo(size_t n, word_type &&first, word_type &&last)

Returns a forward iterator pointing to one after the end of the range from first to last.

The iterator returned by this is still dereferenceable and incrementable, but does not point to a word in the correct range.

See also

cbegin_wislo

const_wislo_iterator libsemigroups::cbegin_wislo(size_t n, word_type const &first, word_type const &last)

Returns a forward iterator pointing to the 2nd parameter first.

If incremented, the iterator will point to the next least short-lex word after w over an n letter alphabet. Iterators of the type returned by this function are equal whenever they are obtained by advancing the return value of any call to cbegin_wislo by the same amount, or they are both obtained by any call to cend_wislo.

See also

cend_wislo

Example

std::vector<word_type>(cbegin_wislo(2, {0}, {0, 0, 0}),
                       cend_wislo(2,  {0}, {0, 0, 0}));
// {{0}, {1}, {0, 0}, {0, 1}, {1, 0}, {1, 1}};

Warning

Copying iterators of this type is expensive. As a consequence, prefix incrementing ++it the iterator it returned by cbegin_wislo is significantly cheaper than postfix incrementing it++.

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;

  • first – the starting point for the iteration;

  • last – the ending point for the iteration.

Throws

(None) – This function guarantees not to throw a LibsemigroupsException.

Returns

An iterator of type const_wislo_iterator.

const_wislo_iterator libsemigroups::cend_wislo(size_t n, word_type const &first, word_type const &last)

Returns a forward iterator pointing to one after the end of the range from first to last.

The iterator returned by this is still dereferenceable and incrementable, but does not point to a word in the correct range.

See also

cbegin_wislo