ROSE  0.11.96.11
Public Types | Public Member Functions | List of all members
Sawyer::Container::Set< T, C, A > Class Template Reference

Description

template<typename T, class C = std::less<T>, class A = std::allocator<T>>
class Sawyer::Container::Set< T, C, A >

Ordered set of values.

This container holds an ordered set of values. This container differs from std::set in the following ways:

Definition at line 52 of file Set.h.

#include <Set.h>

Inheritance diagram for Sawyer::Container::Set< T, C, A >:
Inheritance graph
[legend]

Public Types

typedef T Value
 Type of values stored in this set.
 
typedef C Comparator
 How to compare values with each other.
 
typedef A Allocator
 How to allocate storge for new values.
 
typedef InternalSet::const_iterator ConstIterator
 Iterator for traversing values stored in the set.
 

Public Member Functions

 Set (const Comparator &comparator=Comparator(), const Allocator &allocator=Allocator())
 Default constructor. More...
 
 Set (const Value &value)
 Singleton constructor. More...
 
 Set (const Set &other)
 Copy constructor.
 
Setoperator= (const Set &other)
 Assignment operator.
 
boost::iterator_range< ConstIteratorvalues () const
 Value iterator range. More...
 
bool isEmpty () const
 Whether the set is empty. More...
 
bool exists (const Value &value) const
 Whether a value exists. More...
 
bool existsAny (const Set &other) const
 Whether any value exists. More...
 
bool existsAll (const Set &other) const
 Whether all values exist. More...
 
size_t size () const
 Size of the set. More...
 
Value least () const
 Smallest member. More...
 
Value greatest () const
 Largest member. More...
 
Interval< Valuehull () const
 Range of members. More...
 
bool operator== (const Set &other) const
 Whether two sets contain the same members. More...
 
bool operator!= (const Set &other) const
 Whether two sets do not contain the same members. More...
 
bool insert (const Value &value)
 Insert a value. More...
 
bool insert (const Set &values)
 Insert multiple values. More...
 
bool erase (const Value &value)
 Erase a value. More...
 
bool erase (const Set &values)
 Erase multiple values. More...
 
void clear ()
 Erase all values. More...
 
Setoperator&= (const Set &other)
 Intersects this set with another. More...
 
Setoperator|= (const Set &other)
 Unions this set with another. More...
 
Setoperator-= (const Set &other)
 Differences two sets. More...
 
Set operator& (const Set &other) const
 Compute the intersection of this set with another. More...
 
Set operator| (const Set &other) const
 Compute the union of this set with another. More...
 
Set operator- (const Set &other) const
 Compute the difference of this set with another. More...
 
template<class InputIterator >
 Set (InputIterator begin, InputIterator end, const Comparator &comparator=Comparator(), const Allocator &allocator=Allocator())
 Iterative constructor. More...
 
template<class InputIterator >
 Set (const boost::iterator_range< InputIterator > &range, const Comparator &=Comparator(), const Allocator &=Allocator())
 Iterative constructor. More...
 

Constructor & Destructor Documentation

◆ Set() [1/4]

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Sawyer::Container::Set< T, C, A >::Set ( const Comparator comparator = Comparator(),
const Allocator allocator = Allocator() 
)
inlineexplicit

Default constructor.

Constructs a new set containing no values.

Definition at line 79 of file Set.h.

◆ Set() [2/4]

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Sawyer::Container::Set< T, C, A >::Set ( const Value value)
inline

Singleton constructor.

Constructs a singleton set having only the specified value.

Definition at line 85 of file Set.h.

◆ Set() [3/4]

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
template<class InputIterator >
Sawyer::Container::Set< T, C, A >::Set ( InputIterator  begin,
InputIterator  end,
const Comparator comparator = Comparator(),
const Allocator allocator = Allocator() 
)
inline

Iterative constructor.

Constructs a new set and copies values into the set. For instance, this can be used to initialize a set from a vector:

Map<Key, int> v = ...;
Set<int> set(v.values());

Definition at line 100 of file Set.h.

◆ Set() [4/4]

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
template<class InputIterator >
Sawyer::Container::Set< T, C, A >::Set ( const boost::iterator_range< InputIterator > &  range,
const Comparator = Comparator(),
const Allocator = Allocator() 
)
inlineexplicit

Iterative constructor.

Constructs a new set and copies values into the set. For instance, this can be used to initialize a set from a vector:

Map<Key, int> v = ...;
Set<int> set(v.values());

Definition at line 105 of file Set.h.

Member Function Documentation

◆ values()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
boost::iterator_range<ConstIterator> Sawyer::Container::Set< T, C, A >::values ( ) const
inline

Value iterator range.

Returns an iterator range that covers all values in the set.

Definition at line 127 of file Set.h.

Referenced by Sawyer::Container::Set< Key >::erase(), Sawyer::Container::Set< Key >::existsAll(), Sawyer::Container::Set< Key >::existsAny(), Sawyer::Container::Set< Key >::insert(), and Sawyer::Container::Set< Key >::operator|=().

Here is the caller graph for this function:

◆ isEmpty()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::isEmpty ( ) const
inline

Whether the set is empty.

Returns true if the set is empty, false if not empty.

Definition at line 138 of file Set.h.

Referenced by Sawyer::Container::Set< Key >::greatest(), Sawyer::Container::Set< Key >::hull(), and Sawyer::Container::Set< Key >::least().

Here is the caller graph for this function:

◆ exists()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::exists ( const Value value) const
inline

