helib::IndexSet Class Reference
A dynamic set of non-negative integers. More...
#include <IndexSet.h>
Classes | |
class | iterator |
Public Member Functions | |
IndexSet () | |
IndexSet (long low, long high) | |
IndexSet (long j) | |
long | first () const |
Returns the first element, 0 if the set is empty. More... | |
long | last () const |
Returns the last element, -1 if the set is empty. More... | |
long | next (long j) const |
Returns the next element after j, if any; otherwise j+1. More... | |
long | prev (long j) const |
long | card () const |
The cardinality of the set. More... | |
bool | contains (long j) const |
Returns true iff the set contains j. More... | |
bool | contains (const IndexSet &s) const |
Returns true iff the set contains s. More... | |
bool | disjointFrom (const IndexSet &s) const |
Returns true iff the set is disjoint from s. More... | |
bool | operator== (const IndexSet &s) const |
bool | operator!= (const IndexSet &s) const |
void | clear () |
Set to the empty set. More... | |
void | insert (long j) |
Add j to the set. More... | |
void | remove (long j) |
Remove j from the set. More... | |
void | insert (const IndexSet &s) |
Add s to the set (union) More... | |
void | remove (const IndexSet &s) |
Remove s from the set (set minus) More... | |
void | retain (const IndexSet &s) |
Retains only those elements that are also in s (intersection) More... | |
bool | isInterval () const |
Is this set a contiguous interval? More... | |
void | read (std::istream &str) |
void | write (std::ostream &str) const |
iterator | begin () const |
iterator | end () const |
Static Public Member Functions | |
static const IndexSet & | emptySet () |
Read-only access to an empty set. More... | |
Detailed Description
A dynamic set of non-negative integers.
You can iterate through a set as follows:
for (long i = s.first(); i <= s.last(); i = s.next(i)) ...
for (long i = s.last(); i >= s.first(); i = s.prev(i)) ...
Constructor & Destructor Documentation
◆ IndexSet() [1/3]
|
inline |
◆ IndexSet() [2/3]
|
inline |
◆ IndexSet() [3/3]
|
inlineexplicit |
Member Function Documentation
◆ begin()
|
inline |
◆ card()
|
inline |
The cardinality of the set.
◆ clear()
void helib::IndexSet::clear | ( | ) |
Set to the empty set.
◆ contains() [1/2]
bool helib::IndexSet::contains | ( | const IndexSet & | s | ) | const |
Returns true iff the set contains s.
◆ contains() [2/2]
bool helib::IndexSet::contains | ( | long | j | ) | const |
Returns true iff the set contains j.
◆ disjointFrom()
bool helib::IndexSet::disjointFrom | ( | const IndexSet & | s | ) | const |
Returns true iff the set is disjoint from s.
◆ emptySet()
|
static |
Read-only access to an empty set.
◆ end()
|
inline |
◆ first()
|
inline |
Returns the first element, 0 if the set is empty.
◆ insert() [1/2]
void helib::IndexSet::insert | ( | const IndexSet & | s | ) |
Add s to the set (union)
◆ insert() [2/2]
void helib::IndexSet::insert | ( | long | j | ) |
Add j to the set.
◆ isInterval()
|
inline |
Is this set a contiguous interval?
◆ last()
|
inline |
Returns the last element, -1 if the set is empty.
◆ next()
long helib::IndexSet::next | ( | long | j | ) | const |
Returns the next element after j, if any; otherwise j+1.
◆ operator!=()
|
inline |
◆ operator==()
bool helib::IndexSet::operator== | ( | const IndexSet & | s | ) | const |
◆ prev()
long helib::IndexSet::prev | ( | long | j | ) | const |
◆ read()
void helib::IndexSet::read | ( | std::istream & | str | ) |
◆ remove() [1/2]
void helib::IndexSet::remove | ( | const IndexSet & | s | ) |
Remove s from the set (set minus)
◆ remove() [2/2]
void helib::IndexSet::remove | ( | long | j | ) |
Remove j from the set.
◆ retain()
void helib::IndexSet::retain | ( | const IndexSet & | s | ) |
Retains only those elements that are also in s (intersection)
◆ write()
void helib::IndexSet::write | ( | std::ostream & | str | ) | const |