libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
WordRange

Defined in word-range.hpp.

This class implements a range object for the lower level functions cbegin_wislo and cbegin_wilo. The purpose of this class is to provide a more user-friendly interface with cbegin_wislo and cbegin_wilo.

Note
There is a small overhead to using a WordRange object rather than using cbegin_wislo or cbegin_wilo directly.

The order and range of the words in a WordRange instance can be set using the member functions:

Example
words.order(Order::shortlex) // words in shortlex order
.alphabet_size(2) // on 2 letters
.min(1) // of length in the range from 1
.max(5); // to 5
WordRange()
Default constructor.
Definition word-range.hpp:438
@ shortlex
Definition order.hpp:54
Namespace containing some operators for creating words.
Definition word-range.hpp:2072

Public Types

using output_type = word_type const&
 The type of the output of a WordRange object.
 
using size_type = typename std::vector<word_type>::size_type
 Alias for the size type.
 

Public Member Functions

 WordRange ()
 Default constructor.
 
 WordRange (WordRange &&)
 Default move constructor.
 
 WordRange (WordRange const &)
 Default copy constructor.
 
size_type alphabet_size () const noexcept
 The current number of letters in the alphabet.
 
WordRangealphabet_size (size_type n) noexcept
 Set the number of letters in the alphabet.
 
bool at_end () const noexcept
 Check if the range object is exhausted.
 
auto begin () const noexcept
 Returns an input iterator pointing to the first word in the range.
 
size_t count () const noexcept
 The actual size of the range.
 
auto end () const noexcept
 Returns an input iterator pointing one beyond the last word in the range.
 
word_type const & first () const noexcept
 The current first word in the range.
 
WordRangefirst (word_type const &frst)
 Set the first word in the range.
 
output_type get () const noexcept
 Get the current value.
 
WordRangeinit ()
 Initialize an existing WordRange object.
 
word_type const & last () const noexcept
 The current one past the last word in the range.
 
WordRangelast (word_type const &lst)
 Set one past the last word in the range.
 
WordRangemax (size_type val)
 Set one past the last word in the range by length.
 
WordRangemin (size_type val)
 Set the first word in the range by length.
 
void next () noexcept
 Advance to the next value.
 
WordRangeoperator= (WordRange &&)
 Default move assignment operator.
 
WordRangeoperator= (WordRange const &)
 Default copy assignment operator.
 
Order order () const noexcept
 The current order of the words in the range.
 
WordRangeorder (Order val)
 Set the order of the words in the range.
 
size_t size_hint () const noexcept
 The possible size of the range.
 
size_type upper_bound () const noexcept
 The current upper bound on the length of a word in the range.
 
WordRangeupper_bound (size_type n)
 Set an upper bound for the length of a word in the range.
 
bool valid () const noexcept
 Returns whether or not the settings have been changed since the last time either next or get has been called.
 

Constructor & Destructor Documentation

◆ WordRange() [1/3]

WordRange ( )
inline

Constructs an empty range with:

◆ WordRange() [2/3]

WordRange ( WordRange const & )

Default copy constructor.

◆ WordRange() [3/3]

Default move constructor.

Member Function Documentation

◆ alphabet_size() [1/2]

size_type alphabet_size ( ) const
inlinenodiscardnoexcept

Returns the current number of letters in a WordRange object.

Returns
A value of type size_type.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ alphabet_size() [2/2]

WordRange & alphabet_size ( size_type n)
inlinenoexcept

Sets the number of letters in a WordRange object to n.

Parameters
nthe number of letters.
Returns
A reference to *this.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ at_end()

bool at_end ( ) const
inlinenodiscardnoexcept

Returns true if a WordRange object is exhausted, and false if not.

Returns
A value of type bool.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ begin()

auto begin ( ) const
inlinenoexcept

This function returns an input iterator pointing to the first word in a WordRange object.

Returns
An input iterator.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
The return type of end might be different from the return type of begin.
See also
end.

◆ count()

size_t count ( ) const
nodiscardnoexcept

Returns the number of words in a WordRange object. If order() is Order::shortlex, then size_hint() is used. If order() is not Order::shortlex, then a copy of the range may have to be looped over in order to find the return value of this function.

Returns
A value of type size_t.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ end()

auto end ( ) const
inlinenoexcept

