|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.cm.frw.core.fun.impl.Bag
public class Bag
This is a collection wrapper useful for preparing argument lists for apply. It implements all collection method by delegating them to the wrapped collection. Additional methods are provided that return the Bag instance. This allows to chain calls in a single line, e.g.
Function sum = (Function) reduce.apply(new Bag().put(add).put(new Double(0.0)));
for expressing sum = reduce add 0
(see WhyFPExamples
)
Constructor Summary | |
---|---|
Bag()
|
|
Bag(java.util.Collection c)
|
|
Bag(java.lang.Object[] a)
|
Method Summary | |
---|---|
boolean |
add(java.lang.Object e)
|
boolean |
addAll(java.util.Collection c)
|
void |
clear()
|
boolean |
contains(java.lang.Object o)
|
boolean |
containsAll(java.util.Collection c)
|
static Bag |
drop(Bag bag,
Predicate pred)
Drop all elements of a given bag where given predicate holds |
Bag |
drop(java.lang.Object e)
|
Bag |
dropAll(java.util.Collection c)
|
static Bag |
from(int i)
|
static java.util.Collection |
fromArray(java.lang.Object[] a)
Create a bag putting in the given objects |
boolean |
isEmpty()
|
java.util.Iterator |
iterator()
|
static Bag |
keep(Bag bag,
Predicate pred)
Keep all elements of a given bag where given predicate holds |
static java.util.Collection |
newList()
|
static java.util.Collection |
newList(int[] a)
Create a bag of boxed integers from a given int array |
Bag |
put(boolean x)
|
Bag |
put(byte x)
|
Bag |
put(char x)
|
Bag |
put(double x)
|
Bag |
put(float x)
|
Bag |
put(int x)
|
Bag |
put(long x)
|
Bag |
put(java.lang.Object e)
|
Bag |
putAll(boolean[] x)
|
Bag |
putAll(byte[] x)
|
Bag |
putAll(char[] x)
|
Bag |
putAll(java.util.Collection c)
|
Bag |
putAll(double[] x)
|
Bag |
putAll(float[] x)
|
Bag |
putAll(int[] x)
|
Bag |
putAll(long[] x)
|
java.util.Collection |
putAll(java.lang.Object[] objects)
|
boolean |
remove(java.lang.Object e)
|
boolean |
removeAll(java.util.Collection c)
|
Bag |
removeIfNot(Predicate pred)
Destructively remove all items from the bag for which the given predicate does not hold |
boolean |
retainAll(java.util.Collection c)
|
int |
size()
|
Bag |
to(int end)
|
java.lang.Object[] |
toArray()
|
java.lang.Object[] |
toArray(java.lang.Object[] a)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Constructor Detail |
---|
public Bag()
public Bag(java.lang.Object[] a)
public Bag(java.util.Collection c)
Method Detail |
---|
public Bag put(java.lang.Object e)
public Bag put(boolean x)
public Bag putAll(boolean[] x)
public Bag put(byte x)
public Bag putAll(byte[] x)
public Bag put(char x)
public Bag putAll(char[] x)
public Bag put(double x)
public Bag putAll(double[] x)
public Bag put(float x)
public Bag putAll(float[] x)
public Bag put(int x)
public Bag putAll(int[] x)
public Bag put(long x)
public Bag putAll(long[] x)
public boolean add(java.lang.Object e)
add
in interface java.util.Collection
public Bag putAll(java.util.Collection c)
public boolean addAll(java.util.Collection c)
addAll
in interface java.util.Collection
public void clear()
clear
in interface java.util.Collection
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection
public boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection
public boolean isEmpty()
isEmpty
in interface java.util.Collection
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
public Bag drop(java.lang.Object e)
public boolean remove(java.lang.Object e)
remove
in interface java.util.Collection
public Bag dropAll(java.util.Collection c)
public boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
public int size()
size
in interface java.util.Collection
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection
public static java.util.Collection newList(int[] a)
a
- the array of integers to be boxed and bagged
public static java.util.Collection fromArray(java.lang.Object[] a)
a
- the array of objects to be bagged
public static java.util.Collection newList()
public static Bag from(int i)
public Bag to(int end)
public Bag removeIfNot(Predicate pred) throws Function.InvalidArguments
pred
- the predicate used to filter
Function.InvalidArguments
public static Bag keep(Bag bag, Predicate pred) throws Function.InvalidArguments
bag
- pred
-
bag
where pred
holds
Function.InvalidArguments
public static Bag drop(Bag bag, Predicate pred) throws Function.InvalidArguments
bag
- pred
-
bag
where pred
holds
Function.InvalidArguments
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Collection putAll(java.lang.Object[] objects)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |