JUtil

net.cscott.jutil
Class PersistentSetFactory<T>

java.lang.Object
  extended by net.cscott.jutil.CollectionFactory<V>
      extended by net.cscott.jutil.SetFactory<T>
          extended by net.cscott.jutil.PersistentSetFactory<T>

public class PersistentSetFactory<T>
extends 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.

Version:
$Id: PersistentSetFactory.java,v 1.8 2006-10-30 19:58:06 cananian Exp $
Author:
C. Scott Ananian

Constructor Summary
PersistentSetFactory(Comparator<T> comparator)
          Creates a PersistentSetFactory.
 
Method Summary
 Set<T> makeSet(Collection<? extends T> c)
          Generates a new unsynchronized mutable Set which is based on persistent randomized treaps.
 
Methods inherited from class net.cscott.jutil.SetFactory
makeCollection, makeCollection, makeCollection, makeSet, makeSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistentSetFactory

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

Method Detail

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 class SetFactory<T>

JUtil

Copyright (c) 2006 C. Scott Ananian