Binary Relations
Three new associative container classes
Loading...
Searching...
No Matches
BinaryRelations::OneToOne< LeftType, RightType > Class Template Reference

#include <BinaryRelations.h>

Classes

class  Iterator
 A range-based-for compatible iterator. More...
 
struct  Pair
 A pair of (left, right) values. More...
 

Public Member Functions

 OneToOne () noexcept
 Default constructor.
 
void insert (const Pair &pair) noexcept
 Insert a pair into the set. The rule for one-to-one is that if the rleft value or the ight value are part of an existing pairs in the set, those relations will be erased.
 
void insert (const LeftType &left, const RightType &right) noexcept
 Insert a pair into the set. The rule for one-to-one is that if the left value or the right value are part of existing pairs in the set, those relations will be erased.
 
void insert (const std::vector< Pair > &pairs) noexcept
 Insert multiple pairs into the set. The rule for one-to-one is that if the left value or the right value are part of existing pairs in the set, those relations will be erased.
 
void erase (const Pair &pair) noexcept
 Erase a pair from the set. If there is no matching pair in the set, nothing happens.
 
void erase (const LeftType &left, const RightType &right) noexcept
 Erase a pair from the set. If there is no matching pair in the set, nothing happens.
 
void eraseLeft (const LeftType &left) noexcept
 Erase all pairs with the given left value. If there is no matching pair in the set, nothing happens.
 
void eraseRight (const RightType &right) noexcept
 Erase the pair with the given right value. If there is no matching pair in the set, nothing happens.
 
void erase (const std::vector< Pair > &pairs) noexcept
 Erase multiple pairs from the set. This is equivalent to erasing the pairs one by one.
 
void clear () noexcept
 Erase all pairs from the set.
 
bool contains (const Pair &pair) const noexcept
 Test whether a given pair is in the set.
 
bool contains (const LeftType &left, const RightType &right) const noexcept
 Test whether a given pair is in the set.
 
bool containsLeft (const LeftType &left) const noexcept
 Test whether any pair in the set has this left value.
 
bool containsRight (const RightType &right) const noexcept
 Test whether any pair in the set has this right value.
 
RightType findRight (const LeftType &left, const RightType &notFoundValue) const noexcept
 Find the single right value that is paired with this left value. If nothing is found, you will get the notFoundValue.
 
LeftType findLeft (const RightType &right, const LeftType &notFoundValue) const noexcept
 Find the single left value that is paired with this right value. If nothing is found, you will get the notFoundValue.
 
int countLeft () const noexcept
 Count the number of left values in the set.
 
int countRight () const noexcept
 Count the number of right values in the set.
 
int count () const noexcept
 Count the number of pairs in the set.
 
UnorderedMapHelper< LeftType, RightType > allLeft () const noexcept
 List all left elements.
 
UnorderedMapHelper< RightType, LeftType > allRight () const noexcept
 List all right elements.
 
Iterator begin () const noexcept
 Required member to get range-based-for.
 
Iterator end () const noexcept
 Required member to get range-based-for.
 

Detailed Description

template<typename LeftType, typename RightType>
class BinaryRelations::OneToOne< LeftType, RightType >

A one-to-one set of (left, right) pairs. Any left or right value can only be paired with one counterpart.

one-to-one

Definition at line 1270 of file BinaryRelations.h.

Constructor & Destructor Documentation

◆ OneToOne()

template<typename LeftType , typename RightType >
BinaryRelations::OneToOne< LeftType, RightType >::OneToOne ( )
inlinenoexcept

Default constructor.

Definition at line 1293 of file BinaryRelations.h.

Member Function Documentation

◆ allLeft()

template<typename LeftType , typename RightType >
UnorderedMapHelper< LeftType, RightType > BinaryRelations::OneToOne< LeftType, RightType >::allLeft ( ) const
inlinenoexcept

List all left elements.

Returns
A helper object to iterate over left elements using range-based-for.

Definition at line 1517 of file BinaryRelations.h.

◆ allRight()

template<typename LeftType , typename RightType >
UnorderedMapHelper< RightType, LeftType > BinaryRelations::OneToOne< LeftType, RightType >::allRight ( ) const
inlinenoexcept

List all right elements.

Returns
A helper object to iterate over right elements using range-based-for.

Definition at line 1526 of file BinaryRelations.h.

◆ begin()

template<typename LeftType , typename RightType >
Iterator BinaryRelations::OneToOne< LeftType, RightType >::begin ( ) const
inlinenoexcept

Required member to get range-based-for.

Returns
an Iterator set to the first pair in the set.

Definition at line 1565 of file BinaryRelations.h.

◆ clear()

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::clear ( )
inlinenoexcept

Erase all pairs from the set.

Definition at line 1414 of file BinaryRelations.h.

◆ contains() [1/2]

template<typename LeftType , typename RightType >
bool BinaryRelations::OneToOne< LeftType, RightType >::contains ( const LeftType & left,
const RightType & right ) const
inlinenoexcept

Test whether a given pair is in the set.

Parameters
leftThe left side of the pair to look for.
rightThe right side of the pair to look for.

Definition at line 1434 of file BinaryRelations.h.

◆ contains() [2/2]

template<typename LeftType , typename RightType >
bool BinaryRelations::OneToOne< LeftType, RightType >::contains ( const Pair & pair) const
inlinenoexcept

Test whether a given pair is in the set.

Parameters
pairThe pair to look for.

