Regina 7.0 Calculation Engine
Public Member Functions | List of all members
regina::LightweightSequence< T >::SubsequenceCompareFirst< IndexIterator > Class Template Reference

A binary function object for comparing subsequences, for use in associative containers whose keys are sequences. More...

#include <utilities/sequence.h>

Public Member Functions

 SubsequenceCompareFirst (IndexIterator beginSub, IndexIterator endSub)
 Creates a new function object. More...
 
 SubsequenceCompareFirst (const SubsequenceCompareFirst &)=default
 Copies the given function object into this new object. More...
 
SubsequenceCompareFirstoperator= (const SubsequenceCompareFirst &)=default
 Copies the given function object into this object. More...
 
template<typename SeqIterator >
bool equal (SeqIterator a, SeqIterator b) const
 Tests whether the subsequences referred to by the given pair of iterators are identical. More...
 
template<typename SeqIterator >
bool less (SeqIterator a, SeqIterator b) const
 Lexicographically compares the subsequences referred to by the given pair of iterators. More...
 
template<typename SeqIterator >
bool operator() (SeqIterator a, SeqIterator b) const
 Lexicographically compares the subsequences referred to by the given pair of iterators. More...
 

Detailed Description

template<typename T>
template<typename IndexIterator>
class regina::LightweightSequence< T >::SubsequenceCompareFirst< IndexIterator >

A binary function object for comparing subsequences, for use in associative containers whose keys are sequences.

This is a very specialised comparison object, for use in the following settings:

More precisely: suppose the indices of the elements to compare are i0, i1, i2, ..., and that we are comparing iterators a, b. Then this function object will consider the sequences s = a->first and t = b->first, and will lexicographically compare their subsequences s[i0], s[i1], ... and t[i0], t[i1], ....

Note that the indices i0, i1, ... do not need to be in increasing order.

This class is meant to be lightweight: it merely stores a reference to the list of elements to compare, and it is safe and fast to pass around by value. The cost of this is that the caller must ensure that the list of elements to compare (which is a C-style array) has a lifespan at least as long as this object. This behaviour is new as of Regina 5.96; in past versions of Regina the list of elements was copied on construction.

Template Parameters
IndexIteratorthe iterator type used to store the range of indices that define the subsequences being compared (that is, the range of indices i0, i1, i2, ...). This would be deducible from the constructor arguments, were it not for a gcc bug (#79501) that prevents us from declaring a deduction guide.

Constructor & Destructor Documentation

◆ SubsequenceCompareFirst() [1/2]

template<typename T >
template<typename IndexIterator >
regina::LightweightSequence< T >::SubsequenceCompareFirst< IndexIterator >::SubsequenceCompareFirst ( IndexIterator  beginSub,
IndexIterator  endSub 
)
inline

Creates a new function object.

As explained in the class notes, this object compares just some, not necessarily all, elements of two sequences. The indices of the elements to compare should be passed to this constructor using an iterator range. Specifically, the range defined by beginSub and endSub should contain the indices i0, i1, ..., as described in the class notes.

Warning
This class merely copies the iterators beginSub and endSub, and does not take a deep copy of the range that they define. The caller of this routine must ensure that these iterators remain valid for the entire lifespan of this function object and any function objects that are copied from it.
Parameters
beginSubthe beginning of the range of indices of elements to compare from each sequence.
endSubthe end (i.e., a past-the-end iterator) of the range of indices of elements to compare from each sequence.

◆ SubsequenceCompareFirst() [2/2]

template<typename T >
template<typename IndexIterator >
regina::LightweightSequence< T >::SubsequenceCompareFirst< IndexIterator >::SubsequenceCompareFirst ( const SubsequenceCompareFirst< IndexIterator > &  )
default

Copies the given function object into this new object.

Member Function Documentation

◆ equal()

template<typename T >
template<typename IndexIterator >
template<typename SeqIterator >
bool regina::LightweightSequence< T >::SubsequenceCompareFirst< IndexIterator >::equal ( SeqIterator  a,
SeqIterator  b 
) const
inline

Tests whether the subsequences referred to by the given pair of iterators are identical.

See the class notes for details on how each iterator is converted into a subsequence.

Parameters
aan iterator indicating the first of the two subsequences to compare.
ban iterator indicating the second of the two subsequences to compare.
Returns
true if and only if the two subsequences are identical.

◆ less()

template<typename T >
template<typename IndexIterator >
template<typename SeqIterator >
bool regina::LightweightSequence< T >::SubsequenceCompareFirst< IndexIterator >::less ( SeqIterator  a,
SeqIterator  b 
) const
inline

Lexicographically compares the subsequences referred to by the given pair of iterators.

See the class notes for details on how each iterator is converted into a subsequence.

This member function is identical to the bracket operator.

Parameters
aan iterator indicating the first of the two subsequences to compare.
ban iterator indicating the second of the two subsequences to compare.
Returns
true if and only if the subsequence indicated by a is lexicographically smaller than the subsequence indicated by b.

◆ operator()()

template<typename T >
template<typename IndexIterator >
template<typename SeqIterator >
bool regina::LightweightSequence< T >::SubsequenceCompareFirst< IndexIterator >::operator() ( SeqIterator  a,
SeqIterator  b 
) const
inline

Lexicographically compares the subsequences referred to by the given pair of iterators.

See the class notes for details on how each iterator is converted into a subsequence.

This bracket operator is identical to the less() member function.

Parameters
aan iterator indicating the first of the two subsequences to compare.
ban iterator indicating the second of the two subsequences to compare.
Returns
true if and only if the subsequence indicated by a is lexicographically smaller than the subsequence indicated by b.

◆ operator=()

template<typename T >
template<typename IndexIterator >
SubsequenceCompareFirst & regina::LightweightSequence< T >::SubsequenceCompareFirst< IndexIterator >::operator= ( const SubsequenceCompareFirst< IndexIterator > &  )
default

Copies the given function object into this object.

Returns
a reference to this function object.

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

Copyright © 1999-2021, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).