JUtil

net.cscott.jutil
Class BitSetFactory<V>

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

public class BitSetFactory<V>
extends SetFactory<V>

BitSetFactory is a SetFactory that, given a complete universe of possible values, produces low space overhead representations of Sets. Notably, the Sets produced should have union, intersection, and difference operations that, while still O(n), have blazingly low constant factors. The addition operations (Set.add(Object) and its cousins) are only defined for objects that are part of the universe of values given to the constructor; other Objects will cause IllegalArgumentException to be thrown.

Version:
$Id: BitSetFactory.java,v 1.6 2006-10-30 20:14:41 cananian Exp $
Author:
Felix S. Klock II

Constructor Summary
BitSetFactory(Collection<V> universe)
          Creates a BitSetFactory, given a universe of values.
BitSetFactory(Collection<V> universe, Indexer<V> indexer)
          Creates a BitSetFactory, given a universe of values and an Indexer for the elements of universe.
 
Method Summary
 Set<V> makeFullSet()
          Generates a new mutable Set, using the elements of the universe for this as its initial contents.
 net.cscott.jutil.BitSetFactory.BitStringSet<V> makeSet(Collection<? extends V> c)
          Generates a new mutable Set, using the elements of c as a template for its initial contents.
 
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

BitSetFactory

public BitSetFactory(Collection<V> universe,
                     Indexer<V> indexer)
Creates a BitSetFactory, given a universe of values and an Indexer for the elements of universe.


BitSetFactory

public BitSetFactory(Collection<V> universe)
Creates a BitSetFactory, given a universe of values. Makes a new Indexer for universe; the created Indexer will implement the Indexer.getByID() method to allow efficient iteration over sets.

Method Detail

makeSet

public net.cscott.jutil.BitSetFactory.BitStringSet<V> makeSet(Collection<? extends V> c)
Generates a new mutable Set, using the elements of c as a template for its initial contents.
requires: All of the elements of c must have been part of the universe for this.
effects: Constructs a lightweight Set with the elements from c.

Specified by:
makeSet in class SetFactory<V>

makeFullSet

public Set<V> makeFullSet()
Generates a new mutable Set, using the elements of the universe for this as its initial contents.


JUtil

Copyright (c) 2006 C. Scott Ananian