libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
PTransfBase< Scalar, Container >
template<typename Scalar, typename Container>
class libsemigroups::PTransfBase< Scalar, Container >

This is a class template for partial transformations that collects all the common aspects of the subclasses StaticPTransf and DynamicPTransf. It is not intended that instance of this class are actually constructed, only its derived classes.

Template Parameters
Scalarthe type of image values (must be an unsigned integer type).
Containerthe type of the container holding the image values.
Inheritance diagram for PTransfBase< Scalar, Container >:
[legend]

Public Types

using const_iterator = typename Container::const_iterator
 Type of const iterators point to image values.
 
using container_type = Container
 Type of the underlying container.
 
using iterator = typename Container::iterator
 Type of iterators point to image values.
 
using point_type = Scalar
 Type of the image values.
 

Public Member Functions

 PTransfBase ()=default
 Default constructor.
 
 PTransfBase (Container &&cont)
 Construct from a container of images.
 
 PTransfBase (Container const &cont)
 Construct from a container of images.
 
template<typename Iterator>
 PTransfBase (Iterator first, Iterator last)
 Construct from a range of images.
 
 PTransfBase (PTransfBase &&)=default
 Default move constructor.
 
 PTransfBase (PTransfBase const &)=default
 Default copy constructor.
 
 PTransfBase (std::initializer_list< Scalar > cont)
 Construct from a container of images.
 
point_typeat (size_t i)
 Get a reference to the image of a point.
 
point_type const & at (size_t i) const
 Get a const reference to the image of a point.
 
const_iterator begin () const noexcept
 Returns a const_iterator (random access iterator) pointing at the first image value.
 
iterator begin () noexcept
 Returns an iterator (random access iterator) pointing at the first image value.
 
const_iterator cbegin () const noexcept
 Returns a const_iterator (random access iterator) pointing at the first image value.
 
const_iterator cend () const noexcept
 Returns a const_iterator (random access iterator) pointing one past the last image value.
 
size_t degree () const noexcept
 Returns the degree of a partial transformation.
 
const_iterator end () const noexcept
 Returns a const_iterator (random access iterator) pointing one past the last image value.
 
iterator end () noexcept
 Returns an iterator (random access iterator) pointing one past the last image value.
 
size_t hash_value () const
 Returns a hash value.
 
bool operator!= (PTransfBase const &that) const
 Compare for inequality.
 
template<typename Subclass>
Subclass operator* (Subclass const &that) const
 Multiply by another partial transformation.
 
bool operator< (PTransfBase const &that) const
 Compare for less.
 
bool operator<= (PTransfBase const &that) const
 Compare for less than or equal.
 
PTransfBaseoperator= (PTransfBase &&)=default
 Default move assignment operator.
 
PTransfBaseoperator= (PTransfBase const &)=default
 Default copy assignment operator.
 
bool operator== (PTransfBase const &that) const
 Compare for equality.
 
bool operator> (PTransfBase const &that) const
 Compare for greater.
 
bool operator>= (PTransfBase const &that) const
 Compare for greater than or equal.
 
point_typeoperator[] (size_t i)
 Get a reference to the image of a point.
 
point_type const & operator[] (size_t i) const
 Get a const reference to the image of a point.
 
size_t rank () const
 Returns the number of distinct image values.
 
void swap (PTransfBase &that) noexcept
 Swap with another partial transformation.
 

Static Public Member Functions

template<typename Subclass, typename OtherContainer = Container>
static Subclass make (OtherContainer &&cont)
 Construct from universal reference container and check.
 
template<typename Subclass, typename OtherScalar>
static Subclass make (std::initializer_list< OtherScalar > cont)
 Construct from std::initializer_list and check.
 
template<typename Subclass>
static Subclass one (size_t N)
 Returns the identity transformation on the given number of points.
 
static point_type undef () noexcept
 Returns the value used to represent "undefined".
 

Member Typedef Documentation

◆ const_iterator

template<typename Scalar, typename Container>
using const_iterator = typename Container::const_iterator

Type of const iterators point to image values.

◆ container_type

template<typename Scalar, typename Container>
using container_type = Container

Type of the underlying container.

◆ iterator

template<typename Scalar, typename Container>
using iterator = typename Container::iterator

Type of iterators point to image values.

◆ point_type

template<typename Scalar, typename Container>
using point_type = Scalar

Also the template parameter Scalar.

Constructor & Destructor Documentation

◆ PTransfBase() [1/7]

template<typename Scalar, typename Container>
PTransfBase ( )
default

Constructs an uninitialized partial transformation of degree 0.

Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant.

◆ PTransfBase() [2/7]

template<typename Scalar, typename Container>
PTransfBase ( Container const & cont)
inlineexplicit

