libsemigroups
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
libsemigroups::ElementWithVectorData< TValueType, TSubclass > Class Template Reference

Abstract base class for elements using a vector to store their defining data. More...

#include <elements.h>

Inheritance diagram for libsemigroups::ElementWithVectorData< TValueType, TSubclass >:
Inheritance graph
Collaboration diagram for libsemigroups::ElementWithVectorData< TValueType, TSubclass >:
Collaboration graph

Public Member Functions

 ElementWithVectorData ()
 A constructor. More...
 
 ElementWithVectorData (std::vector< TValueType > *vector)
 A constructor. More...
 
 ElementWithVectorData (std::vector< TValueType > const &vector)
 A constructor. More...
 
TValueType at (size_t pos) const
 Returns the pos entry in the vector containing the defining data. More...
 
std::vector< TValueType >::iterator begin () const
 Returns an iterator. More...
 
std::vector< TValueType >::iterator cbegin () const
 Returns a const iterator. More...
 
std::vector< TValueType >::iterator cend () const
 Returns a const iterator. More...
 
void copy (Element const *x) override
 Copy another Element into this. More...
 
std::vector< TValueType >::iterator end () const
 Returns an iterator. More...
 
bool operator< (Element const &that) const override
 Returns true if this is less than that. More...
 
bool operator== (Element const &that) const override
 Returns true if this equals that. More...
 
TValueType operator[] (size_t pos) const
 Returns the pos entry in the vector containing the defining data. More...
 
Elementreally_copy (size_t increase_deg_by=0) const override
 Returns a pointer to a copy of this. More...
 
void really_delete () override
 Deletes the defining data of an ElementWithVectorData. More...
 
void swap (Element *x) override
 Swap another Element with this. More...
 
- Public Member Functions inherited from libsemigroups::Element
 Element (elm_t type=Element::elm_t::NOT_RWSE)
 A constructor. More...
 
virtual ~Element ()
 A default destructor. More...
 
virtual size_t complexity () const =0
 Returns the approximate time complexity of multiplying two Element objects in a given subclass. More...
 
virtual size_t degree () const =0
 Returns the degree of an Element. More...
 
elm_t get_type () const
 Returns the type libsemigroups::Element::elm_t of an Element object. More...
 
size_t hash_value () const
 Return the hash value of an Element. More...
 
virtual Elementidentity () const =0
 Returns a new copy of the identity element. More...
 
virtual void redefine (Element const *x, Element const *y)
 Multiplies x and y and stores the result in this. More...
 
virtual void redefine (Element const *x, Element const *y, size_t const &thread_id)
 Multiplies x and y and stores the result in this. More...
 

Static Protected Member Functions

template<typename T >
static size_t vector_hash (std::vector< T > const *vec)
 Returns a hash value for a vector provided there is a specialization of std::hash for the template type T. More...
 

Protected Attributes

std::vector< TValueType > * _vector
 The vector containing the defining data of this. More...
 

Additional Inherited Members

- Public Types inherited from libsemigroups::Element
enum  elm_t { RWSE = 0, NOT_RWSE = 1 }
 This enum contains some different types of Element. More...
 
- Protected Member Functions inherited from libsemigroups::Element
virtual void cache_hash_value () const =0
 Calculate and cache a hash value. More...
 
void reset_hash_value () const
 Reset the cached value used by Element::hash_value. More...
 
- Static Protected Attributes inherited from libsemigroups::Element
static size_t const UNDEFINED = std::numeric_limits<size_t>::max()
 UNDEFINED value. More...
 

Detailed Description

template<typename TValueType, class TSubclass>
class libsemigroups::ElementWithVectorData< TValueType, TSubclass >

Abstract base class for elements using a vector to store their defining data.

The template parameter TValueType is the type entries in the vector containing the defining data.

The template parameter TSubclass is the subclass of ElementWithVectorData used by certain methods to construct new instances of subclasses of ElementWithVectorData.

For example, Transformation<u_int128_t> is a subclass of ElementWithVectorData<u_int128_t, Transformation<u_int128_t>> so that when the identity method in this class is called it returns a Transformation and not an ElementWithVectorData.

Constructor & Destructor Documentation

◆ ElementWithVectorData() [1/3]

template<typename TValueType, class TSubclass>
libsemigroups::ElementWithVectorData< TValueType, TSubclass >::ElementWithVectorData ( )
inline

A constructor.

Returns an object with an uninitialised vector.

◆ ElementWithVectorData() [2/3]

template<typename TValueType, class TSubclass>
libsemigroups::ElementWithVectorData< TValueType, TSubclass >::ElementWithVectorData ( std::vector< TValueType > *  vector)
inlineexplicit

A constructor.

The parameter vector should be a pointer to defining data of the element.

Returns an object whose defining data is stored in vector, which is not copied, and is deleted using Element::really_delete.

◆ ElementWithVectorData() [3/3]

template<typename TValueType, class TSubclass>
libsemigroups::ElementWithVectorData< TValueType, TSubclass >::ElementWithVectorData ( std::vector< TValueType > const &  vector)
inlineexplicit

A constructor.

The parameter vector should be a const reference to defining data of the element.

Returns an object whose defining data is a copy of vector.

Member Function Documentation

◆ at()

