Class BitSetFactory<V>

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

public class BitSetFactory<V> extends Object implements 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.
Author:
Felix S. Klock II <pnkfelix@mit.edu>
  • Constructor Details

    • 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 Details

    • 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 interface SetFactory<V>
    • makeFullSet

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