Speclib  0.1.2
The library for writing better CUDA libraries
sp::integer_set< Members > Class Template Reference

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
 

Detailed Description

template<typename Members>
class sp::integer_set< Members >

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).

Template Parameters
MembersA sorted integer_sequence of the members of the set.

Member Typedef Documentation

◆ add

template<typename Members >
template<ValueType I>
using sp::integer_set< Members >::add = unionWith<integer_set<integer_sequence<ValueType, I> >>

Add an element to the set.

◆ intersectionWith

template<typename Members >
template<typename OtherSet >
using sp::integer_set< Members >::intersectionWith = integer_set<decltype(intersectHelper<Members, typename OtherSet::AsList>())>

Intersect this set with another.

◆ map

template<typename Members >
template<typename Lambda , typename OutType = ValueType>
using sp::integer_set< Members >::map = integer_set<typename Members::template map<Lambda, OutType> >

Functional map.

◆ remove

template<typename Members >
template<ValueType I>
using sp::integer_set< Members >::remove = subtract<integer_set<integer_sequence<ValueType, I> >>

Remove an element from the set.

◆ subtract

template<typename Members >
template<typename OtherSet >
using sp::integer_set< Members >::subtract = integer_set<decltype(subtractHelper<Members, typename OtherSet::AsList>())>

Subtract another set from this one.

◆ unionWith

template<typename Members >
template<typename OtherSet >
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.

Member Function Documentation

◆ contains()

template<typename Members >
static constexpr bool sp::integer_set< Members >::contains ( ValueType  I)
staticconstexpr

O(log(n)), unlike integer_sequence::contains, which is linear.

◆ get()

template<typename Members >
constexpr static auto sp::integer_set< Members >::get ( )
staticconstexpr

Access an arbitrary element.