Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
EqualToMethod< Container > Class Template Reference

Equality test for sets. More...

#include <ah-dry.H>

Inheritance diagram for EqualToMethod< Container >:
[legend]

Public Member Functions

template<class C = Container>
requires Aleph::dry_detail::SetSearchable<C>
bool equal_to (const Container &r) const
 Test if elements of this are exactly contained in another container.
 

Private Member Functions

const Container * const_me () const noexcept
 

Friends

template<class C = Container>
requires Aleph::dry_detail::SetSearchable<C>
bool operator== (const Container &l, const Container &r)
 Equality operator: l.equal_to(r).
 
template<class C = Container>
requires Aleph::dry_detail::SetSearchable<C>
bool operator!= (const Container &l, const Container &r)
 Negation of equal_to()
 

Detailed Description

template<class Container>
class EqualToMethod< Container >

Equality test for sets.

The test compares the sizes and then searches each element of this in the other container with search(). That is the equality of sets only: it ignores the order and the repetitions, so it is offered only to containers that have Key_Type and search(), and is meant for containers that keep no repeated keys, such as hash tables.

Sequences use EqualSequenceMethod, and sorted containers that may keep repeated keys use EqualSortedMethod.

Definition at line 3025 of file ah-dry.H.

Member Function Documentation

◆ const_me()

template<class Container >
const Container * EqualToMethod< Container >::const_me ( ) const
inlineprivatenoexcept

Definition at line 3027 of file ah-dry.H.

Referenced by EqualToMethod< Container >::equal_to().

◆ equal_to()

template<class Container >
template<class C = Container>
requires Aleph::dry_detail::SetSearchable<C>
bool EqualToMethod< Container >::equal_to ( const Container &  r) const
inline

Test if elements of this are exactly contained in another container.

This method serves for testing if two containers contain the same elements. First, the container sizes are tested for equality. If they have the same size, then the testing is done by traversing this. Each seen element is searched in the another container with the method search().

Warning
On some container, the size is computed, not retrieved. So take in account this fact.
Parameters
[in]rcontainer on which the searches will be performed.
Returns
true if the container have the same size and all the elements of this are present in r
Exceptions
anythingthat size(), search() or the comparator or hash function of the container throws.

Definition at line 3053 of file ah-dry.H.

References EqualToMethod< Container >::const_me(), k, and r.

Friends And Related Symbol Documentation

◆ operator!=

template<class Container >
template<class C = Container>
requires Aleph::dry_detail::SetSearchable<C>
bool operator!= ( const Container &  l,
const Container &  r 
)
friend

Negation of equal_to()

Parameters
[in]lcontainer to compare.
[in]rcontainer to compare with.
Returns
negation of l.equal_to(r).
Exceptions
whatequal_to() throws.

Definition at line 3095 of file ah-dry.H.

◆ operator==

template<class Container >
template<class C = Container>
requires Aleph::dry_detail::SetSearchable<C>
bool operator== ( const Container &  l,
const Container &  r 
)
friend

Equality operator: l.equal_to(r).

A hidden friend with two parameters of the same type, so that the C++20 reversed candidate is never ambiguous; a template so that its constraint is checked on use (Clang 14 checks the constraint of a non-template member when the class is instantiated).

Parameters
[in]lcontainer to compare.
[in]rcontainer to compare with.
Returns
result of l.equal_to(r).
Exceptions
whatequal_to() throws.

Definition at line 3082 of file ah-dry.H.


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