A set of integers, based on sorted lists. More...
#include <integer_set.hpp>
Public Types | |
using | ValueType = typename Members::ValueType |
using | ThisType = integer_set< Members > |
using | AsList = Members |
template<typename OtherSet > | |
using | unionWith = integer_set< decltype(unionHelper< typename OtherSet::AsList >(sp::make_int_sequence< Size+OtherSet::Size >{}))> |
Union this set with another. More... | |
template<typename OtherSet > | |
using | intersectionWith = integer_set< decltype(intersectHelper< Members, typename OtherSet::AsList >())> |
Intersect this set with another. More... | |
template<typename OtherSet > | |
using | subtract = integer_set< decltype(subtractHelper< Members, typename OtherSet::AsList >())> |
Subtract another set from this one. More... | |
template<ValueType I> | |
using | add = unionWith< integer_set< integer_sequence< ValueType, I > > > |
Add an element to the set. More... | |
template<ValueType I> | |
using | remove = subtract< integer_set< integer_sequence< ValueType, I > > > |
Remove an element from the set. More... | |
template<typename Lambda , typename OutType = ValueType> | |
using | map = integer_set< typename Members::template map< Lambda, OutType > > |
Functional map. More... | |
Static Public Member Functions | |
static constexpr bool | contains (ValueType I) |
O(log(n)), unlike integer_sequence::contains , which is linear. More... | |
constexpr static auto | get () |
Access an arbitrary element. More... | |
Static Public Attributes | |
constexpr static int | Size = Members::Size |
constexpr static bool | Empty = Size == 0 |
A set of integers, based on sorted lists.
These can be constructed from integer_sequence
in O(n²). Most operations here are no worse than nlog(n).
Members | A sorted integer_sequence of the members of the set. |
using sp::integer_set< Members >::add = unionWith<integer_set<integer_sequence<ValueType, I> >> |
Add an element to the set.
using sp::integer_set< Members >::intersectionWith = integer_set<decltype(intersectHelper<Members, typename OtherSet::AsList>())> |
Intersect this set with another.
using sp::integer_set< Members >::map = integer_set<typename Members::template map<Lambda, OutType> > |
Functional map.
using sp::integer_set< Members >::remove = subtract<integer_set<integer_sequence<ValueType, I> >> |
Remove an element from the set.
using sp::integer_set< Members >::subtract = integer_set<decltype(subtractHelper<Members, typename OtherSet::AsList>())> |
Subtract another set from this one.
using sp::integer_set< Members >::unionWith = integer_set<decltype(unionHelper<typename OtherSet::AsList>(sp::make_int_sequence<Size + OtherSet::Size>{}))> |
Union this set with another.
|
staticconstexpr |
O(log(n)), unlike integer_sequence::contains
, which is linear.
|
staticconstexpr |
Access an arbitrary element.