|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjaggregate.AbstractCollection<E>
jaggregate.AbstractExtensibleCollection<E>
jaggregate.AbstractBag<E>
E - a restriction on the types of elements that may be contained in the bagpublic abstract class AbstractBag<E>
Represents an unordered, variable-sized collection whose elements can be added or removed, but cannot be individually accessed by external keys.
A bag is similar to a set but can contain duplicate elements. Elements are duplicates if they are equivalent.
| Method Summary | ||
|---|---|---|
void |
add(E newElement)
Adds a new element to this collection. |
|
void |
add(E newElement,
int occurrences)
Adds the given element to this bag a given number of times. |
|
|
collect(UnaryFunctor<? super E,? 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. |
|
boolean |
equals(Object that)
An object is considered equivalent to this bag if the object is assignable to this bag's class and has equivalent contents, as defined by this bag's notion of equivalence. |
|
void |
forEachDo(UnaryFunctor<? super E,?> operation)
For each element of this collection, evaluates the given operation with the element as the parameter. |
|
int |
hashCode()
|
|
boolean |
includes(E target)
Answers true if an element of this collection is equivalent to the
given one; answers false otherwise. |
|
int |
occurrencesOf(E target)
Answers the number of elements of this collection which are equivalent to the given target. |
|
void |
rehash()
Re-establishes any hash invariants of this collection. |
|
AbstractBag<E> |
reject(UnaryCondition<? super E> 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. |
|
boolean |
remove(E oldElement)
Removes the first element of this collection which is equivalent to the given element. |
|
AbstractBag<E> |
select(UnaryCondition<? super E> 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. |
|
int |
size()
Answers the number of elements in this collection. |
|
String |
toString()
|
|
| 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.Collection |
|---|
allSatisfy, anySatisfy, detect, inject, isEmpty, toArray, toArray, toBag, toIdentityBag, toIdentitySet, toOrderedCollection, toSet, toSortedCollection, toSortedCollection |
| Method Detail |
|---|
public <R> AbstractBag<R> collect(UnaryFunctor<? super E,? 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 Collection<E>collect in interface ExtensibleCollection<E>collect in class AbstractExtensibleCollection<E>R - return type of the transformertransformer - the transformer to evaluate
public void forEachDo(UnaryFunctor<? super E,?> operation)
operation - the operation to performpublic boolean includes(E target)
true if an element of this collection is equivalent to the
given one; answers false otherwise.
includes in interface Collection<E>includes in class AbstractCollection<E>target - the object to compare against
public int occurrencesOf(E target)
occurrencesOf in interface Collection<E>occurrencesOf in class AbstractCollection<E>target - the object to compare against
public void rehash()
rehash in interface Collection<E>rehash in class AbstractCollection<E>public AbstractBag<E> reject(UnaryCondition<? super E> 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 Collection<E>reject in interface ExtensibleCollection<E>reject in class AbstractExtensibleCollection<E>discriminator - the discriminator to evaluate
public AbstractBag<E> select(UnaryCondition<? super E> 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 Collection<E>select in interface ExtensibleCollection<E>select in class AbstractExtensibleCollection<E>discriminator - the discriminator to evaluate
public int size()
public void add(E 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.
newElement - the element to add
public void add(E newElement,
int occurrences)
newElement - the element to addoccurrences - number of times to add newElement
IllegalArgumentException - if occurrences is negativeadd(Object)public boolean remove(E oldElement)
forEachDo for this collection.
oldElement - the element to remove
true if any removal occurredpublic 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 | |||||||||