aGrUM  0.13.2

A Set is a structure that contains arbitrary elements. More...

+ Collaboration diagram for Sets:

Detailed Description

A Set is a structure that contains arbitrary elements.

Note that, as in mathematics, an element cannot appear twice in a given set. Sets have unsafe and safe iterators. The safe iterators (SetIteratorSafe<> a.k.a. Set<>::iterator_safe are slightly slower than the unsafe ones (SetIterator<> a.k.a. Set<>::iterator) but they guarantee that even if they point to a deleted element, using their operators ++ or * cannot produce a segfault. In such cases, they simply raise an exception. On the contrary, unsafe iterators should never be used on elements that can be deleted because, as in the STL, they will most probably produce a segfault.

Usage example:
// creation of a set with 10 elements
Set<int> set;
for (int i = 0; i< 10; ++i)
set<<i;
Set<int> set2 { 1, 2, 3 };
// parse the set
for (auto iter = set.begin (); iter != set.end (); ++iter) {
// display the values
cerr << *iter << endl;
}
// use an iterator to point the element we wish to erase
Set<int>::iterator iter = set.begin ();
set.erase ( iter );
// check whether two iterators point toward the same element
Set<int>::iterator iter1 = set.begin();
Set<int>::iterator iter2 = set.end();
if (iter1 != iter2)
cerr << "iter1 and iter2 point toward different elements";

Classes

class  gum::Set< Key, Alloc >
 Representation of a setA Set is a structure that contains arbitrary elements. More...
 
class  gum::SetIteratorSafe< Key >
 Safe iterators for the Set classDevelopers may consider using Set<x>::iterator_safe instead of SetIteratorSafe<x>. More...
 
class  gum::SetIterator< Key >
 Unsafe iterators for the Set class. More...