harpoon.Util.Collections
Class BitSetFactory

java.lang.Object
  |
  +--harpoon.Util.Collections.CollectionFactory
        |
        +--harpoon.Util.Collections.SetFactory
              |
              +--harpoon.Util.Collections.BitSetFactory

public class BitSetFactory
extends SetFactory

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.3 2002/02/26 22:47:33 cananian Exp $
Author:
Felix S. Klock II <pnkfelix@mit.edu>

Constructor Summary
BitSetFactory(Set universe)
          Creates a BitSetFactory, given a universe of values.
BitSetFactory(Set universe, Indexer indexer)
          Creates a BitSetFactory, given a universe of values and an Indexer for the elements of universe.
 
Method Summary
 Set makeFullSet()
          Generates a new mutable Set, using the elements of the universe for this as its initial contents.
 Set makeSet(Collection c)
          Generates a new mutable Set, using the elements of c as a template for its initial contents.
 
Methods inherited from class harpoon.Util.Collections.SetFactory
makeCollection, makeCollection, makeSet, makeSet
 
Methods inherited from class harpoon.Util.Collections.CollectionFactory
makeCollection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitSetFactory

public BitSetFactory(Set universe,
                     Indexer indexer)
Creates a BitSetFactory, given a universe of values and an Indexer for the elements of universe.


BitSetFactory

public BitSetFactory(Set 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 Set makeSet(Collection 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

makeFullSet

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