This function returns an input iterator pointing one beyond the last word in a WordRange object.

Returns
An input iterator.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
The return type of end might be different from the return type of begin.
See also
begin.

◆ first() [1/2]

word_type const & first ( ) const
inlinenodiscardnoexcept

Returns the first word in a WordRange object.

Returns
A const reference to a word_type.
Exceptions
This function is noexcept and is guaranteed never to throw.
See also
min

◆ first() [2/2]

WordRange & first ( word_type const & frst)
inline

Sets the first word in a WordRange object to be frst. This function performs no checks on its arguments. If frst contains letters greater than alphabet_size(), then the WordRange object will be empty. Similarly, if first() is greater than last() with respect to order(), then the object will be empty.

Parameters
frstthe first word.
Returns
A reference to *this.
See also
min

◆ get()

output_type get ( ) const
inlinenodiscardnoexcept

Returns the current word in a WordRange object.

Returns
A value of type output_type.
Exceptions
This function is noexcept and is guaranteed never to throw.
Warning
If at_end() returns true, then the return value of this function could be anything.

◆ init()

WordRange & init ( )

This function puts a WordRange object back into the same state as if it had been newly default constructed.

Returns
A reference to *this.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ last() [1/2]

word_type const & last ( ) const
inlinenodiscardnoexcept

Returns one past the last word in a WordRange object.

Returns
A const reference to a word_type.
Exceptions
This function is noexcept and is guaranteed never to throw.
See also
max

◆ last() [2/2]

WordRange & last ( word_type const & lst)
inline

Sets one past the last word in a WordRange object to be lst. This function performs no checks on its arguments. If lst contains letters greater than alphabet_size(), then the WordRange object will be empty.

Parameters
lstone past the last word.
Returns
A reference to *this.
See also
max

◆ max()

WordRange & max ( size_type val)
inline

Sets one past the last word in a WordRange object to be pow(0_w, val) (the word consisting of val letters equal to 0).

Parameters
valthe exponent.
Returns
A reference to *this.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ min()

WordRange & min ( size_type val)
inline

Sets the first word in a WordRange object to be pow(0_w, val) (the word consisting of val letters equal to 0).

Parameters
valthe exponent.
Returns
A reference to *this.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ next()

void next ( )
inlinenoexcept

Advances a WordRange object to the next value (if any).

Exceptions
This function is noexcept and is guaranteed never to throw.
See also
at_end

◆ operator=() [1/2]

WordRange & operator= ( WordRange && )

Default move assignment operator.

◆ operator=() [2/2]

WordRange & operator= ( WordRange const & )

Default copy assignment operator.

◆ order() [1/2]

Order order ( ) const
inlinenodiscardnoexcept

Returns the current order of the words in a WordRange object.

Returns
A value of type Order.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ order() [2/2]

WordRange & order ( Order val)

Sets the order of the words in a WordRange object to val.

Parameters
valthe order.
Returns
A reference to *this.
Exceptions
LibsemigroupsExceptionif val is not Order::shortlex or Order::lex.

◆ size_hint()

size_t size_hint ( ) const
inlinenodiscardnoexcept

Returns the number of words in a WordRange object if order() is Order::shortlex. If order() is not Order::shortlex, then the return value of this function is meaningless.

Returns
A value of type size_t.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ upper_bound() [1/2]

size_type upper_bound ( ) const
inlinenodiscardnoexcept

Returns the current upper bound on the length of a word in a WordRange object. This setting is only used if order() is Order::lex.

Returns
A value of type size_type.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ upper_bound() [2/2]

WordRange & upper_bound ( size_type n)
inline

Sets an upper bound for the length of a word in a WordRange object. This setting is only used if order() is Order::lex.

Parameters
nthe upper bound.
Returns
A reference to *this.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ valid()

bool valid ( ) const
inlinenoexcept

Other than by calling next, the value returned by get may be altered by a call to one of the following:

This function returns true if none of the above settings have been changed since the last time next or get is called, and false otherwise.

Returns
A value of type bool.

Member Data Documentation

◆ is_finite

bool is_finite = true
staticconstexpr

Value indicating that the range is finite.

◆ is_idempotent

bool is_idempotent = true
staticconstexpr

Value indicating that if get() is called twice on a WordRange object that is not changed between the two calls, then the return value of get() is the same both times.


The documentation for this class was generated from the following file: