net.walend.lyophil.collection
Class MutableFreezerHashSet

java.lang.Object
  |
  +--net.walend.lyophil.collection.AbstractFreezerHashSet
        |
        +--net.walend.lyophil.collection.MutableFreezerHashSet
All Implemented Interfaces:
Collection, CollectionOfFreezables, HasState, MutableCollection, MutableCollectionOfFreezables, MutableSet, MutableSetOfFreezables, Set, SetOfFreezables

public class MutableFreezerHashSet
extends AbstractFreezerHashSet
implements MutableSetOfFreezables

Since:
20010727
Author:
David Walend

Nested Class Summary
 
Nested classes inherited from class net.walend.lyophil.collection.AbstractFreezerHashSet
 
Field Summary
 
Fields inherited from class net.walend.lyophil.collection.AbstractFreezerHashSet
serialVersionUID
 
Fields inherited from interface net.walend.lyophil.collection.SetOfFreezables
EMPTY
 
Constructor Summary
MutableFreezerHashSet()
          Constructs a new, empty set; the backing MutableHashMap instance has default capacity and load factor, which is 0.75, and uses the DefaultIdentitor.
MutableFreezerHashSet(Collection c)
          Constructs a new set containing the elements in the specified collection.
MutableFreezerHashSet(java.util.Collection c)
          Constructs a new set containing the elements in the specified java.util.Collection.
MutableFreezerHashSet(Identitor identitor)
          Constructs a new, empty set; the backing MutableHashMap instance has default capacity and load factor, which is 0.75.
MutableFreezerHashSet(Identitor identitor, int initialCapacity)
          Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and default load factor, which is 0.75.
MutableFreezerHashSet(Identitor identitor, int initialCapacity, float loadFactor)
          Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and the specified load factor.
MutableFreezerHashSet(int initialCapacity)
          Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and default load factor, which is 0.75.
MutableFreezerHashSet(int initialCapacity, float loadFactor)
          Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and the specified load factor.
 
Method Summary
 boolean add(java.lang.Object object)
          Adds a Object to the MutableCollection.
 boolean addAll(Collection c)
          Adds all the Objects in c to this MutableCollection by using the add() method.
 boolean addAllIdentifiedBy(Collection c)
          Adds all the Freezables identified by c to this MutableCollection using the addIdentifier method.
 boolean addIdentifiedBy(java.io.Serializable id)
          Adds a Freezable to the MutableCollection.
 void clear()
          Removes all of the Objects in this collection.
 boolean remove(java.lang.Object object)
          Removes a Object from the MutableCollection.
 boolean removeAll(Collection c)
          Removes all the Objects in c from this MutableCollection by using the remove() method.
 boolean removeAllIdentifiedBy(Collection c)
          Removes all the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method.
 boolean removeIdentifiedBy(java.io.Serializable id)
          Removes a Freezable from the MutableCollection, based on that Freezable's identifier.
 boolean retainAll(Collection c)
          Retains only the Objects in this collection that are contained in c by using the contains() and remove() methods.
 boolean retainAllIdentifiedBy(Collection c)
          Removes all but the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method.
 
Methods inherited from class net.walend.lyophil.collection.AbstractFreezerHashSet
contains, containsAll, containsAllIdentifiedBy, containsIdentifiedBy, freezableIterator, getFreezableForID, getFreezer, getIdentifiers, getIdentitor, getJavaCollection, getJavaSet, getPrincipleInterface, identifierIterator, isEmpty, iterator, sameContentsAs, sameStateAs, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.walend.lyophil.collection.CollectionOfFreezables
containsAllIdentifiedBy, containsIdentifiedBy, freezableIterator, getIdentifiers, identifierIterator
 
Methods inherited from interface net.walend.collection.Collection
contains, containsAll, getIdentitor, getJavaCollection, isEmpty, iterator, sameContentsAs, size
 
Methods inherited from interface net.walend.collection.HasState
getPrincipleInterface, sameStateAs
 
Methods inherited from interface net.walend.collection.Set
getJavaSet
 

Constructor Detail

MutableFreezerHashSet

public MutableFreezerHashSet()
Constructs a new, empty set; the backing MutableHashMap instance has default capacity and load factor, which is 0.75, and uses the DefaultIdentitor.


MutableFreezerHashSet

public MutableFreezerHashSet(Collection c)
Constructs a new set containing the elements in the specified collection. The capacity of the backing MutableHashMap instance is twice the size of the specified collection or eleven (whichever is greater), the default load factor (which is 0.75) is used. It uses the same Identitor as c.

Parameters:
c - the collection whose elements are to be placed into this set.

MutableFreezerHashSet

public MutableFreezerHashSet(java.util.Collection c)
Constructs a new set containing the elements in the specified java.util.Collection. The capacity of the backing MutableHashMap instance is twice the size of the specified collection or eleven (whichever is greater), and the default load factor (which is 0.75) is used. It uses the DefaultIdentitor.

Parameters:
c - the collection whose elements are to be placed into this set.

MutableFreezerHashSet

public MutableFreezerHashSet(int initialCapacity,
                             float loadFactor)
Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and the specified load factor. It uses the FreezableIdentitor.

Parameters:
initialCapacity - the initial capacity of the hash map.
loadFactor - the load factor of the hash map.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.

MutableFreezerHashSet

