|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jaggregate.AbstractCollection<E>
E
- a restriction on the types of elements that may be included in a collectionpublic abstract class AbstractCollection<E>
Implementation of the collection concept that should be common for most concrete implementations.
Method Summary | ||
---|---|---|
boolean |
allSatisfy(UnaryCondition<? super E> discriminator)
Answers true if the given discriminator answers true for every
element of this collection, or if this collection is empty; otherwise answers false . |
|
boolean |
anySatisfy(UnaryCondition<? super E> discriminator)
Answers true if the given discriminator answers true for any
element of this collection; answers false otherwise, or if this
collection is empty. |
|
|
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. |
|
E |
detect(UnaryCondition<? super E> discriminator)
Answers the first element of this collection for which the given discriminator answers true when given that element as an argument. |
|
boolean |
includes(E target)
Answers true if an element of this collection is equivalent to the
given one; answers false otherwise. |
|
|
inject(R initialValue,
BinaryFunctor<? super R,? super E,? extends R> operation)
Answers the final result of evaluating the given operation using each element of this collection and the previous evaluation result as the parameters. |
|
boolean |
isEmpty()
Answers true iff this collection's size is zero;
otherwise answers false . |
|
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. |
|
Collection<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 . |
|
Collection<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 . |
|
Object[] |
toArray()
Answers an array with the same elements as this collection, with the same size as this collection, and a component class of Object . |
|
Object[] |
toArray(Class<? super E> componentClass)
Answers an array with the same elements as this collection, with the same size as this collection, and a component type of the given class. |
|
Bag<E> |
toBag()
Answers a bag with the same elements as this collection. |
|
IdentityBag<E> |
toIdentityBag()
Answers an identity bag with the same elements as this collection. |
|
IdentitySet<E> |
toIdentitySet()
Answers an identity set with the same elements as this collection. |
|
OrderedCollection<E> |
toOrderedCollection()
Answers an ordered collection with the same elements as this collection. |
|
Set<E> |
toSet()
Answers a set with the same elements as this collection. |
|
SortedCollection<E> |
toSortedCollection()
Answers a sorted collection with the same elements as this collection. |
|
SortedCollection<E> |
toSortedCollection(Comparator<? super E> comparator)
Answers a sorted collection with the same elements as this collection, using the given comparator to order the elements. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface jaggregate.Collection |
---|
forEachDo, size |
Method Detail |
---|
public boolean allSatisfy(UnaryCondition<? super E> discriminator)
true
if the given discriminator answers true
for every
element of this collection, or if this collection is empty; otherwise answers false
.
It is unspecified whether discriminator
will be evaluated with every
element of this collection.
allSatisfy
in interface Collection<E>
discriminator
- the discriminator to evaluate
discriminator
is true
for every elementpublic boolean anySatisfy(UnaryCondition<? super E> discriminator)
true
if the given discriminator answers true
for any
element of this collection; answers false
otherwise, or if this
collection is empty.
It is unspecified whether discriminator
will be evaluated with every
element of this collection.
anySatisfy
in interface Collection<E>
discriminator
- the discriminator to evaluate
discriminator
is true
for any elementpublic Object[] toArray()
Object
. This means that objects of any class may be inserted into
the result.
If this collection maintains an ordering for its elements, the order of those
elements will be preserved in the result.
toArray
in interface Collection<E>
Collection.toArray(Class)
,
Collections.toArray(Collection,Class)
public Object[] toArray(Class<? super E> componentClass)
Object[]
. With Java
generics, it is not possible to express the return type as an array of the
component class without sacrificing the flexibility of providing a
componentClass
that is a supertype of the generic parameter's actual
argument. Therefore, the caller should downcast to the desired type, or risk
raising ArrayStoreException
when inserting via a reference of type
Object[]
.
If this collection maintains an ordering for its elements, the order of those
elements will be preserved in the result.
toArray
in interface Collection<E>
componentClass
- the desired type of the result array's components
Collections.toArray(Collection,Class)
public Bag<E> toBag()
toBag
in interface Collection<E>
public IdentityBag<E> toIdentityBag()
toIdentityBag
in interface Collection<E>
public IdentitySet<E> toIdentitySet()
toIdentitySet
in interface Collection<E>
public OrderedCollection<E> toOrderedCollection()
toOrderedCollection
in interface Collection<E>
public Set<E> toSet()
toSet
in interface Collection<E>
public SortedCollection<E> toSortedCollection()
toSortedCollection
in interface Collection<E>
public SortedCollection<E> toSortedCollection(Comparator<? super E> comparator)
toSortedCollection
in interface Collection<E>
comparator
- a comparator
public <R> Collection<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>
R
- return type of the transformertransformer
- the transformer to evaluate
public E detect(UnaryCondition<? super E> discriminator)
true
when given that element as an argument.
discriminator
will only be evaluated until such an object is found or
until all of the elements of the collection have been used as arguments.
That is, there may be elements of this collection that are never used as
arguments to discriminator
.
The elements are traversed in the order specified by forEachDo
for this collection.
detect
in interface Collection<E>
discriminator
- the discriminator to evaluate
discriminator
public 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>
target
- the object to compare against
public <R> R inject(R initialValue, BinaryFunctor<? super R,? super E,? extends R> operation)
operation
is performed with the given initial
value as the first parameter, and the first element of this collection as the
second parameter. Subsequent evaluations are done with the result of the
previous evaluation as the first parameter, and the next element as the second
parameter. The result of the last evaluation is answered.
If this collection is empty, answers the initial value.
The elements are traversed in the order specified by forEachDo
for this collection.
inject
in interface Collection<E>
R
- return type and type of first argument of the operationinitialValue
- first parameter for the first evaluationoperation
- the operation to evaluate
public boolean isEmpty()
true
iff this collection's size is zero;
otherwise answers false
.
isEmpty
in interface Collection<E>
public int occurrencesOf(E target)
occurrencesOf
in interface Collection<E>
target
- the object to compare against
public void rehash()
rehash
in interface Collection<E>
public Collection<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>
discriminator
- the discriminator to evaluate
public Collection<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>
discriminator
- the discriminator to evaluate
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |