|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IL
A generalized list with several element-processing methods, mainly influenced by functional-oriented programming.
All the methods that return anIL
list always construct a new list
unless specifically stated.
Indices start from zero. An improper index is an index beyond the bounds
of this list (either negative or greater than size
-1).
Method Summary | |
---|---|
IL |
add(java.lang.Object o)
Adds the element to the list. |
IL |
addAll(java.util.Collection c)
Adds all the elements of the collection to this list. |
IL |
addAll(IL l)
Adds all the elements of the given list to this one. |
IL |
addAll(java.lang.Object[] array)
Adds all the elements of the array to this list. |
boolean |
all(IFilter filter)
Returns true iff all the elements can be accepted by the filter . |
boolean |
all(IFilter filter,
java.lang.Object hints)
Returns true iff all the elements can be accepted by the filter . |
boolean |
any(IFilter filter)
Returns true iff all the elements can be accepted by the filter . |
boolean |
any(IFilter filter,
java.lang.Object hints)
Returns true iff all the elements can be accepted by the filter . |
IL |
chopPrefix(java.lang.String prefix)
Chops the prefix from all elements, which are assumed to be strings. |
IL |
chopPrefixRE(java.lang.String prefix)
Chops the regular expression prefix from all elements, which are assumed to be strings. |
IL |
chopSuffix(java.lang.String suffix)
Chops the suffix from all elements, which are assumed to be strings. |
IL |
chopSuffixRE(java.lang.String suffix)
Chops the regula expression suffix from all elements, which are assumed to be strings. |
IL |
clear(java.lang.Object o)
Completely removes the element from the list. |
boolean |
contains(java.lang.Object o)
Returns true if this list contains the specified element. |
IL |
copy()
Returns a copy of this list. |
IL |
filter(IFilter filter)
Returns a new list with all the elements that are accepted by filter . |
IL |
filter(IFilter filter,
java.lang.Object hints)
Returns a new list with all the elements that are accepted by filter . |
IL |
filterEndsWith(java.lang.String s)
Filters all elements that end with s , assuming that elements are strings. |
IL |
filterEndsWithRE(java.lang.String re)
|
IL |
filterEndsWithRE(java.lang.String re,
int modifiers)
|
IL |
filterFindRE(java.lang.String re)
Uses Matcher.find() . |
IL |
filterFindRE(java.lang.String re,
int modifiers)
Uses Matcher.find() . |
void |
filterForEach(IFilterProcedure procedure)
Combines filtering and processing in one place. |
void |
filterForEach(IFilterProcedure procedure,
java.lang.Object hints)
Combines filtering and processing in one place. |
IL |
filterMap(IFilterFunction ff)
Combines filtering and mapping in one place. |
IL |
filterMap(IFilterFunction ff,
java.lang.Object hints)
Combines filtering and mapping in one place. |
IL |
filterMatchesRE(java.lang.String re)
Uses Matcher.matches() . |
IL |
filterMatchesRE(java.lang.String re,
int modifiers)
Uses Matcher.matches() . |
IL |
filterNotEndsWith(java.lang.String s)
Filters all elements that end with s , assuming that elements are strings. |
IL |
filterNotEndsWithRE(java.lang.String re)
|
IL |
filterNotEndsWithRE(java.lang.String re,
int modifiers)
|
IL |
filterNotFindRE(java.lang.String re)
Uses Matcher.find() . |
IL |
filterNotFindRE(java.lang.String re,
int modifiers)
Uses Matcher.find() . |
IL |
filterNotMatchesRE(java.lang.String re)
Uses Matcher.matches() . |
IL |
filterNotMatchesRE(java.lang.String re,
int modifiers)
Uses Matcher.matches() . |
IL |
filterNotStartsWith(java.lang.String s)
Filters all elements that do not start with s , assuming that elements are strings. |
IL |
filterNotStartsWithRE(java.lang.String re)
|
IL |
filterNotStartsWithRE(java.lang.String re,
int modifiers)
|
IL |
filterStartsWith(java.lang.String s)
Filters all elements that start with s , assuming that elements are strings. |
IL |
filterStartsWithRE(java.lang.String re)
|
IL |
filterStartsWithRE(java.lang.String re,
int modifiers)
|
void |
forEach(IProcedure procedure)
Processes all alements with procedure . |
void |
forEach(IProcedure procedure,
java.lang.Object hints)
Processes all alements with procedure . |
java.lang.Object |
get(int i)
Returns the i -th element of this list. |
java.lang.String |
getString(int i)
Convenience method that returns the i -th string of this list,
assuming that the list contains strings. |
java.lang.Object |
head()
Returns the first element of this list, retrieved from the iterator . |
java.lang.Object |
head(IFilter filter)
Returns the first element of this list that is accepted by filter . |
java.lang.Object |
head(IFilter filter,
java.lang.Object hints)
Returns the first element of this list that is accepted by filter . |
IL |
intersect(IL other)
Returns a new list containg the elements of this list that also belong to the other list. |
boolean |
isArray()
Returns true if this list wraps an Object array. |
boolean |
isCollection()
Returns true if this list wraps a Collection . |
boolean |
isList()
Returns true if this list wraps a Collection
and more specifically a List . |
boolean |
isSet()
Returns true if this list wraps a Collection
and more specifically a Set . |
java.util.Iterator |
iterator()
Returns an iterator over the elements in this list. |
java.util.Iterator |
iterator(IFilter filter)
Returns an iterator over the elements in this list that are accepted
by the given filter . |
java.util.Iterator |
iterator(IFilter filter,
java.lang.Object hints)
Returns an iterator over the elements in this list that are accepted
by the given filter . |
IL |
map(IFunction function)
Returns a new list containing all the elements of this list, mapped by function . |
IL |
map(IFunction function,
java.lang.Object hints)
Returns a new list containing all the elements of this list, mapped by function . |
IL |
minus(IL other)
Returns a new list containg the elements of this list that do not belong to the other list. |
void |
print()
Prints the elements to standard output. |
void |
print(java.io.PrintStream ps)
Prints the elements to the PrintStream . |
void |
print(java.io.PrintWriter pw)
Prints the elements to the PrintWriter . |
IL |
remove(java.lang.Object o)
Removes the element from the list (only once). |
IL |
selectProperty(java.lang.String name)
Returns a new list with the JavaBean properties of the given name
for each element. |
IL |
setFrom(CollectionProxy proxy)
Sets the elements of this list from those of the collection proxy . |
int |
size()
Returns the number of elements in this list. |
IL |
sort()
Sorts the elements of the list. |
IL |
sort(java.util.Comparator c)
Sorts the elements of the list, using the given Comparator . |
IL |
tail()
Returns the list constructed from this one if we remove the head() . |
IL |
take(int n)
Returns the first n elements of this list, n starting from one. |
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this collection. |
java.lang.Object[] |
toArray(java.lang.Class arrayClass)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified class. |
java.util.Collection |
toCollection()
Returns a Collection containing the elements of this array. |
java.util.List |
toList()
Returns a List containing the elements of this array. |
java.util.Set |
toSet()
Returns a Set containing the unique elements of this array. |
java.util.SortedSet |
toSortedSet()
Returns a SortedSet containing the unique elements of this array. |
java.lang.String[] |
toStringArray()
Convenience method that returns the strings of this list, assuming of course that this list contains strings. |
IL |
union(IL other)
Returns a new list containg the elements of this list along with the elements of other . |
IL |
unique()
Returns a set containing the unique elements of this list. |
IL |
zip(IL other)
Implements list zipping. |
Methods inherited from interface org.ckkloverdos.string.IToStringAware |
---|
toStringAware |
Method Detail |
---|
java.util.Iterator iterator()
java.util.Iterator iterator(IFilter filter)
accepted
by the given filter
.
filter
- java.util.Iterator iterator(IFilter filter, java.lang.Object hints)
accepted
by the given filter
.
The hints
parameter is passed directly to the filter
.
filter
- hints
- int size()
boolean contains(java.lang.Object o)
o
- boolean isArray()
true
if this list wraps an Object
array.
boolean isCollection()
true
if this list wraps a Collection
.
boolean isSet()
true
if this list wraps a Collection
and more specifically a Set
.
boolean isList()
true
if this list wraps a Collection
and more specifically a List
.
java.lang.Object[] toArray()
Object
array, this array
is returned.
java.lang.Object[] toArray(java.lang.Class arrayClass)
Object
array, this array
is returned and it MUST be of the given type.
java.lang.String[] toStringArray()
java.util.List toList()
List
containing the elements of this array.
If this list is already wrapping a List
, then it is returned
intact, otherwise a new one is created.
java.util.Set toSet()
Set
containing the unique elements of this array.
If this list is already wrapping a Set
, then it is returned
intact, otherwise a new one is created.
java.util.SortedSet toSortedSet()
SortedSet
containing the unique elements of this array.
If this list is already wrapping a SortedSet
, then it is returned
intact, otherwise a new one is created.
java.util.Collection toCollection()
Collection
containing the elements of this array.
If this list is already wrapping a Collection
, then it is returned
intact, otherwise a new one is created.
java.lang.Object get(int i)
i
-th element of this list.
i
- java.lang.String getString(int i)
i
-th string of this list,
assuming that the list contains strings.
i
- java.lang.Object head()
iterator
.
java.lang.IndexOutOfBoundsException
- of the list has no elements.java.lang.Object head(IFilter filter)
filter
.
Elements are retrieved from the iterator
.
java.lang.IndexOutOfBoundsException
- of the list has no elements or no element
is accepted by filter
.java.lang.Object head(IFilter filter, java.lang.Object hints)
filter
.
Elements are retrieved from the iterator
.
The second parameter hints
is directly passed to the filter
.
java.lang.IndexOutOfBoundsException
- of the list has no elements or no element
is accepted by filter
.IL tail()
head()
.
If this list has no elements, an empty one is returned.
IL take(int n)
n
elements of this list, n
starting from one.
If the list contains less than n
elements, all are returned.
If n
is less than one, an empty list is returned.
IL il = new L("zero", "one", "two", "three", "four"); StdLog.log("il = " + il.take(3));prints:
[0="zero", 1="one", 2="two"]
n
- IL filter(IFilter filter)
filter
.
filter
- IL filter(IFilter filter, java.lang.Object hints)
filter
.
The second parameter hints
is directly passed to the filter
.
IL map(IFunction function)
function
.
function
- IL map(IFunction function, java.lang.Object hints)
function
.
The second parameter hints
is directly passed to the function
.
IL filterMap(IFilterFunction ff)
ff
- IL filterMap(IFilterFunction ff, java.lang.Object hints)
hints
is directly passed to ff
.
If hints
is an implementation of BinaryHint
,
then BinaryHint.getHintA()
is passed to IFilter.accept(Object, Object)
and BinaryHint.getHintB()
is passed to IFunction.evaluate(Object, Object)
.
ff
- BinaryHint
IL selectProperty(java.lang.String name)
name
for each element.
If name
ends with ()
, then the name is treated as a method,
which is used to give the new elements.
IL il = new L("zero", "one", "two", "three", "four"); System.out.println(il.selectProperty("length()"));prints:
[0=4, 1=3, 2=3, 3=5, 4=4]
name
- void forEach(IProcedure procedure)
procedure
.
procedure
- void forEach(IProcedure procedure, java.lang.Object hints)
procedure
.
The second parameter hints
is directly passed to procedure
.
procedure
- hints
- void filterForEach(IFilterProcedure procedure)
void filterForEach(IFilterProcedure procedure, java.lang.Object hints)
hints
is directly passed to procedure
.
If hints
is an implementation of BinaryHint
,
then BinaryHint.getHintA()
is passed to IFilter.accept(Object,Object)
and BinaryHint.getHintB()
is passed to IProcedure.process(Object, Object)
.
BinaryHint
IL copy()
IL add(java.lang.Object o)
null
.
IL l = new L("zero", "one", "two", "three", "four"); System.out.println(l.add(new Integer(1000)));will print:
[0="zero", 1="one", 2="two", 3="three", 4="four", 5=1000]
IL l = new L(new String[]{"zero", "one", "two", "three", "four"}); System.out.println(l.add(new Integer(1000)));will throw an exception:
java.lang.IllegalArgumentException: array element type mismatch
.
IL l = new L(new Number[] {new Long(1), new Float(2.2)}); System.out.println(l.add(new Integer(1000)));will print:
[0=1, 1=2.2, 2=1000]
o
-
IL addAll(java.util.Collection c)
add(Object)
apply here as well.
c
- IL addAll(java.lang.Object[] array)
array
to this list.
The comments of add(Object)
apply here as well.
array
- IL addAll(IL l)
add(Object)
apply here as well.
l
- IL remove(java.lang.Object o)
o
- IL clear(java.lang.Object o)
o
- IL setFrom(CollectionProxy proxy)
proxy
.
This is lightweight and just updates the underlying backing store
reference with that of the proxy
.
proxy
- boolean all(IFilter filter)
true
iff all the elements can be accepted by the filter
.
In case the list is empty, false
is returned.
filter
- boolean all(IFilter filter, java.lang.Object hints)
true
iff all the elements can be accepted by the filter
.
In case the list is empty, false
is returned.
The second parameter hints
is directly passed to filter
.
filter
- hints
- boolean any(IFilter filter)
true
iff all the elements can be accepted by the filter
.
In case the list is empty, true
is returned.
filter
- boolean any(IFilter filter, java.lang.Object hints)
true
iff all the elements can be accepted by the filter
.
In case the list is empty, true
is returned.
The second parameter hints
is directly passed to filter
.
filter
- hints
- IL unique()
IL zip(IL other)
Pair
. The backing store of the returned
list is a List
.
other
- IL sort()
IL sort(java.util.Comparator c)
Comparator
.
IL union(IL other)
other
.
other
- IL intersect(IL other)
other
list.
other
- IL minus(IL other)
other
list.
other
- IL chopPrefix(java.lang.String prefix)
prefix
from all elements, which are assumed to be strings.
null
s pass through.
prefix
- IL chopPrefixRE(java.lang.String prefix)
prefix
from all elements, which are assumed to be strings.
null
s pass through.
prefix
- IL chopSuffix(java.lang.String suffix)
suffix
from all elements, which are assumed to be strings.
null
s pass through.
IL chopSuffixRE(java.lang.String suffix)
suffix
from all elements, which are assumed to be strings.
null
s pass through.
IL filterStartsWith(java.lang.String s)
s
, assuming that elements are strings.
null
s do not pass through.
s
- IL filterNotStartsWith(java.lang.String s)
s
, assuming that elements are strings.
null
s pass through.
s
- IL filterEndsWith(java.lang.String s)
s
, assuming that elements are strings.
null
s do not pass through.
s
- IL filterNotEndsWith(java.lang.String s)
s
, assuming that elements are strings.
null
s pass through.
s
- IL filterFindRE(java.lang.String re)
Matcher.find()
.
null
s do not pass through.
re
- IL filterNotFindRE(java.lang.String re)
Matcher.find()
.
null
s pass through.
re
- IL filterFindRE(java.lang.String re, int modifiers)
Matcher.find()
.
null
s do not pass through.
re
- IL filterNotFindRE(java.lang.String re, int modifiers)
Matcher.find()
.
null
s pass through.
re
- IL filterMatchesRE(java.lang.String re)
Matcher.matches()
.
null
s do not pass through.
re
- IL filterNotMatchesRE(java.lang.String re)
Matcher.matches()
.
null
s pass through.
re
- IL filterMatchesRE(java.lang.String re, int modifiers)
Matcher.matches()
.
null
s do not pass through.
re
- IL filterNotMatchesRE(java.lang.String re, int modifiers)
Matcher.matches()
.
null
s pass through.
re
- IL filterStartsWithRE(java.lang.String re)
IL filterNotStartsWithRE(java.lang.String re)
IL filterStartsWithRE(java.lang.String re, int modifiers)
IL filterNotStartsWithRE(java.lang.String re, int modifiers)
IL filterEndsWithRE(java.lang.String re)
IL filterNotEndsWithRE(java.lang.String re)
IL filterEndsWithRE(java.lang.String re, int modifiers)
IL filterNotEndsWithRE(java.lang.String re, int modifiers)
void print()
void print(java.io.PrintStream ps)
PrintStream
.
ps
- void print(java.io.PrintWriter pw)
PrintWriter
.
pw
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |