AnySet Documentation
|
Primary classes and utility functions for AnySet.
Classes | |
struct | AnyHash |
Generic hash function object. More... | |
struct | AnySet |
AnySet is an associative container that contains a set of unique objects of any constructible type. Search, insertion, and removal have average constant-time complexity. Internally, the elements are not sorted in any particular order, but organized into buckets. Which bucket an element is placed into depends entirely on the hash of its value. This allows fast access to individual elements, since once a hash is computed, it refers to the exact bucket the element is placed into. More... | |
class | AnyValue |
struct | CompressedPair |
struct | ConstValueHolder |
struct | ConstValueHolder< Value, Tag, false > |
struct | ConstValueHolder< Value, Tag, true > |
struct | CopyConstructionError |
Base type of NoCopyConstructorError. Thrown when attempting to make copies of an AnyValue instance that contains a non-copy-constructible type. More... | |
struct | Hash |
Function object that implements a hash function for instances of type T. Inherits from std::hash<T> unless otherwise specialized by the user to not do so. More... | |
struct | Hash< std::array< T, N > > |
Specialize te::Hash for std::array. More... | |
struct | Hash< std::complex< T > > |
Specialize te::Hash for std::complex. More... | |
struct | Hash< std::pair< T, U > > |
Specialize te::Hash for std::pair. More... | |
struct | Hash< std::tuple< T... > > |
Specialize te::Hash for std::tuple. More... | |
struct | Hash< void > |
Function object that implements a hash function for instances of type T. More... | |
struct | NoCopyConstructorError |
Exception thrown when attempting to make copies of an AnyValue instance that contains an instance of non-copyable type T. More... | |
struct | ValueHolder |
struct | ValueHolder< Value, Tag, false > |
struct | ValueHolder< Value, Tag, true > |
Functions | |
template<class H , class E , class A > | |
std::ostream & | operator<< (std::ostream &os, const AnySet< H, E, A > &set) |
template<class T , class H , class C > | |
const T * | try_as (const AnyValue< H, C > &self) |
template<class T , class H , class C > | |
const T & | as (const AnyValue< H, C > &self) |
template<class T , class H , class C , class ... Args> | |
std::unique_ptr< AnyValue< H, C > > | make_any_value (std::size_t hash_value, Args &&... args) |
template<class T , class H , class C , class ... Args> | |
std::unique_ptr< AnyValue< H, C > > | make_any_value (H hasher, Args &&... args) |
template<class T , class U > | |
CompressedPair< std::decay_t< T >, std::decay_t< U > > | make_compressed_pair (T &&left, U &&right) |
template<class T , class U > | |
void | swap (CompressedPair< T, U > &left, CompressedPair< T, U > &right) noexcept(noexcept(left.swap(right))) |
Set Operation Free-Functions | |
template<class T , class ... U> | |
std::decay_t< T > | union_of (T &&first, U &&... args) |
Get the union of a group of AnySet instances. More... | |
template<class T , class ... U> | |
std::decay_t< T > | intersection_of (T &&first, U &&... args) |
Get the intersection of a group of AnySet instances. More... | |
template<class T , class ... U> | |
std::decay_t< T > | symmetric_difference_of (T &&first, U &&... args) |
Get the symmetric difference of a group of AnySet instances. More... | |
template<class T , class ... U> | |
std::decay_t< T > | difference_of (T &&left, const U &... right) |
Get the (asymmetric) difference of a group of AnySet instances. More... | |
template<class H , class E , class A > | |
bool | is_subset_of (const AnySet< H, E, A > &sub, const AnySet< H, E, A > &super) |
Determine whether sub is a subset of super . More... | |
template<class H , class E , class A > | |
bool | is_superset_of (const AnySet< H, E, A > &super, const AnySet< H, E, A > &sub) |
Determine whether super is a superset of sub . More... | |
Set Union Operators | |
template<class T , class U , class = std::enable_if_t< detail::is_any_set_v<std::decay_t<T>> and std::is_same_v<std::decay_t<T>, std::decay_t<U>> >> | |
std::decay_t< T > | operator+ (T &&left, U &&right) |
Compute the union of left and right as if by union_of(left, right); | |
template<class H , class E , class A > | |
AnySet< H, E, A > & | operator+= (AnySet< H, E, A > &left, AnySet< H, E, A > &&right) |
Compute the union of left and right as if by left = (left + right); | |
template<class H , class E , class A > | |
AnySet< H, E, A > & | operator+= (AnySet< H, E, A > &left, const AnySet< H, E, A > &right) |
Compute the union of left and right as if by left = (left + right); | |
template<class T , class U , class = std::enable_if_t< detail::is_any_set_v<std::decay_t<T>> and std::is_same_v<std::decay_t<T>, std::decay_t<U>> >> | |
std::decay_t< T > | operator| (T &&left, U &&right) |
Compute the union of left and right as if by union_of(left, right); | |
template<class H , class E , class A > | |
AnySet< H, E, A > & | operator|= (AnySet< H, E, A > &left, AnySet< H, E, A > &&right) |
Compute the union of left and right as if by left = (left + right); | |
template<class H , class E , class A > | |
AnySet< H, E, A > & | operator|= (AnySet< H, E, A > &left, const AnySet< H, E, A > &right) |
Compute the union of left and right as if by left = (left + right); | |
Set Intersection Operators | |
template<class T , class U , class = std::enable_if_t< detail::is_any_set_v<std::decay_t<T>> and std::is_same_v<std::decay_t<T>, std::decay_t<U>> >> | |
std::decay_t< T > | operator & (T &&left, U &&right) |
Compute the intersection of left and right as if by intersection_of(left, right); | |
template<class H , class E , class A > | |
AnySet< H, E, A > & | operator &= (AnySet< H, E, A > &left, AnySet< H, E, A > &&right) |
Compute the intersection of left and right as if by left = (left & right); | |
template<class H , class E , class A > | |
AnySet< H, E, A > & | operator &= (AnySet< H, E, A > &left, const AnySet< H, E, A > &right) |
Compute the intersection of left and right as if by left = (left & right); | |
Set Difference Operators | |
template<class T , class U , class = std::enable_if_t< detail::is_any_set_v<std::decay_t<T>> and std::is_same_v<std::decay_t<T>, std::decay_t<U>> >> | |
std::decay_t< T > | operator- (T &&left, U &&right) |
Compute the (asymmetric) difference of left and right as if by difference_of(left, right); | |
template<class H , class E , class A > | |
AnySet< H, E, A > & | operator-= (AnySet< H, E, A > &left, AnySet< H, E, A > &&right) |
Compute the (asymmetric) difference of left and right as if by left = (left - right); | |
template<class H , class E , class A > | |
AnySet< H, E, A > & | operator-= (AnySet< H, E, A > &left, const AnySet< H, E, A > &right) |
Compute the (asymmetric) difference of left and right as if by left = (left - right); | |
Set Symmetric Difference Operators | |
template<class T , class U , class = std::enable_if_t< detail::is_any_set_v<std::decay_t<T>> and std::is_same_v<std::decay_t<T>, std::decay_t<U>> >> | |
std::decay_t< T > | operator^ (T &&left, U &&right) |
Compute the symmetric difference of left and right as if by symmetric_difference_of(left, right); | |
template<class H , class E , class A , class U , class = std::enable_if_t<std::is_same_v<AnySet<H, E, A>, std::decay_t<U>>>> | |
AnySet< H, E, A > & | operator^= (AnySet< H, E, A > &left, U &&right) |
Compute the symmetric difference of left and right as if by left = (left ^ right); | |
Subset/Superset Operators | |
template<class H , class E , class A > | |
bool | operator<= (const AnySet< H, E, A > &left, const AnySet< H, E, A > &right) |
Semantically equivalent to is_subset_of(left, right); . | |
template<class H , class E , class A > | |
bool | operator< (const AnySet< H, E, A > &left, const AnySet< H, E, A > &right) |
Semantically equivalent to is_subset_of(left, right) && !(left.size() == right.size()); . | |
template<class H , class E , class A > | |
bool | operator>= (const AnySet< H, E, A > &left, const AnySet< H, E, A > &right) |
Semantically equivalent to is_superset_of(left, right); . | |
template<class H , class E , class A > | |
bool | operator> (const AnySet< H, E, A > &left, const AnySet< H, E, A > &right) |
Semantically equivalent to is_subset_of(left, right) && !(left.size() == right.size()); . | |
Stream Insertion Operators | |
template<class H , class E , class C > | |
std::ostream & | operator<< (std::ostream &os, const AnySet< H, E, C > &set) |
Write an AnySet instance to the std::ostream os . | |
Extra Hash Utilities | |
std::size_t | hash_combine (std::size_t first, std::size_t second) |
Combine two hash values using a formula that is compatible with boost::hash_combine(). More... | |
template<class T , class U , class ... Args, class = std::enable_if< (sizeof...(Args) > 0u> | |
std::size_t | hash_combine (T first, U second, Args ... args) |
Combine an arbitrary number of hash values using a formula that is compatible with boost::hash_combine(). More... | |
Higher-Level Accessors |
std::decay_t<T> te::difference_of | ( | T && | left, |
const U &... | right | ||
) |
Get the (asymmetric) difference of a group of AnySet instances.
All arguments (first
and args
...) must be AnySet instances with the same HashFn
and KeyEqual
values.
KeyEqual
function, not necessarily operator==.first | - the first set in the group. |
args | - the other sets in the group. |
first
and args
....
|
inline |
Combine two hash values using a formula that is compatible with boost::hash_combine().
first | - First hash value. |
second | - Second hash value. |
|
inline |
Combine an arbitrary number of hash values using a formula that is compatible with boost::hash_combine().
first | - First hash value. |
second | - Second hash value. |
args | - Other hash values. |
std::decay_t<T> te::intersection_of | ( | T && | first, |
U &&... | args | ||
) |
Get the intersection of a group of AnySet instances.
All arguments (first
and args
...) must be AnySet instances with the same HashFn
and KeyEqual
values.
KeyEqual
function, not necessarily operator==.first | - the first set in the group. |
args | - the other sets in the group. |
first
and args
.... bool te::is_subset_of | ( | const AnySet< H, E, A > & | sub, |
const AnySet< H, E, A > & | super | ||
) |
Determine whether sub
is a subset of super
.
sub | - The set to be considered the subset of super . |
super | - The set to be considered the superset of sub . |
KeyEqual
function, not necessarily operator==.sub
is a subset of super
. bool te::is_superset_of | ( | const AnySet< H, E, A > & | super, |
const AnySet< H, E, A > & | sub | ||
) |
Determine whether super
is a superset of sub
.
super | - The set to be considered the superset of sub . |
sub | - The set to be considered the subset of super . |
KeyEqual
function, not necessarily operator==.super
is a superset of sub
. std::decay_t<T> te::symmetric_difference_of | ( | T && | first, |
U &&... | args | ||
) |
Get the symmetric difference of a group of AnySet instances.
All arguments (first
and args
...) must be AnySet instances with the same HashFn
and KeyEqual
values.
KeyEqual
function, not necessarily operator==.first | - the first set in the group. |
args | - the other sets in the group. |
first
and args
.... std::decay_t<T> te::union_of | ( | T && | first, |
U &&... | args | ||
) |
Get the union of a group of AnySet instances.
All arguments (first
and args
...) must be AnySet instances with the same HashFn
and KeyEqual
values.
KeyEqual
function, not necessarily operator==.first | - the first set in the group. |
args | - the other sets in the group. |
first
and args
....