|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.walend.lyophil.collection.AbstractFreezerHashSet
This class implements the net.walend.collection.SetOfFreezables interface, but instead of storing whole Freezables in the set, it stores a Set of identifiers. When it needs the actual Freezables, it thaws them from the Freezer. This impelentation trades memory for time to access.
Nested Class Summary | |
private class |
AbstractFreezerHashSet.IteratesFreezables
|
Field Summary | |
private MutableSet |
ids
|
(package private) static long |
serialVersionUID
|
Fields inherited from interface net.walend.lyophil.collection.SetOfFreezables |
EMPTY |
Constructor Summary | |
protected |
AbstractFreezerHashSet()
Constructs a new, empty set; the backing MutableHashMap instance has default capacity and load factor, which is 0.75, and uses the DefaultIdentitor. |
protected |
AbstractFreezerHashSet(Collection c)
Constructs a new set containing the elements in the specified collection. |
protected |
AbstractFreezerHashSet(java.util.Collection c)
Constructs a new set containing the elements in the specified java.util.Collection. |
protected |
AbstractFreezerHashSet(Identitor identitor)
Constructs a new, empty set; the backing MutableHashMap instance has default capacity and load factor, which is 0.75. |
protected |
AbstractFreezerHashSet(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. |
protected |
AbstractFreezerHashSet(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. |
protected |
AbstractFreezerHashSet(int initialCapacity)
Constructs a new, empty set; the backing MutableHashMap instance has the specified initial capacity and default load factor, which is 0.75. |
protected |
AbstractFreezerHashSet(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 | |
protected boolean |
add(java.lang.Object o)
Adds the specified element to this set if it is not already present. |
protected boolean |
addAll(Collection c)
Adds all the Objects in c to this MutableCollection by using the add() method. |
protected boolean |
addAllIdentifiedBy(Collection c)
Adds all the Freezables identified by c to this MutableCollection using the addIdentifier method. |
protected boolean |
addIdentifiedBy(java.io.Serializable id)
Adds a Freezable to the MutableCollection. |
private void |
checkFreezable(java.lang.Object o)
|
protected void |
clear()
Removes all of the elements from this set. |
boolean |
contains(java.lang.Object o)
Returns true if this set contains the specified element. |
boolean |
containsAll(Collection c)
Returns true if this collection contains all of the Objects in the specified collection. |
boolean |
containsAllIdentifiedBy(Collection collectionOfFreezables)
Returns true if this collection contains the specified Freezables. |
boolean |
containsIdentifiedBy(java.io.Serializable id)
Returns true if this collection contains the specified Freezable. |
FreezableIterator |
freezableIterator()
Returns an iterator over the Freezables in this collection. |
protected Freezable |
getFreezableForID(java.io.Serializable id)
|
protected Freezer |
getFreezer()
|
Collection |
getIdentifiers()
Returns a Collection of all the identifiers in this collection. |
Identitor |
getIdentitor()
Returns the Identitor for this Collection. |
java.util.Collection |
getJavaCollection()
Return a java.util.Collection of these Objects. |
java.util.Set |
getJavaSet()
Return a java.util.Collection of these Objects. |
java.lang.Class |
getPrincipleInterface()
Returns the class's principle interface for state comparisons. |
java.util.Iterator |
identifierIterator()
Returns an iterator over the identifiers in this collection. |
boolean |
isEmpty()
Returns true if this set contains no elements. |
java.util.Iterator |
iterator()
Returns an iterator over the elements in this set. |
protected boolean |
remove(java.lang.Object o)
Removes the given element from this set if it is present. |
protected boolean |
removeAll(Collection c)
Removes all the Objects in c from this MutableCollection by using the remove() method. |
protected boolean |
removeAllIdentifiedBy(Collection c)
Removes all the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method. |
protected boolean |
removeIdentifiedBy(java.io.Serializable id)
Removes a Freezable from the MutableCollection, based on that Freezable's identifier. |
protected boolean |
retainAll(Collection c)
Retains only the Objects in this collection that are contained in c by using the contains() and remove() methods. |
protected boolean |
retainAllIdentifiedBy(Collection c)
Removes all but the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method. |
boolean |
sameContentsAs(Collection c)
Returns true if this Collection's contents are equal to c's. |
boolean |
sameStateAs(HasState victem)
If two HasStates have the same internal state, return true. |
int |
size()
Returns the number of elements in this set (its cardinality). |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private MutableSet ids
static final long serialVersionUID
Constructor Detail |
protected AbstractFreezerHashSet()
protected AbstractFreezerHashSet(Collection c)
c
- the collection whose elements are to be placed into this set.protected AbstractFreezerHashSet(java.util.Collection c)
c
- the collection whose elements are to be placed into this set.protected AbstractFreezerHashSet(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacity of the hash map.loadFactor
- the load factor of the hash map.java.lang.IllegalArgumentException
- if the initial capacity is less
than zero, or if the load factor is nonpositive.protected AbstractFreezerHashSet(int initialCapacity)
initialCapacity
- the initial capacity of the hash table.java.lang.IllegalArgumentException
- if the initial capacity is less
than zero.protected AbstractFreezerHashSet(Identitor identitor)
protected AbstractFreezerHashSet(Identitor identitor, int initialCapacity, float loadFactor)
identitor
- initialCapacity
- the initial capacity of the hash map.loadFactor
- the load factor of the hash map.java.lang.IllegalArgumentException
- if the initial capacity is less
than zero, or if the load factor is nonpositive.protected AbstractFreezerHashSet(Identitor identitor, int initialCapacity)
identitor
- initialCapacity
- the initial capacity of the hash table.java.lang.IllegalArgumentException
- if the initial capacity is less
than zero.Method Detail |
public Identitor getIdentitor()
getIdentitor
in interface Collection
public int size()
size
in interface Collection
public boolean isEmpty()
isEmpty
in interface Collection
private void checkFreezable(java.lang.Object o)
public boolean contains(java.lang.Object o)
contains
in interface Collection
o
- element whose presence in this set is to be tested.public java.util.Iterator iterator()
iterator
in interface Collection
public boolean containsAll(Collection c)
containsAll
in interface Collection
public boolean sameContentsAs(Collection c)
sameContentsAs
in interface Collection
public java.util.Collection getJavaCollection()
Collection
getJavaCollection
in interface Collection
public java.util.Set getJavaSet()
Set
getJavaSet
in interface Set
protected boolean add(java.lang.Object o)
o
- element to be added to this set.protected boolean remove(java.lang.Object o)
o
- object to be removed from this set, if present.protected boolean addAll(Collection c)
java.lang.UnsupportedOperationException
- if this collection does not support the addAll method.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.protected boolean removeAll(Collection c)
java.lang.UnsupportedOperationException
- if the removeAll method is not supported by this collection.protected boolean retainAll(Collection c)
java.lang.UnsupportedOperationException
- if the retainAll method is not supported by this collection.protected void clear()
public java.lang.Class getPrincipleInterface()
HasState
getPrincipleInterface
in interface HasState
public boolean sameStateAs(HasState victem)
HasState
For objects with subobjects, Generally this method should only return true if the internal objects are equal. Implement a contentsHaveSameState() method to determine if the contents have the same state.
sameStateAs
in interface HasState
public java.lang.String toString()
toString
in class java.lang.Object
protected Freezer getFreezer()
protected Freezable getFreezableForID(java.io.Serializable id)
public boolean containsIdentifiedBy(java.io.Serializable id)
containsIdentifiedBy
in interface CollectionOfFreezables
public boolean containsAllIdentifiedBy(Collection collectionOfFreezables)
containsAllIdentifiedBy
in interface CollectionOfFreezables
public FreezableIterator freezableIterator()
freezableIterator
in interface CollectionOfFreezables
public java.util.Iterator identifierIterator()
identifierIterator
in interface CollectionOfFreezables
public Collection getIdentifiers()
getIdentifiers
in interface CollectionOfFreezables
protected boolean addIdentifiedBy(java.io.Serializable id)
java.lang.UnsupportedOperationException
- add is not supported by this collection.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.protected boolean removeIdentifiedBy(java.io.Serializable id)
The AbstractHashSet implementation has to scan the freezables in the Set to find the right one.
java.lang.UnsupportedOperationException
- remove is not supported by this collection.protected boolean addAllIdentifiedBy(Collection c)
java.lang.UnsupportedOperationException
- if this collection does not support the addAll method.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.protected boolean removeAllIdentifiedBy(Collection c)
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.protected boolean retainAllIdentifiedBy(Collection c)
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.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |