|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjaggregate.AbstractCollection<E>
jaggregate.AbstractExtensibleCollection<Pair<K,V>>
jaggregate.AbstractDictionaryImpl<K,V>
K - a restriction on the types of the keys that may be contained in the
dictionaryV - a restriction on the types of the values that may be contained in the
dictionarypublic abstract class AbstractDictionaryImpl<K,V>
Implementation of the dictionary concept that should be common for most concrete implementations.
| Method Summary | ||
|---|---|---|
void |
add(Pair<K,V> newElement)
Adds a new element to this collection. |
|
V |
at(K key)
Answers the element associated with the given key in this dictionary. |
|
|
collect(UnaryFunctor<? super Pair<K,V>,? extends R> transformer)
Evaluates the given transformer for each element of this collection, with the element as the parameter, and answers a new collection containing the results of these evaluations. The elements are traversed in the order specified by forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. |
|
|
collectValues(UnaryFunctor<? super V,? extends R> transformer)
Answers a new dictionary whose keys are this dictionary's keys, and whose corresponding elements are the results of evaluating the given transformer with each corresponding element of this dictionary. |
|
boolean |
equals(Object that)
An object is considered equivalent to this dictionary if the object is assignable to this dictionary's class and has equivalent contents, as defined by this dictionary's notion of equivalence. |
|
void |
forEachDo(UnaryFunctor<? super Pair<K,V>,?> operation)
For each element of this collection, evaluates the given operation with the element as the parameter. |
|
int |
hashCode()
|
|
boolean |
includes(Pair<K,V> target)
Answers true if an element of this collection is equivalent to the
given one; answers false otherwise. |
|
boolean |
includesKey(K key)
Answers true if this dictionary contains an element stored at the given
key, else answers false. |
|
K |
keyAt(V value)
Answers a key such that the element associated with this key is equivalent to the given value. |
|
AbstractSet<K> |
keys()
Answers a set of keys at which there is an element stored in this dictionary. |
|
void |
keysAndValuesDo(BinaryFunctor<? super K,? super V,?> operation)
Iteratively evaluates the given operation with each of this dictionary's keys and values. |
|
|
keysDo(UnaryFunctor<? super K,? extends R> operation)
Iteratively evaluates the given operation with each of this dictionary's keys at which there are elements stored. |
|
int |
occurrencesOf(Pair<K,V> target)
Answers the number of elements of this collection which are equivalent to the given target. |
|
void |
putAll(AbstractDictionary<? extends K,? extends V> newPairs)
Stores the elements of the given dictionary in this dictionary at the corresponding key from the given dictionary. |
|
V |
putAt(K key,
V newElement)
Stores a new element at a given key in this dictionary. |
|
void |
rehash()
Re-establishes any hash invariants of this collection. |
|
AbstractDictionary<K,V> |
reject(UnaryCondition<? super Pair<K,V>> discriminator)
Answers a new collection which contains only the elements in this collection which cause the given discriminator to answer false.
For each element of this collection, discriminator is evaluated with the
element as the parameter. Each element which causes discriminator to
answer false is included in the new collection.
The elements are traversed in the order specified by forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. If both this collection
and the result maintain an ordering of their elements, the elements of the
result will be in the same relative order as the elements of this collection. |
|
AbstractDictionary<K,V> |
rejectValues(UnaryCondition<? super V> discriminator)
Answers a new dictionary which excludes the elements in this dictionary that cause the given discriminator to answer true. |
|
boolean |
remove(Pair<K,V> oldElement)
Removes the first element of this collection which is equivalent to the given element. |
|
void |
removeAllKeys(Collection<? extends K> oldKeys)
Removes any elements from this dictionary which are stored at any of the given keys. |
|
void |
removeAllKeys(Iterable<? extends K> oldKeys)
|
|
void |
removeAllKeys(K[] oldKeys)
|
|
void |
removeAllKeys(K oldKey,
K... restOfOldKeys)
|
|
boolean |
removeIfKey(UnaryCondition<? super K> discriminator)
Removes each element of this dictionary whose key causes the given discriminator to answer true. |
|
boolean |
removeIfValue(UnaryCondition<? super V> discriminator)
Removes each element of this dictionary which causes the given discriminator to answer true. |
|
V |
removeKey(K key)
Removes the element stored at the given key in this dictionary. |
|
boolean |
retainAllKeys(Collection<? extends K> keepers)
Removes any elements from this dictionary which are not stored at any of the given keys. |
|
boolean |
retainAllKeys(Iterable<? extends K> keepers)
|
|
boolean |
retainAllKeys(K[] keepers)
|
|
boolean |
retainAllKeys(K keeper,
K... restOfKeepers)
|
|
boolean |
retainIfKey(UnaryCondition<? super K> discriminator)
Removes each element of this dictionary whose key causes the given discriminator to answer false. |
|
boolean |
retainIfValue(UnaryCondition<? super V> discriminator)
Removes each element of this dictionary which causes the given discriminator to answer false. |
|
AbstractDictionary<K,V> |
select(UnaryCondition<? super Pair<K,V>> discriminator)
Answers a new collection which contains only the elements in this collection which cause the given discriminator to answer true.
For each element of this collection, discriminator is evaluated with the
element as the parameter. Each element which causes discriminator to
answer true is included in the new collection.
The elements are traversed in order specified by forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. If both this collection
and the result maintain an ordering of their elements, the elements of the
result will be in the same relative order as the elements of this collection. |
|
AbstractDictionary<K,V> |
selectValues(UnaryCondition<? super V> discriminator)
Answers a new dictionary which contains the elements in this dictionary whose keys cause the given discriminator to answer true. |
|
int |
size()
Answers the number of elements in this collection. |
|
String |
toString()
|
|
AbstractBag<V> |
values()
Answers a collection of this dictionary's elements. |
|
| Methods inherited from class jaggregate.AbstractExtensibleCollection |
|---|
addAll, addAll, addAll, addAll, removeAll, removeAll, removeAll, removeAll, removeIf, retainAll, retainAll, retainAll, retainAll, retainIf |
| Methods inherited from class jaggregate.AbstractCollection |
|---|
allSatisfy, anySatisfy, detect, inject, isEmpty, toArray, toArray, toBag, toIdentityBag, toIdentitySet, toOrderedCollection, toSet, toSortedCollection, toSortedCollection |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface jaggregate.ExtensibleCollection |
|---|
addAll, addAll, addAll, addAll, removeAll, removeAll, removeAll, removeAll, removeIf, retainAll, retainAll, retainAll, retainAll, retainIf |
| Methods inherited from interface jaggregate.Collection |
|---|
allSatisfy, anySatisfy, detect, inject, isEmpty, toArray, toArray, toBag, toIdentityBag, toIdentitySet, toOrderedCollection, toSet, toSortedCollection, toSortedCollection |
| Method Detail |
|---|
public void add(Pair<K,V> newElement)
newElement in the element traversal order is unspecified.
Conformant protocols may place restrictions on the characteristics of objects
that are valid elements. Unless otherwise specified, any object that is of the
same class as or of a subclass of this collection's type parameter is acceptable.
add in interface ExtensibleCollection<Pair<K,V>>newElement - the element to addpublic <R> AbstractBag<R> collect(UnaryFunctor<? super Pair<K,V>,? extends R> transformer)
forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection.
collect in interface AbstractDictionary<K,V>collect in interface Collection<Pair<K,V>>collect in interface ExtensibleCollection<Pair<K,V>>collect in class AbstractExtensibleCollection<Pair<K,V>>R - return type of the transformertransformer - the transformer to evaluate
public void forEachDo(UnaryFunctor<? super Pair<K,V>,?> operation)
forEachDo in interface Collection<Pair<K,V>>operation - the operation to performpublic boolean includes(Pair<K,V> target)
true if an element of this collection is equivalent to the
given one; answers false otherwise.
includes in interface Collection<Pair<K,V>>includes in class AbstractCollection<Pair<K,V>>target - the object to compare against
public int occurrencesOf(Pair<K,V> target)
occurrencesOf in interface Collection<Pair<K,V>>occurrencesOf in class AbstractCollection<Pair<K,V>>target - the object to compare against
public void rehash()
rehash in interface Collection<Pair<K,V>>rehash in class AbstractCollection<Pair<K,V>>public AbstractDictionary<K,V> reject(UnaryCondition<? super Pair<K,V>> discriminator)
false.
For each element of this collection, discriminator is evaluated with the
element as the parameter. Each element which causes discriminator to
answer false is included in the new collection.
The elements are traversed in the order specified by forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. If both this collection
and the result maintain an ordering of their elements, the elements of the
result will be in the same relative order as the elements of this collection.
reject in interface AbstractDictionary<K,V>reject in interface Collection<Pair<K,V>>reject in interface ExtensibleCollection<Pair<K,V>>reject in class AbstractExtensibleCollection<Pair<K,V>>discriminator - the discriminator to evaluate
public AbstractDictionary<K,V> select(UnaryCondition<? super Pair<K,V>> discriminator)
true.
For each element of this collection, discriminator is evaluated with the
element as the parameter. Each element which causes discriminator to
answer true is included in the new collection.
The elements are traversed in order specified by forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. If both this collection
and the result maintain an ordering of their elements, the elements of the
result will be in the same relative order as the elements of this collection.
select in interface AbstractDictionary<K,V>select in interface Collection<Pair<K,V>>select in interface ExtensibleCollection<Pair<K,V>>select in class AbstractExtensibleCollection<Pair<K,V>>discriminator - the discriminator to evaluate
public int size()
size in interface Collection<Pair<K,V>>public void putAll(AbstractDictionary<? extends K,? extends V> newPairs)
putAt on this dictionary with each of the keys and elements from newPairs
in turn. If a key in newPairs is key-equivalent to a key in
this dictionary, the associated element in newPairs replaces the element
in this dictionary.
putAll in interface AbstractDictionary<K,V>newPairs - the pairs to addpublic V at(K key)
at in interface AbstractDictionary<K,V>key - the key to look up
null if there is no such elementpublic <R> AbstractDictionary<K,R> collectValues(UnaryFunctor<? super V,? extends R> transformer)
transformer with the
corresponding element of this dictionary as a parameter.
The elements are traversed in the order specified by forEachDo for this dictionary.
collectValues in interface AbstractDictionary<K,V>R - return type of the transformertransformer - the transformer to evaluate
transformer with the elements of this
dictionarypublic boolean includesKey(K key)
true if this dictionary contains an element stored at the given
key, else answers false.
includesKey in interface AbstractDictionary<K,V>key - the key to lookup
public K keyAt(V value)
keyAt in interface AbstractDictionary<K,V>value - the value to look up
null if there is no such keypublic AbstractSet<K> keys()
keys in interface AbstractDictionary<K,V>public void keysAndValuesDo(BinaryFunctor<? super K,? super V,?> operation)
operation is evaluated with the
corresponding key as the first argument and the element as the second argument.
The order in which the elements are visited is not specified. Each key is visited
exactly once.
keysAndValuesDo in interface AbstractDictionary<K,V>operation - the operation to performpublic <R> void keysDo(UnaryFunctor<? super K,? extends R> operation)
operation is evaluated with the
corresponding key as the argument.
The order in which the elements are visited is not specified. Each key is visited
exactly once.
keysDo in interface AbstractDictionary<K,V>R - a constraint on the return type of the operationoperation - the operation to perform
public V putAt(K key,
V newElement)
key, then newElement replaces the element
previously stored at key. Otherwise, newElement is stored at the
new key. In either case, subsequent successful lookups for key
will answer newElement.
putAt in interface AbstractDictionary<K,V>key - a keynewElement - the new element to associate with key
key, or null if
there is no such elementpublic AbstractDictionary<K,V> rejectValues(UnaryCondition<? super V> discriminator)
true.
For each of this dictionary's keys, discriminator is evaluated with the
corresponding element as the argument. If the element causes discriminator
to answer false, the key is added to the answer with the element as its
corresponding value.
rejectValues in interface AbstractDictionary<K,V>discriminator - the discriminator to evaluate
public boolean remove(Pair<K,V> oldElement)
forEachDo for this collection.
remove in interface ExtensibleCollection<Pair<K,V>>oldElement - the element to remove
true if any removal occurredpublic V removeKey(K key)
removeKey in interface AbstractDictionary<K,V>key - the key to remove
null if there is no such elementpublic void removeAllKeys(Collection<? extends K> oldKeys)
removeKey on this dictionary for each element in
oldKeys.
removeAllKeys in interface AbstractDictionary<K,V>oldKeys - the keys to removepublic void removeAllKeys(K[] oldKeys)
removeAllKeys in interface AbstractDictionary<K,V>oldKeys - the keys to removeAbstractDictionary.removeAllKeys(Collection)
public void removeAllKeys(K oldKey,
K... restOfOldKeys)
removeAllKeys in interface AbstractDictionary<K,V>oldKey - the first key to removerestOfOldKeys - the remainder of keys to removeAbstractDictionary.removeAllKeys(Collection)public void removeAllKeys(Iterable<? extends K> oldKeys)
removeAllKeys in interface AbstractDictionary<K,V>oldKeys - the keys to removeAbstractDictionary.removeAllKeys(Collection)public boolean removeIfKey(UnaryCondition<? super K> discriminator)
true.
removeIfKey in interface AbstractDictionary<K,V>discriminator - the discriminator to evaluate
true if any removal occurredpublic boolean removeIfValue(UnaryCondition<? super V> discriminator)
true.
removeIfValue in interface AbstractDictionary<K,V>discriminator - the discriminator to evaluate
true if any removal occurredpublic boolean retainAllKeys(Collection<? extends K> keepers)
retainAllKeys in interface AbstractDictionary<K,V>keepers - the keys to retain
true if any elements were removed from this dictionarypublic boolean retainAllKeys(K[] keepers)
retainAllKeys in interface AbstractDictionary<K,V>keepers - the keys to retain
true if any elements were removed from this dictionaryAbstractDictionary.retainAllKeys(Collection)
public boolean retainAllKeys(K keeper,
K... restOfKeepers)
retainAllKeys in interface AbstractDictionary<K,V>keeper - the first key to retainrestOfKeepers - the remainder of keys to retain
true if any elements were removed from this dictionaryAbstractDictionary.retainAllKeys(Collection)public boolean retainAllKeys(Iterable<? extends K> keepers)
retainAllKeys in interface AbstractDictionary<K,V>keepers - the keys to retain
true if any elements were removed from this dictionaryAbstractDictionary.retainAllKeys(Collection)public boolean retainIfKey(UnaryCondition<? super K> discriminator)
false.
retainIfKey in interface AbstractDictionary<K,V>discriminator - the discriminator to evaluate
true if any removal occurredpublic boolean retainIfValue(UnaryCondition<? super V> discriminator)
false.
retainIfValue in interface AbstractDictionary<K,V>discriminator - the discriminator to evaluate
true if any removal occurredpublic AbstractDictionary<K,V> selectValues(UnaryCondition<? super V> discriminator)
true.
For each of this dictionary's keys, discriminator is evaluated with the
corresponding element as the argument. If the element causes discriminator
to answer true, the key is added to the answer with the element as
its corresponding value.
selectValues in interface AbstractDictionary<K,V>discriminator - the discriminator to evaluate
public AbstractBag<V> values()
values in interface AbstractDictionary<K,V>public boolean equals(Object that)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||