Binary Relations
Three new associative container classes
|
#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 | |
OneToMany () noexcept | |
Default constructor. | |
void | insert (const Pair &pair) noexcept |
Insert a pair into the set. The rule for one-to-many is that if the right value is part of an existing pair in the set, that relation will be erased. | |
void | insert (const LeftType &left, const RightType &right) noexcept |
Insert a pair into the set. The rule for one-to-many is that if the right value is part of an existing pair in the set, that relation will be erased. | |
void | insert (const std::vector< Pair > &pairs) noexcept |
Insert multiple pairs into the set. This is faster than inserting the pairs one by one. The rule for one-to-many is that if the right value is part of an existing pair in the set, that pair 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 faster than 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. | |
const std::vector< RightType > * | findRight (const LeftType &left) const noexcept |
Find all right values that are paired with this left value. If nothing is found, you will get an empty array. This works well with range-based-for. | |
LeftType | findLeft (const RightType &right, const LeftType ¬FoundValue) 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, std::vector< 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. | |
A one-to-many set of (left, right) pairs. The left side can have any number of right counterparts. The right side can only be in a pair with one left side.
Definition at line 211 of file BinaryRelations.h.
|
inlinenoexcept |
Default constructor.
Definition at line 236 of file BinaryRelations.h.
|
inlinenoexcept |
List all left elements.
Definition at line 612 of file BinaryRelations.h.
|
inlinenoexcept |
List all right elements.
Definition at line 621 of file BinaryRelations.h.
|
inlinenoexcept |
Required member to get range-based-for.
Definition at line 674 of file BinaryRelations.h.
|
inlinenoexcept |
Erase all pairs from the set.
Definition at line 505 of file BinaryRelations.h.
|
inlinenoexcept |
Test whether a given pair is in the set.
left | The left side of the pair to look for. |
right | The right side of the pair to look for. |
Definition at line 525 of file BinaryRelations.h.
|
inlinenoexcept |
Test whether a given pair is in the set.
pair | The pair to look for. |
Definition at line 515 of file BinaryRelations.h.
|
inlinenoexcept |
Test whether any pair in the set has this left value.
left | The left side of the pair to look for. |
Definition at line 535 of file BinaryRelations.h.
|
inlinenoexcept |
Test whether any pair in the set has this right value.
right | The right side of the pair to look for. |
Definition at line 544 of file BinaryRelations.h.
|
inlinenoexcept |
Count the number of pairs in the set.
Definition at line 603 of file BinaryRelations.h.
|
inlinenoexcept |
Count the number of left values in the set.
Definition at line 585 of file BinaryRelations.h.
|
inlinenoexcept |
Count the number of right values in the set.
Definition at line 594 of file BinaryRelations.h.
|
inlinenoexcept |
Required member to get range-based-for.
Definition at line 691 of file BinaryRelations.h.
|
inlinenoexcept |
Erase a pair from the set. If there is no matching pair in the set, nothing happens.
left | The left side of the pair to erase. |
right | The right side of the pair to erase. |
Definition at line 389 of file BinaryRelations.h.
|
inlinenoexcept |
Erase a pair from the set. If there is no matching pair in the set, nothing happens.
pair | The pair to erase. |
Definition at line 378 of file BinaryRelations.h.
|
inlinenoexcept |
Erase multiple pairs from the set. This is faster than erasing the pairs one by one.
pairs | The pairs to erase. |
Definition at line 453 of file BinaryRelations.h.
|
inlinenoexcept |
Erase all pairs with the given left value. If there is no matching pair in the set, nothing happens.
left | The left side of the pairs to erase. |
Definition at line 418 of file BinaryRelations.h.
|
inlinenoexcept |
Erase the pair with the given right value. If there is no matching pair in the set, nothing happens.
right | The right side of the pairs to erase. |
Definition at line 440 of file BinaryRelations.h.
|
inlinenoexcept |
Find the single left value that is paired with this right value. If nothing is found, you will get the notFoundValue.
right | The right side of the pair to look for. |
notFoundValue | The value to return if no matching pair is found. |
Definition at line 572 of file BinaryRelations.h.
|
inlinenoexcept |
Find all right values that are paired with this left value. If nothing is found, you will get an empty array. This works well with range-based-for.
left | The left side of the pair to look for. |
Definition at line 556 of file BinaryRelations.h.
|
inlinenoexcept |
Insert a pair into the set. The rule for one-to-many is that if the right value is part of an existing pair in the set, that relation will be erased.
left | The left side of the pair to add. |
right | The right side of the pair to add. |
Definition at line 255 of file BinaryRelations.h.
|
inlinenoexcept |
Insert a pair into the set. The rule for one-to-many is that if the right value is part of an existing pair in the set, that relation will be erased.
pair | The pair to insert. |
Definition at line 244 of file BinaryRelations.h.
|
inlinenoexcept |
Insert multiple pairs into the set. This is faster than inserting the pairs one by one. The rule for one-to-many is that if the right value is part of an existing pair in the set, that pair will be erased.
pairs | The pairs to add. |
Definition at line 283 of file BinaryRelations.h.