|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jaggregate.AbstractCollection<E> jaggregate.AbstractExtensibleCollection<E> jaggregate.AbstractBag<E> jaggregate.Bag<E>
E
- a restriction on the types of elements that may be included in the bagpublic class Bag<E>
A bag for which equivalence is defined by equals
.
Constructor Summary | |
---|---|
Bag()
Creates an empty bag. |
|
Bag(Collection<? extends E> elements)
Creates a bag containing the elements in the given collection. |
|
Bag(E... elements)
Creates a bag containing the elements in the given array. |
|
Bag(Iterable<? extends E> elements)
Creates a bag containing the elements given by an iterable object. |
Method Summary | ||
---|---|---|
static
|
bagFrom(Collection<? extends T> elements)
Creates a bag containing the elements in the given collection. |
|
static
|
bagFrom(Iterable<? extends T> elements)
Creates a bag containing the elements given by an iterable object. |
|
static
|
bagFrom(T[] elements)
Creates a bag containing the elements in the given array. |
|
static
|
bagWith(T newElement,
T... restOfNewElements)
Creates a bag containing the given elements. |
|
|
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. |
|
static
|
emptyBag()
Creates an empty bag. |
|
Bag<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. |
|
Bag<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. |
|
Bag<E> |
toBag()
Answers a bag with the same elements as this collection. Answers self. |
Methods inherited from class jaggregate.AbstractBag |
---|
add, add, equals, forEachDo, hashCode, includes, occurrencesOf, rehash, remove, size, 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, 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, toIdentityBag, toIdentitySet, toOrderedCollection, toSet, toSortedCollection, toSortedCollection |
Constructor Detail |
---|
public Bag()
public Bag(Collection<? extends E> elements)
elements
- elements to add to the new bag
NullPointerException
- if elements
is null
public Bag(E... elements)
elements
- elements to add to the new bag
NullPointerException
- if elements
is null
public Bag(Iterable<? extends E> elements)
elements
- elements to add to the new bag
NullPointerException
- if elements
is null
Method Detail |
---|
public static <T> Bag<T> emptyBag()
T
- the type of elements allowed in the new bag
public static <T> Bag<T> bagFrom(Collection<? extends T> elements)
T
- the type of elements allowed in the new bagelements
- elements to add to the new bag
NullPointerException
- if elements
is null
public static <T> Bag<T> bagFrom(T[] elements)
T
- the type of elements allowed in the new bagelements
- elements to add to the new bag
NullPointerException
- if elements
is null
public static <T> Bag<T> bagWith(T newElement, T... restOfNewElements)
T
- the type of elements allowed in the new bagnewElement
- first new element to addrestOfNewElements
- remainder of the elements to add
NullPointerException
- if restOfNewElements
is null
IllegalArgumentException
- if any of the new elements is found to violate
restrictions on the characteristics of valid elementsAbstractExtensibleCollection.addAll(Collection)
public static <T> Bag<T> bagFrom(Iterable<? extends T> elements)
T
- the type of elements allowed in the new bagelements
- elements to add to the new bag
NullPointerException
- if elements
is null
public Bag<E> toBag()
toBag
in interface Collection<E>
toBag
in class AbstractCollection<E>
public <R> Bag<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 AbstractBag<E>
R
- return type of the transformertransformer
- the transformer to evaluate
public Bag<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 AbstractBag<E>
discriminator
- the discriminator to evaluate
public Bag<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 AbstractBag<E>
discriminator
- the discriminator to evaluate
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |