Program Base Library

pblSet - Set Implementation

Set in C, C hash set, C-HashSet, hash set in C, HashSet in C,C tree set, C-TreeSet, tree set in C, TreeSet in C.

Documentation

Open source C implementation of a collection that contains no duplicate elements.
More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2).
This C implementation is
similar to the
Java Set
interface.

This implementations of sets do not allow NULL elements.

As implied by its name, this module models the mathematical set abstraction and
allows very efficient access to their elements.

The Set module provides two implementations of sets,
an open source C hash set implementation equivalent to the
Java HashSet class
and
a sorted open source C avl-tree-based balanced tree set implementation equivalent to the
Java TreeSet
class.

Hash sets make no guarantees as to the iteration order of the set;
in particular, they do not guarantee that the order will remain constant over time.
Hash sets offer constant time performance for the basic operations (add, remove, contains and size),
assuming the hash function disperses the elements properly among the buckets.
Iterating over hash sets requires time proportional to the sum of the hash set
instance's size (the number of elements) plus the "capacity" of the set (the number of buckets).
Thus, it's very important not to set the initial capacity too
high (or the load factor too low) if iteration performance is important.

Tree sets being sorted guarantee that the set can be iterated in ascending element order, according to the
compare function specified for the set.
The implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains).
Iterating over tree sets requires time proportional to the tree set
instance's size.

The user can also access elements by their integer index (position in the set).
From a performance standpoint, these methods should be used with caution.
They will perform costly linear searches.
Thus, iterating over the elements in a set is
preferable to indexing through it.

The Set module provides an iterator, called a
pblIterator,
that allows bidirectional access in addition to the normal operations iterators provide.

All set functions described below work on hash sets as well as on tree sets,
they of course will show different runtime and memory complexities depending on the type of
set used.