template<typename TValueType, class TSubclass>
TValueType libsemigroups::ElementWithVectorData< TValueType, TSubclass >::at ( size_t  pos) const
inline

Returns the pos entry in the vector containing the defining data.

This method returns the pos entry in the vector used to construct this.

◆ begin()

template<typename TValueType, class TSubclass>
std::vector<TValueType>::iterator libsemigroups::ElementWithVectorData< TValueType, TSubclass >::begin ( ) const
inline

Returns an iterator.

This method returns an iterator pointing at the first entry in the vector that is the underlying defining data of this.

◆ cbegin()

template<typename TValueType, class TSubclass>
std::vector<TValueType>::iterator libsemigroups::ElementWithVectorData< TValueType, TSubclass >::cbegin ( ) const
inline

Returns a const iterator.

This method returns a const_iterator pointing at the first entry in the vector that is the underlying defining data of this.

◆ cend()

template<typename TValueType, class TSubclass>
std::vector<TValueType>::iterator libsemigroups::ElementWithVectorData< TValueType, TSubclass >::cend ( ) const
inline

Returns a const iterator.

This method returns a const iterator referring to the past-the-end element of the vector that is the underlying defining data of this.

◆ copy()

template<typename TValueType, class TSubclass>
void libsemigroups::ElementWithVectorData< TValueType, TSubclass >::copy ( Element const *  x)
inlineoverridevirtual

Copy another Element into this.

This method copies x into this by changing this in-place. This method asserts that the degrees of this and x are equal and then replaces the underlying vector of this with the underlying vector of x. Any method overriding this one must define _hash_value correctly or call Element::reset_hash_value on this.

Implements libsemigroups::Element.

◆ end()

template<typename TValueType, class TSubclass>
std::vector<TValueType>::iterator libsemigroups::ElementWithVectorData< TValueType, TSubclass >::end ( ) const
inline

Returns an iterator.

This method returns an iterator referring to the past-the-end element of the vector that is the underlying defining data of this.

◆ operator<()

template<typename TValueType, class TSubclass>
bool libsemigroups::ElementWithVectorData< TValueType, TSubclass >::operator< ( Element const &  that) const
inlineoverridevirtual

Returns true if this is less than that.

This method defines a total order on the set of objects in ElementWithVectorData of a given Element::degree, which is the short-lex order.

Implements libsemigroups::Element.

◆ operator==()

template<typename TValueType, class TSubclass>
bool libsemigroups::ElementWithVectorData< TValueType, TSubclass >::operator== ( Element const &  that) const
inlineoverridevirtual

Returns true if this equals that.

This method checks that the underlying vectors of this and that are equal.

Implements libsemigroups::Element.

◆ operator[]()

template<typename TValueType, class TSubclass>
TValueType libsemigroups::ElementWithVectorData< TValueType, TSubclass >::operator[] ( size_t  pos) const
inline

Returns the pos entry in the vector containing the defining data.

This method returns the pos entry in the vector used to construct this. No checks are performed that pos in within the bounds of this vector.

◆ really_copy()

template<typename TValueType, class TSubclass>
Element* libsemigroups::ElementWithVectorData< TValueType, TSubclass >::really_copy ( size_t  increase_deg_by = 0) const
inlineoverridevirtual

Returns a pointer to a copy of this.

The size of the vector containing the defining data of this will be increased by increase_deg_by. If increase_deg_by is not 0, then this method must be overridden by any subclass of ElementWithVectorData since there is no way of knowing how a subclass is defined by the data in the vector.

Implements libsemigroups::Element.

Reimplemented in libsemigroups::MatrixOverSemiringBase< TValueType, TSubclass >, libsemigroups::MatrixOverSemiringBase< bool, BooleanMat >, libsemigroups::MatrixOverSemiringBase< TValueType, MatrixOverSemiring< TValueType > >, and libsemigroups::MatrixOverSemiringBase< int64_t, ProjectiveMaxPlusMatrix >.

◆ really_delete()

template<typename TValueType, class TSubclass>
void libsemigroups::ElementWithVectorData< TValueType, TSubclass >::really_delete ( )
inlineoverridevirtual

Deletes the defining data of an ElementWithVectorData.

Implements libsemigroups::Element.

◆ swap()

template<typename TValueType, class TSubclass>
void libsemigroups::ElementWithVectorData< TValueType, TSubclass >::swap ( Element x)
inlineoverridevirtual

Swap another Element with this.

This method swaps the defining data of x and this. This method asserts that the degrees of this and x are equal and then swaps the underlying vector of this with the underlying vector of x. Any method overriding should swap the hash_value of this and x, or call Element::reset_hash_value on this and x.

Implements libsemigroups::Element.

◆ vector_hash()

template<typename TValueType, class TSubclass>
template<typename T >
static size_t libsemigroups::ElementWithVectorData< TValueType, TSubclass >::vector_hash ( std::vector< T > const *  vec)
inlinestaticprotected

Returns a hash value for a vector provided there is a specialization of std::hash for the template type T.

Member Data Documentation

◆ _vector

template<typename TValueType, class TSubclass>
std::vector<TValueType>* libsemigroups::ElementWithVectorData< TValueType, TSubclass >::_vector
protected

The vector containing the defining data of this.

The actual data defining of this is stored in _vector.


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