IntSet Class ReferenceA set of small, positive integers.
More...
#include <IntSet.h>
List of all members.
Detailed Description
A set of small, positive integers.
Polaris Base - See also:
- IntSet.h
IntSet.h
IntSet.cc
A IntSet object represents a set of small, positive integers. There is no limitation on the size of the integers placed in the set, but will be inefficient in both time and space if large integers are stored within it.
An IntSet object represents a set of small, positive integers using a bit-vector implementation. Insertions and deletions take constant time while unions, intersections, and set comparisons take O(n) time, where n is the largest integer stored in the set. IntSets take up O(n) space. Because of these time and space bounds, IntSet objects are best used for relatively dense sets of integers with small magnitude. If one wishes to use sets containing large integers or large, sparse sets of integers, one should instead use the Set class (see Collection/Set.h and IntElem.h).
The first() and next() methods can be used to iterate over the elements of an IntSet. An example of this is:
for (int elem = int_set.first(); elem != -1; elem = int_set.next(elem)) { ... }
Iteration can also be done using the similar last() and prev() member functions.
IntSets will only take positive integers or zero.
The negation operation for IntSets is poorly implemented.
Definition at line 60 of file IntSet.h.
Constructor & Destructor Documentation
| IntSet::IntSet |
( |
unsigned int |
max_int = 31 |
) |
|
|
|
|
Create a new IntSet whose maximum integer value is the given value.
This integer value is not required, but may prevent unnecessary allocations and deletes as successively larger integers are placed in the set. |
| IntSet::IntSet |
( |
const IntSet & |
other |
) |
|
|
Member Function Documentation
| int IntSet::operator[] |
( |
unsigned |
int |
) |
const [inline] |
|
|
|
Return true if the given integer is in the set.
Definition at line 197 of file IntSet.h. |
| void IntSet::ins |
( |
unsigned |
int |
) |
[inline] |
|
| void IntSet::del |
( |
unsigned |
int |
) |
[inline] |
|
| int IntSet::operator== |
( |
const IntSet & |
|
) |
const |
|
|
|
Return True if two sets are equal.
Definition at line 78 of file IntSet.cc. |
| int IntSet::operator!= |
( |
const IntSet & |
|
) |
const [inline] |
|
|
|
Return True if one set contains an element not in the other set.
Definition at line 228 of file IntSet.h. |
| int IntSet::operator<= |
( |
const IntSet & |
|
) |
const |
|
|
|
Return True if I am a subset of the other set.
Definition at line 107 of file IntSet.cc. |
| int IntSet::operator>= |
( |
const IntSet & |
|
) |
const [inline] |
|
|
|
Return True if I am a superset of the other set.
Definition at line 234 of file IntSet.h. |
| int IntSet::operator< |
( |
const IntSet & |
|
) |
const [inline] |
|
|
|
Return True if I am a proper subset of the other set.
Definition at line 240 of file IntSet.h. |
| int IntSet::operator> |
( |
const IntSet & |
|
) |
const [inline] |
|
|
|
Return True if I am a proper superset of the other set.
Definition at line 246 of file IntSet.h. |
| int IntSet::intersects_with |
( |
const IntSet & |
|
) |
const |
|
|
|
Return True if my set has at least one element in common with the other set.
Definition at line 131 of file IntSet.cc.
References _max_size.
Referenced by main(). |
| const IntSet IntSet::operator+ |
( |
const IntSet & |
|
) |
const [inline] |
|
| const IntSet IntSet::operator| |
( |
const IntSet & |
|
) |
const [inline] |
|
|
|
Return the union of the two sets.
Definition at line 282 of file IntSet.h. |
| const IntSet IntSet::operator & |
( |
const IntSet & |
|
) |
const [inline] |
|
|
|
Return the intersection of the two sets.
Definition at line 296 of file IntSet.h. |
| const IntSet IntSet::operator~ |
( |
|
) |
const [inline] |
|
| IntSet IntSet::operator~ |
( |
|
) |
[inline] |
|
|
|
Return the negation of myself.
Definition at line 328 of file IntSet.h. |
| IntSet & IntSet::negate_in_place |
( |
|
) |
|
|
| const IntSet IntSet::operator- |
( |
const IntSet & |
other |
) |
const [inline] |
|
|
|
Return the subtraction of the other set from my set.
Definition at line 312 of file IntSet.h. |
| int IntSet::entries |
( |
|
) |
const |
|
| int IntSet::first |
( |
|
) |
const |
|
| int IntSet::last |
( |
|
) |
const |
|
|
|
Returns largest integer in set.
If there are no integers in the set, it returns -1.
Definition at line 259 of file IntSet.cc. |
| int IntSet::next |
( |
unsigned |
int |
) |
const |
|
| int IntSet::prev |
( |
unsigned |
int |
) |
const |
|
|
|
Returns the largest integer in the set that is smaller than the given integer.
If there are no smaller integers in the set, it returns -1.
Definition at line 315 of file IntSet.cc. |
| void IntSet::print |
( |
ostream & |
o |
) |
const |
|
| int IntSet::structures_OK |
( |
|
) |
const |
|
Friends And Related Function Documentation
| ostream& operator<< |
( |
ostream & |
o, |
|
|
const IntSet & |
set |
|
) |
[friend] |
|
|
|
Print out the set.
Definition at line 380 of file IntSet.cc. |
The documentation for this class was generated from the following files:
|