ROSE 0.11.145.192
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 56 of file Set.h.

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

Member Typedef Documentation

◆ Value

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

Type of values stored in this set.

Definition at line 60 of file Set.h.

◆ Comparator

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

How to compare values with each other.

Definition at line 61 of file Set.h.

◆ Allocator

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

How to allocate storge for new values.

Definition at line 62 of file Set.h.

◆ ConstIterator

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

Iterator for traversing values stored in the set.

Definition at line 63 of file Set.h.

Constructor & Destructor Documentation

◆ Set() [1/5]

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 95 of file Set.h.

◆ Set() [2/5]

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 101 of file Set.h.

◆ Set() [3/5]

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());
Container associating values with keys.
Definition Sawyer/Map.h:72
boost::iterator_range< ValueIterator > values()
Iterators for container values.
Definition Sawyer/Map.h:414
Ordered set of values.
Definition Set.h:56

Definition at line 116 of file Set.h.

◆ Set() [4/5]

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 121 of file Set.h.

◆ Set() [5/5]

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

Copy constructor.

Definition at line 127 of file Set.h.

Member Function Documentation

◆ 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

Assignment operator.

Definition at line 131 of file Set.h.

◆ 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

◆ isEmpty()

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

◆ 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 161 of file Set.h.

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

◆ 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 168 of file Set.h.

References Sawyer::Container::Set< T, C, A >::exists(), and Sawyer::Container::Set< T, C, A >::values().

◆ 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 179 of file Set.h.

References Sawyer::Container::Set< T, C, A >::exists(), and Sawyer::Container::Set< T, C, A >::values().

◆ 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 190 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 197 of file Set.h.

References Sawyer::Container::Set< T, C, A >::isEmpty().

Referenced by Sawyer::Container::Set< T, C, A >::hull().

◆ 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 205 of file Set.h.

References Sawyer::Container::Set< T, C, A >::isEmpty().

Referenced by Sawyer::Container::Set< T, C, A >::hull().

◆ 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 215 of file Set.h.

References Sawyer::Container::Set< T, C, A >::greatest(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::Set< T, C, A >::isEmpty(), and Sawyer::Container::Set< T, C, A >::least().

◆ 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 224 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 232 of file Set.h.

◆ operator bool()

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

Whether the set is non-empty.

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

Definition at line 240 of file Set.h.

References Sawyer::Container::Set< T, C, A >::isEmpty().

◆ operator!()

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

Whether the set is empty.

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

Definition at line 247 of file Set.h.

References Sawyer::Container::Set< T, C, A >::isEmpty().

◆ 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() [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 266 of file Set.h.

References Sawyer::Container::Set< T, C, A >::values().

◆ 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() [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 286 of file Set.h.

References Sawyer::Container::Set< T, C, A >::values().

◆ 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 298 of file Set.h.

Referenced by Rose::BinaryAnalysis::InstructionSemantics::BaseSemantics::MemoryCell::eraseWriters(), and Rose::BinaryAnalysis::BestMapAddress::reset().

◆ 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 305 of file Set.h.

References Sawyer::Container::Set< T, C, A >::erase(), and Sawyer::Container::Set< T, C, A >::exists().

◆ 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 322 of file Set.h.

References Sawyer::Container::Set< T, C, A >::insert(), and Sawyer::Container::Set< T, C, A >::values().

◆ 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 328 of file Set.h.

References Sawyer::Container::Set< T, C, A >::insert(), and Sawyer::Container::Set< T, C, A >::values().

◆ 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 339 of file Set.h.

References Sawyer::Container::Set< T, C, A >::erase(), and Sawyer::Container::Set< T, C, A >::exists().

◆ 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 359 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 370 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 376 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 384 of file Set.h.


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