[ GAMB | Source | Keywords | Summary | Ancestors | All Members | Descendants ]
public: | |
UnionList(); | |
iterator | addUnion(const Key& key); |
iterator | addUnion(const Key& key, const Union& unionData); |
bool | unite(const Key& key1, const Key& key2); |
const_iterator | getUnion(const Key& key) const; |
iterator | getUnion(const Key& key); |
const_iterator | begin() const; |
iterator | begin(); |
const_iterator | end() const; |
iterator | end(); |
size_type | size() const; |
protected: |
Copyright: SAMBA group, Tel-Aviv Univ. Israel, 1997.
The union elements are called Keys since they are used to access the unions.
Since the union elements are stored in a hash table a hash function object
must be supplied as the 3rd template argument or defined as hash
The simplest UnionList:
The following example defines a int UnionList and uses it to create a single
union for all non-prime numbers (whose repressentative is the integer 4) and
a union for each prime number between 1 and 100:
typedef UnionList<int> IntUnion;
The following defines a UnionList of ints where each union is represented
by a float (instead of the default int>. If the union elements and the union
representative are not of the same type then the representative type must
have a constructor taking a single union element (Key) as its argument.
typedef UnionList<int, float>
The following defines a UnionList of floats. In this case hash
struct hash<float>
{
size_t operator()(const float f) const { return (size_t)f; }
};
typedef UnionList<float> FloatsUnion;
UnionList<int> intUnion;
for (int i=1; i<=10000; ++i) // Define unions. This step is not necessary
intUnion.addUnion(i);
for(int i=100; i>=2; --i) // unite all non-prime numbers.
for(int j=2; j*i<=10000; ++j)
intUnion.unite(j*i, i*2);
for (UnionList<int>::iterator it = intUnion.begin(); // print results
it != intUnion.end();
++it)
cout << (*it) << ' ';
cout << '\n' << '\n';
UnionList();
Constructor. Initialize an empty union list.
UnionList();
iterator addUnion(const Key& key);
Add a union containing a single data element.
iterator addUnion(const Key& key);
iterator addUnion(const Key& key, const Union& unionData);
Add a union containing a single data element.
iterator addUnion(const Key& key, const Union& unionData);
bool unite(const Key& key1, const Key& key2);
Unite the two unions which contain key1 and key2. If key1 or key2
are not found a new single union is created. If key1 or key2 are in the
same union no action is taken. The new representative of the new union
is always the one that was used to represent key2's union. key1's union
is deleted.
bool unite(const Key& key1, const Key& key2);
const_iterator getUnion(const Key& key) const;
Gets the representative data element of the union which contains key.
const_iterator getUnion(const Key& key) const;
iterator getUnion(const Key& key);
Gets the union which contains key. If key is not found returns end()
iterator getUnion(const Key& key);
const_iterator begin() const;
Returns an iterator used to iterate over the list of union
representatives.
const_iterator begin() const;
iterator begin();
Returns an iterator used to iterate over the list of union
representatives.
iterator begin();
const_iterator end() const;
Returns an iterator used to iterate over the list of union
representatives.
const_iterator end() const;
iterator end();
Returns an iterator used to iterate over the list of union
representatives.
iterator end();
size_type size() const;
Number of unions in the list.
size_type size() const;
All Members
public: iterator addUnion(const Key& key); iterator addUnion(const Key& key, const Union& unionData); bool unite(const Key& key1, const Key& key2); const_iterator getUnion(const Key& key) const; iterator getUnion(const Key& key); const_iterator begin() const; iterator begin(); const_iterator end() const; iterator end(); size_type size() const; protected: Ancestors
Class does not inherit from any other class.Descendants
Class is not inherited by any others.
Generated from source by the Cocoon utilities on Sun Nov 15 13:35:26 2009
.