jpaul.DataStructs
Class SetFactory<T>

java.lang.Object
  extended by jpaul.DataStructs.SetFactory<T>
All Implemented Interfaces:
java.io.Serializable, CollectionFactory<T>, Factory<java.util.Set<T>>
Direct Known Subclasses:
SetFacts.COWSetFactory, SetFacts.HashSetFactory, SetFacts.TreeSetFactory

public abstract class SetFactory<T>
extends java.lang.Object
implements Factory<java.util.Set<T>>, CollectionFactory<T>, java.io.Serializable

SetFactory is a set-instance of the factory pattern. Default implementations are provided for most of the methods. Subclasses must implement the create() method; for efficiency reasons, they may also override the newColl(Collection) method.

Various set factories are available in the class SetFacts.

Version:
$Id: SetFactory.java,v 1.10 2006/01/29 17:49:09 adam_kiezun Exp $
Author:
Alexandru Salcianu - salcianu@alum.mit.edu
See Also:
Serialized Form

Constructor Summary
SetFactory()
           
 
Method Summary
 java.util.Set<T> create(java.util.Set<T> s)
          Default implementation: invokes newColl(Collection).
 java.util.Collection<T> newColl()
          Default implementation: invokes Factory.create().
 java.util.Set<T> newColl(java.util.Collection<T> coll)
          Default implementation: uses create() to create an empty set, and next adds all elements from coll to the newly-created set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jpaul.DataStructs.Factory
create
 

Constructor Detail

SetFactory

public SetFactory()
Method Detail

create

public java.util.Set<T> create(java.util.Set<T> s)
Default implementation: invokes newColl(Collection).

Specified by:
create in interface Factory<java.util.Set<T>>
See Also:
Factory.create(Object)

newColl

public java.util.Collection<T> newColl()
Default implementation: invokes Factory.create(). Yes, it would have been more consistent to make all create methods invoke newColl methods (or the other way around). Still, technical typing aspects prevent us from doing so: create must return a set, so it cannot invoke a newColl (that returns only a collection); similarly, newColl(Collection) cannot invoke create(Set).

Specified by:
newColl in interface CollectionFactory<T>

newColl

public java.util.Set<T> newColl(java.util.Collection<T> coll)
Default implementation: uses create() to create an empty set, and next adds all elements from coll to the newly-created set.

Specified by:
newColl in interface CollectionFactory<T>
See Also:
Factory.create(Object)


Copyright 2005 Alexandru Salcianu - salcianu@alum.mit.edu