Constructs a partial transformation initialized using the container cont as follows: the image of the point i under the partial transformation is the value in position i of the container cont.

Parameters
contthe container.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in the size of the container cont.
Warning
No checks on the validity of cont are performed.
See also
make

◆ PTransfBase() [3/7]

template<typename Scalar, typename Container>
PTransfBase ( Container && cont)
inlineexplicit

Constructs a partial transformation initialized using the container cont as follows: the image of the point i under the partial transformation is the value in position i of the container cont.

Parameters
contthe container.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in the size of the container cont.
Warning
No checks on the validity of cont are performed.
See also
make

◆ PTransfBase() [4/7]

template<typename Scalar, typename Container>
template<typename Iterator>
PTransfBase ( Iterator first,
Iterator last )
inlineexplicit

Constructs a partial transformation initialized using the iterators first and last as follows: the image of the point i under the partial transformation at first + i.

The values pointed at by iterators of type Iterator must be convertible to point_type or equal to UNDEFINED.

Parameters
firstiterator pointing at the first image point.
lastiterator pointing one beyond the last image point.
Complexity
Linear in the size of the container cont.
Warning
No checks on the validity of cont are performed.
See also
make

◆ PTransfBase() [5/7]

template<typename Scalar, typename Container>
PTransfBase ( std::initializer_list< Scalar > cont)
inline

Constructs a partial transformation initialized using the container cont as follows: the image of the point i under the partial transformation is the value in position i of the container cont.

Parameters
contthe container.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in the size of the container cont.
Warning
No checks on the validity of cont are performed.
See also
make

◆ PTransfBase() [6/7]

template<typename Scalar, typename Container>
PTransfBase ( PTransfBase< Scalar, Container > const & )
default

Default copy constructor

◆ PTransfBase() [7/7]

template<typename Scalar, typename Container>
PTransfBase ( PTransfBase< Scalar, Container > && )
default

Default move constructor

Member Function Documentation

◆ at() [1/2]

template<typename Scalar, typename Container>
point_type & at ( size_t i)
inlinenodiscard

Returns a reference to the image of i.

Parameters
ithe point.
Returns
A reference to a point_type.
Exceptions
std::out_of_rangeif i is out of range.
Complexity
Constant.

◆ at() [2/2]

template<typename Scalar, typename Container>
point_type const & at ( size_t i) const
inlinenodiscard

Returns a const reference to the image of i.

Parameters
ithe point.
Returns
A const reference to a point_type.
Exceptions
std::out_of_rangeif i is out of range.
Complexity
Constant.

◆ begin() [1/2]

template<typename Scalar, typename Container>
const_iterator begin ( ) const
inlinenodiscardnoexcept
Returns
A const iterator to the first image value.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ begin() [2/2]

template<typename Scalar, typename Container>
iterator begin ( )
inlinenodiscardnoexcept
Returns
An iterator to the first image value.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ cbegin()

template<typename Scalar, typename Container>
const_iterator cbegin ( ) const
inlinenodiscardnoexcept
Returns
A const iterator to the first image value.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ cend()

template<typename Scalar, typename Container>
const_iterator cend ( ) const
inlinenodiscardnoexcept
Returns
A const iterator pointing one past the last image value.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ degree()

template<typename Scalar, typename Container>
size_t degree ( ) const
inlinenodiscardnoexcept

The degree of a partial transformation is the number of points used in its definition, which is equal to the size of the underlying container.

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

◆ end() [1/2]

template<typename Scalar, typename Container>
const_iterator end ( ) const
inlinenodiscardnoexcept
Returns
A const iterator pointing one past the last image value.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ end() [2/2]

template<typename Scalar, typename Container>
iterator end ( )
inlinenodiscardnoexcept
Returns
An iterator pointing one past the last image value.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ hash_value()

template<typename Scalar, typename Container>
size_t hash_value ( ) const
inlinenodiscard
Returns
A value of type size_t.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in degree().

◆ make() [1/2]

template<typename Scalar, typename Container>
template<typename Subclass, typename OtherContainer = Container>
static Subclass make ( OtherContainer && cont)
staticnodiscard

Constructs a partial transformation initialized using the container cont as follows: the image of the point i under the partial transformation is the value in position i of the container cont.

Template Parameters
Subclassthe type of the return value.
OtherContaineruniversal reference for the type of the container (default: Container).
Parameters
contthe container.
Exceptions
LibsemigroupsExceptionif any of the following hold:
  • the size of cont is incompatible with container_type.
  • any value in cont exceeds cont.size() and is not equal to UNDEFINED.
Complexity
Linear in the size of the container cont.

◆ make() [2/2]

template<typename Scalar, typename Container>
template<typename Subclass, typename OtherScalar>
static Subclass make ( std::initializer_list< OtherScalar > cont)
staticnodiscard