Whether a value exists.

Returns true if value is a member of the set, false if not a member.

Definition at line 145 of file Set.h.

Referenced by Sawyer::Container::Set< Key >::existsAll(), Sawyer::Container::Set< Key >::existsAny(), Sawyer::Container::Set< Key >::operator&=(), and Sawyer::Container::Set< Key >::operator-=().

Here is the caller graph for this function:

◆ existsAny()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::existsAny ( const Set< T, C, A > &  other) const
inline

Whether any value exists.

Returns true if any of the specified values exist in this set.

Definition at line 152 of file Set.h.

◆ existsAll()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::existsAll ( const Set< T, C, A > &  other) const
inline

Whether all values exist.

Returns true if all specified values exist in this set.

Definition at line 163 of file Set.h.

◆ size()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
size_t Sawyer::Container::Set< T, C, A >::size ( ) const
inline

Size of the set.

Returns the number of values that are members of this set.

Definition at line 174 of file Set.h.

◆ least()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Value Sawyer::Container::Set< T, C, A >::least ( ) const
inline

Smallest member.

Returns the smallest member of the set. The set must not be empty.

Definition at line 181 of file Set.h.

Referenced by Sawyer::Container::Set< Key >::hull().

Here is the caller graph for this function:

◆ greatest()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Value Sawyer::Container::Set< T, C, A >::greatest ( ) const
inline

Largest member.

Returns the largest member of the set. The set must not be empty.

Definition at line 189 of file Set.h.

Referenced by Sawyer::Container::Set< Key >::hull().

Here is the caller graph for this function:

◆ hull()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Interval<Value> Sawyer::Container::Set< T, C, A >::hull ( ) const
inline

Range of members.

Returns a range having the minimum and maximum members of the set.

Definition at line 199 of file Set.h.

◆ operator==()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::operator== ( const Set< T, C, A > &  other) const
inline

Whether two sets contain the same members.

Returns true if this set and other contain exactly the same members.

Definition at line 208 of file Set.h.

◆ operator!=()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::operator!= ( const Set< T, C, A > &  other) const
inline

Whether two sets do not contain the same members.

Returns true if this set and the other set are not equal, although this method is faster than using !(*this==other).

Definition at line 216 of file Set.h.

◆ insert() [1/2]

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::insert ( const Value value)
inline

Insert a value.

Inserts value into the set. Returns true if the value was inserted, false if the value was already a member.

Definition at line 228 of file Set.h.

Referenced by Sawyer::Container::Trace< T, IndexTag >::labels(), and Sawyer::Container::Set< Key >::operator|=().

Here is the caller graph for this function:

◆ insert() [2/2]

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::insert ( const Set< T, C, A > &  values)
inline

Insert multiple values.

Inserts all specified values into this set. Returns true if any value was inserted, false if all the values were already members of this set.

Definition at line 236 of file Set.h.

◆ erase() [1/2]

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::erase ( const Value value)
inline

Erase a value.

Erases value from the set. Returns true if the value was erased, false if the value was not a member.

Definition at line 248 of file Set.h.

◆ erase() [2/2]

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
bool Sawyer::Container::Set< T, C, A >::erase ( const Set< T, C, A > &  values)
inline

Erase multiple values.

Erases all specified values from this set. Returns true if any value was erased, false if none of the specified values were members of this set.

Definition at line 256 of file Set.h.

◆ clear()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
void Sawyer::Container::Set< T, C, A >::clear ( )
inline

Erase all values.

Erases all values from the set so that the set becomes empty.

Definition at line 268 of file Set.h.

◆ operator&=()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Set& Sawyer::Container::Set< T, C, A >::operator&= ( const Set< T, C, A > &  other)
inline

Intersects this set with another.

Removes those members of this set that are not in the other set.

Definition at line 275 of file Set.h.

◆ operator|=()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Set& Sawyer::Container::Set< T, C, A >::operator|= ( const Set< T, C, A > &  other)
inline

Unions this set with another.

Adds those members of other that are not already members of this set.

Definition at line 290 of file Set.h.

◆ operator-=()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Set& Sawyer::Container::Set< T, C, A >::operator-= ( const Set< T, C, A > &  other)
inline

Differences two sets.

Removes those members of this set that are in the other set. This is like the intersection of the complement but does not require computing a potentially large complement.

Definition at line 300 of file Set.h.

◆ operator&()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Set Sawyer::Container::Set< T, C, A >::operator& ( const Set< T, C, A > &  other) const
inline

Compute the intersection of this set with another.

Returns a new set which has only those members that are common to this set and the other set.

Definition at line 320 of file Set.h.

◆ operator|()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Set Sawyer::Container::Set< T, C, A >::operator| ( const Set< T, C, A > &  other) const
inline

Compute the union of this set with another.

Returns a new set containing the union of all members of this set and the other set.

Definition at line 329 of file Set.h.

◆ operator-()

template<typename T , class C = std::less<T>, class A = std::allocator<T>>
Set Sawyer::Container::Set< T, C, A >::operator- ( const Set< T, C, A > &  other) const
inline

Compute the difference of this set with another.

Returns a new set containing those elements of this set that are not members of the other set.

Definition at line 338 of file Set.h.


The documentation for this class was generated from the following file:
Sawyer::Container::BitVectorSupport::set
void set(Word *words, const BitRange &where)
Set some bits.
Definition: BitVectorSupport.h:417
Map
Extends std::map with methods that return optional values.
Definition: Map.h:10