Strings in short-lex order (sislo)

The functions libsemigroups::cbegin_sislo() and libsemigroups::cend_sislo() can be used to iterate through strings in short-lex order in some range.

const_sislo_iterator libsemigroups::cbegin_sislo(std::string const &alphabet, std::string const &first, std::string const &last)

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

If incremented, the iterator will point to the next least short-lex string after w over 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_sislo by the same amount, or they are both obtained by any call to cend_sislo.

See also

cend_sislo

Example

std::vector<std::string>(cbegin_sislo("ba", "b", "bbb"),
                         cend_sislo("ba", "b", "bbb"));
// {"b", "b", "bb", "ba","ab", "aa"};

Warning

Copying iterators of this type is expensive. As a consequence, prefix incrementing ++it the iterator it returned by cbegin_sislo 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
  • alphabet – 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_sislo_iterator.

const_sislo_iterator libsemigroups::cend_sislo(std::string const &alphabet, std::string const &first, std::string 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 string in the correct range.

See also

cbegin_sislo