public MutableFreezerHashSet(int initialCapacity)
Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and default load factor, which is 0.75. It uses the FreezableIdentitor.

Parameters:
initialCapacity - the initial capacity of the hash table.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero.

MutableFreezerHashSet

public MutableFreezerHashSet(Identitor identitor)
Constructs a new, empty set; the backing MutableHashMap instance has default capacity and load factor, which is 0.75. It uses the specified identitor.


MutableFreezerHashSet

public MutableFreezerHashSet(Identitor identitor,
                             int initialCapacity,
                             float loadFactor)
Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and the specified load factor. It uses the specified identitor.

Parameters:
identitor -
initialCapacity - the initial capacity of the hash map.
loadFactor - the load factor of the hash map.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.

MutableFreezerHashSet

public MutableFreezerHashSet(Identitor identitor,
                             int initialCapacity)
Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and default load factor, which is 0.75. It uses the specified identitor.

Parameters:
identitor -
initialCapacity - the initial capacity of the hash table.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero.
Method Detail

add

public boolean add(java.lang.Object object)
Adds a Object to the MutableCollection. Sets will only add it to the Set if it's not already there.

Specified by:
add in interface MutableCollection
Overrides:
add in class AbstractFreezerHashSet
Returns:
true if the MutableCollection changes, false if not.

remove

public boolean remove(java.lang.Object object)
Removes a Object from the MutableCollection.

Specified by:
remove in interface MutableCollection
Overrides:
remove in class AbstractFreezerHashSet
Returns:
true if the MutableCollection changes, false if not.

addAll

public boolean addAll(Collection c)
Adds all the Objects in c to this MutableCollection by using the add() method. Returns true if this MutableCollection changes.

Specified by:
addAll in interface MutableCollection
Overrides:
addAll in class AbstractFreezerHashSet

removeAll

public boolean removeAll(Collection c)
Removes all the Objects in c from this MutableCollection by using the remove() method. Returns true if this Colleciton changes.

Specified by:
removeAll in interface MutableCollection
Overrides:
removeAll in class AbstractFreezerHashSet

retainAll

public boolean retainAll(Collection c)
Retains only the Objects in this collection that are contained in c by using the contains() and remove() methods. Returns true if this Colleciton changes.

Specified by:
retainAll in interface MutableCollection
Overrides:
retainAll in class AbstractFreezerHashSet

clear

public void clear()
Removes all of the Objects in this collection.

Specified by:
clear in interface MutableCollection
Overrides:
clear in class AbstractFreezerHashSet

addIdentifiedBy

public boolean addIdentifiedBy(java.io.Serializable id)
Adds a Freezable to the MutableCollection. Sets will only add it to the Set if it's not already there, based on the getIdentifier() and sameIdentifierAs() methods. Lists will tack it on the end of a list.

Specified by:
addIdentifiedBy in interface MutableCollectionOfFreezables
Overrides:
addIdentifiedBy in class AbstractFreezerHashSet
Returns:
true if the MutableCollection changes, false if not.
Throws:
java.lang.ClassCastException - class of the specified element prevents it from being added to this collection.
java.lang.IllegalArgumentException - some aspect of this element prevents it from being added to this collection.
ZombieIdentifierException - if f is not in the Freezer and this implementation checks on add.

removeIdentifiedBy

public boolean removeIdentifiedBy(java.io.Serializable id)
Removes a Freezable from the MutableCollection, based on that Freezable's identifier. This method uses the getIdentifier() and sameIdentifierAs() methods of the Freezables to find the right one.

Specified by:
removeIdentifiedBy in interface MutableCollectionOfFreezables
Overrides:
removeIdentifiedBy in class AbstractFreezerHashSet
Returns:
true if the MutableCollection changes, false if not.

addAllIdentifiedBy

public boolean addAllIdentifiedBy(Collection c)
Adds all the Freezables identified by c to this MutableCollection using the addIdentifier method. Returns true if this MutableCollection changes.

Specified by:
addAllIdentifiedBy in interface MutableCollectionOfFreezables
Overrides:
addAllIdentifiedBy in class AbstractFreezerHashSet
Throws:
java.lang.ClassCastException - if the class of an element of the specified collection prevents it from being added to this collection.
java.lang.IllegalArgumentException - some aspect of an element of the specified collection prevents it from being added to this collection.

removeAllIdentifiedBy

public boolean removeAllIdentifiedBy(Collection c)
Removes all the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method. Returns true if this MutableCollection changes.

Specified by:
removeAllIdentifiedBy in interface MutableCollectionOfFreezables
Overrides:
removeAllIdentifiedBy in class AbstractFreezerHashSet
Throws:
java.lang.ClassCastException - if the class of an element of the specified collection prevents it from being added to this collection.
java.lang.IllegalArgumentException - some aspect of an element of the specified collection prevents it from being added to this collection.

retainAllIdentifiedBy

public boolean retainAllIdentifiedBy(Collection c)
Removes all but the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method. Returns true if this MutableCollection changes.

Specified by:
retainAllIdentifiedBy in interface MutableCollectionOfFreezables
Overrides:
retainAllIdentifiedBy in class AbstractFreezerHashSet
Throws:
java.lang.ClassCastException - if the class of an element of the specified collection prevents it from being added to this collection.
java.lang.IllegalArgumentException - some aspect of an element of the specified collection prevents it from being added to this collection.


Copyright (c) 2000, 2001, David Walend