An implementation of ordered sets using Prof. Arne Andersson's General Balanced Trees. This can be much more efficient than using ordered lists, for larger sets, but depends on the application.
The complexity on set operations is bounded by either O(|S|) or O(|T| * log(|S|)), where S is the largest given set, depending on which is fastest for any particular function call. For operating on sets of almost equal size, this implementation is about 3 times slower than using ordered-list sets directly. For sets of very different sizes, however, this solution can be arbitrarily much faster; in practical cases, often between 10 and 100 times. This implementation is particularly suited for accumulating elements a few at a time, building up a large set (more than 100-200 elements), and repeatedly testing for membership in the current set.
As with normal tree structures, lookup (membership testing), insertion and deletion have logarithmic complexity.
All of the following functions in this module also exist
and do the same thing in the
gb_set() = a GB set
Returns a new gb_set formed from
Rebalances the tree representation of
Returns a new gb_set formed from
Returns a new gb_set formed from
Returns only the elements of
Returns a new empty gb_set.
Filters elements in
Folds
Returns a gb_set of the elements in
Turns an ordered-set list
Returns a new gb_set formed from
Returns the intersection of
Returns the intersection of the non-empty list of gb_sets.
Returns
Returns
Returns
Returns
Returns
Returns an iterator that can be used for traversing the
entries of
Returns the largest element in
Returns
Returns a gb_set containing only the element
Returns the number of elements in
Returns the smallest element in
Returns
Returns
Returns the elements of
Returns the merged (union) gb_set of
Returns the merged (union) gb_set of the list of gb_sets.