Constructs a partial transformation initialized using the container cont as follows: the image of the point i under the partial transformation is the value in position i of the container cont.

Template Parameters
Subclassthe type of the return value.
OtherScalarthe type of the points in cont.
Parameters
contthe initializer list.
Exceptions
LibsemigroupsExceptionif any of the following hold:
  • the size of cont is incompatible with container_type.
  • any value in cont exceeds cont.size() and is not equal to UNDEFINED.
Complexity
Linear in the size of the container cont.

◆ one()

template<typename Scalar, typename Container>
template<typename Subclass>
static Subclass one ( size_t N)
inlinestaticnodiscard

This function returns a newly constructed partial transformation with degree equal to the degree of N that fixes every value from 0 to N - 1.

Template Parameters
Subclassthe return type.
Parameters
Nthe degree of the identity being constructed.
Returns
A value of type Subclass.

◆ operator!=()

template<typename Scalar, typename Container>
bool operator!= ( PTransfBase< Scalar, Container > const & that) const
inlinenodiscard

Returns true if *this does not equal that by comparing the image values of *this and that.

Parameters
thatthe partial transformation for comparison.
Returns
A value of type bool.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst linear in degree().

◆ operator*()

template<typename Scalar, typename Container>
template<typename Subclass>
Subclass operator* ( Subclass const & that) const
inlinenodiscard

Returns a newly constructed partial transformation holding the product of *this and that.

Template Parameters
Subclassthe return type.
Parameters
thata partial transformation.
Returns
A value of type Subclass.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in degree().
Warning
This function does not check its arguments. In particular, if *this and that have different degrees, then bad things may happen.

◆ operator<()

template<typename Scalar, typename Container>
bool operator< ( PTransfBase< Scalar, Container > const & that) const
inlinenodiscard

Returns true if *this is less than that by comparing the image values of *this and that.

Parameters
thatthe partial transformation for comparison.
Returns
A value of type bool.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst linear in degree().

◆ operator<=()

template<typename Scalar, typename Container>
bool operator<= ( PTransfBase< Scalar, Container > const & that) const
inlinenodiscard

Returns true if *this is less than or equal to that by comparing the image values of *this and that.

Parameters
thatthe partial transformation for comparison.
Returns
A value of type bool.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst linear in degree().

◆ operator=() [1/2]

template<typename Scalar, typename Container>
PTransfBase & operator= ( PTransfBase< Scalar, Container > && )
default

Default move assignment operator.

◆ operator=() [2/2]

template<typename Scalar, typename Container>
PTransfBase & operator= ( PTransfBase< Scalar, Container > const & )
default

Default copy assignment operator.

◆ operator==()

template<typename Scalar, typename Container>
bool operator== ( PTransfBase< Scalar, Container > const & that) const
inlinenodiscard

Returns true if *this equals that by comparing the image values of *this and that.

Parameters
thatthe partial transformation for comparison.
Returns
A value of type bool.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst linear in degree().

◆ operator>()

template<typename Scalar, typename Container>
bool operator> ( PTransfBase< Scalar, Container > const & that) const
inlinenodiscard

Returns true if *this is greater than that by comparing the image values of *this and that.

Parameters
thatthe partial transformation for comparison.
Returns
A value of type bool.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst linear in degree().

◆ operator>=()

template<typename Scalar, typename Container>
bool operator>= ( PTransfBase< Scalar, Container > const & that) const
inlinenodiscard

Returns true if *this is greater than or equal to that by comparing the image values of *this and that.

Parameters
thatthe partial transformation for comparison.
Returns
A value of type bool.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst linear in degree().

◆ operator[]() [1/2]

template<typename Scalar, typename Container>
point_type & operator[] ( size_t i)
inlinenodiscard

Returns a reference to the image of i.

Parameters
ithe point.
Returns
A reference to a point_type.
Complexity
Constant.
Warning
No bound checks are performed on i.

◆ operator[]() [2/2]

template<typename Scalar, typename Container>
point_type const & operator[] ( size_t i) const
inlinenodiscard

Returns a const reference to the image of i.

Parameters
ithe point.
Returns
A const reference to a point_type.
Complexity
Constant.
Warning
No bound checks are performed on i.

◆ rank()

template<typename Scalar, typename Container>
size_t rank ( ) const
inlinenodiscard

The rank of a partial transformation is the number of its distinct image values, not including UNDEFINED.

Returns
A value of type size_t.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in degree().

◆ swap()

template<typename Scalar, typename Container>
void swap ( PTransfBase< Scalar, Container > & that)
inlinenoexcept
Parameters
thatthe partial transformation to swap with.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ undef()

template<typename Scalar, typename Container>
static point_type undef ( )
inlinestaticnodiscardnoexcept

This static function returns the value of type point_type used to represent an "undefined" value.

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

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