Definition at line 1424 of file BinaryRelations.h.

◆ containsLeft()

template<typename LeftType , typename RightType >
bool BinaryRelations::OneToOne< LeftType, RightType >::containsLeft ( const LeftType & left) const
inlinenoexcept

Test whether any pair in the set has this left value.

Parameters
leftThe left side of the pair to look for.

Definition at line 1444 of file BinaryRelations.h.

◆ containsRight()

template<typename LeftType , typename RightType >
bool BinaryRelations::OneToOne< LeftType, RightType >::containsRight ( const RightType & right) const
inlinenoexcept

Test whether any pair in the set has this right value.

Parameters
rightThe right side of the pair to look for.

Definition at line 1454 of file BinaryRelations.h.

◆ count()

template<typename LeftType , typename RightType >
int BinaryRelations::OneToOne< LeftType, RightType >::count ( ) const
inlinenoexcept

Count the number of pairs in the set.

Returns
The number of pairs in the set.

Definition at line 1508 of file BinaryRelations.h.

◆ countLeft()

template<typename LeftType , typename RightType >
int BinaryRelations::OneToOne< LeftType, RightType >::countLeft ( ) const
inlinenoexcept

Count the number of left values in the set.

Returns
The number of left values in the set.

Definition at line 1490 of file BinaryRelations.h.

◆ countRight()

template<typename LeftType , typename RightType >
int BinaryRelations::OneToOne< LeftType, RightType >::countRight ( ) const
inlinenoexcept

Count the number of right values in the set.

Returns
The number of right values in the set.

Definition at line 1499 of file BinaryRelations.h.

◆ end()

template<typename LeftType , typename RightType >
Iterator BinaryRelations::OneToOne< LeftType, RightType >::end ( ) const
inlinenoexcept

Required member to get range-based-for.

Returns
an Iterator set to one after the last pair in the set.

Definition at line 1576 of file BinaryRelations.h.

◆ erase() [1/3]

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::erase ( const LeftType & left,
const RightType & right )
inlinenoexcept

Erase a pair from the set. If there is no matching pair in the set, nothing happens.

Parameters
leftThe left side of the pair to erase.
rightThe right side of the pair to erase.

Definition at line 1352 of file BinaryRelations.h.

◆ erase() [2/3]

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::erase ( const Pair & pair)
inlinenoexcept

Erase a pair from the set. If there is no matching pair in the set, nothing happens.

Parameters
pairThe pair to erase.

Definition at line 1341 of file BinaryRelations.h.

◆ erase() [3/3]

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::erase ( const std::vector< Pair > & pairs)
inlinenoexcept

Erase multiple pairs from the set. This is equivalent to erasing the pairs one by one.

Parameters
pairsThe pairs to erase.

Definition at line 1403 of file BinaryRelations.h.

◆ eraseLeft()

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::eraseLeft ( const LeftType & left)
inlinenoexcept

Erase all pairs with the given left value. If there is no matching pair in the set, nothing happens.

Parameters
leftThe left side of the pairs to erase.

Definition at line 1369 of file BinaryRelations.h.

◆ eraseRight()

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::eraseRight ( const RightType & right)
inlinenoexcept

Erase the pair with the given right value. If there is no matching pair in the set, nothing happens.

Parameters
rightThe right side of the pairs to erase.

Definition at line 1386 of file BinaryRelations.h.

◆ findLeft()

template<typename LeftType , typename RightType >
LeftType BinaryRelations::OneToOne< LeftType, RightType >::findLeft ( const RightType & right,
const LeftType & notFoundValue ) const
inlinenoexcept

Find the single left value that is paired with this right value. If nothing is found, you will get the notFoundValue.

Parameters
rightThe right side of the pair to look for.
notFoundValueThe value to return if no matching pair is found.
Returns
The singular left value.

Definition at line 1480 of file BinaryRelations.h.

◆ findRight()

template<typename LeftType , typename RightType >
RightType BinaryRelations::OneToOne< LeftType, RightType >::findRight ( const LeftType & left,
const RightType & notFoundValue ) const
inlinenoexcept

Find the single right value that is paired with this left value. If nothing is found, you will get the notFoundValue.

Parameters
leftThe left side of the pair to look for.
notFoundValueThe value to return if no matching pair is found.
Returns
The singular right value.

Definition at line 1467 of file BinaryRelations.h.

◆ insert() [1/3]

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::insert ( const LeftType & left,
const RightType & right )
inlinenoexcept

Insert a pair into the set. The rule for one-to-one is that if the left value or the right value are part of existing pairs in the set, those relations will be erased.

Parameters
leftThe left side of the pair to add.
rightThe right side of the pair to add.

Definition at line 1312 of file BinaryRelations.h.

◆ insert() [2/3]

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::insert ( const Pair & pair)
inlinenoexcept

Insert a pair into the set. The rule for one-to-one is that if the rleft value or the ight value are part of an existing pairs in the set, those relations will be erased.

Parameters
pairThe pair to insert.

Definition at line 1301 of file BinaryRelations.h.

◆ insert() [3/3]

template<typename LeftType , typename RightType >
void BinaryRelations::OneToOne< LeftType, RightType >::insert ( const std::vector< Pair > & pairs)
inlinenoexcept

Insert multiple pairs into the set. The rule for one-to-one is that if the left value or the right value are part of existing pairs in the set, those relations will be erased.

Parameters
pairsThe pairs to add.

Definition at line 1328 of file BinaryRelations.h.


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