Class PersistentSetFactory<T>

java.lang.Object
net.cscott.jutil.PersistentSetFactory<T>
All Implemented Interfaces:
CollectionFactory<T>, SetFactory<T>

public class PersistentSetFactory<T> extends Object implements SetFactory<T>
A PersistentSetFactory uses hash-consing to ensure that the Sets created by it maximally reuse space. Equality tests between Sets created by this factory are constant-time. Cloning a Set created by this factory is also constant-time. The implementation is based on persistent randomized treaps.
Since:
1.1
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
  • Constructor Details

    • PersistentSetFactory

      public PersistentSetFactory(Comparator<T> comparator)
      Creates a PersistentSetFactory. Note that the elements must implement a good hashcode as well as being comparable.
  • Method Details

    • makeSet

      public Set<T> makeSet(Collection<? extends T> c)
      Generates a new unsynchronized mutable Set which is based on persistent randomized treaps. All Sets created by this factory maximally reuse space, and have very fast equality-test and clone operations.
      Specified by:
      makeSet in interface SetFactory<T>