T - the element type of the Listpublic static interface C.List<T> extends List<T>, C.ReversibleSequence<T>
List and osgl C.Sequence| Modifier and Type | Interface and Description |
|---|---|
static interface |
C.List.Cursor<T>
A cursor points to an element of a
List. |
C.Featured.Factory| Modifier and Type | Method and Description |
|---|---|
C.List<T> |
accept(Osgl.Func2<Integer,? super T,?> indexedVisitor)
Loop through the list and for each element, call on the
indexedVisitor function specified
|
C.List<T> |
accept(Osgl.Function<? super T,?> visitor)
Iterate this
Traversable with a visitor function. |
C.List<T> |
acceptLeft(Osgl.Func2<Integer,? super T,?> indexedVisitor)
Loop through the list from
0 to size - 1. |
C.List<T> |
acceptLeft(Osgl.Function<? super T,?> visitor)
Iterate through this sequence from head to tail with
the visitor function specified
|
C.List<T> |
acceptRight(Osgl.Func2<Integer,? super T,?> indexedVisitor)
Loop through the list from
size() - 1 to 0. |
C.List<T> |
acceptRight(Osgl.Function<? super T,?> visitor)
Iterate through this sequence from tail to head with the visitor function
specified
|
boolean |
addAll(Iterable<? extends T> iterable)
Add all elements from an
Iterable into this list. |
C.List<T> |
append(C.List<T> list)
Returns a List contains all elements in this List followed by
all elements in the specified List.
|
C.List<T> |
append(Collection<? extends T> iterable) |
C.List<T> |
append(T t)
Returns a sequence consists of all elements of this sequence
followed by the element specified.
|
C.List<T> |
copy()
Returns a mutable copy of this list
|
C.List<T> |
drop(int n)
Returns a
Sequence consisting of the elements from this Sequence except the first n
if number n is positive and the Sequence contains more than n elements |
C.List<T> |
dropWhile(Osgl.Function<? super T,Boolean> predicate)
Returns a
Sequence consisting of the elements from this sequence with leading elements
dropped until the predicate returns true |
C.List<T> |
each(Osgl.Func2<Integer,? super T,?> indexedVisitor)
Alias of
accept(Osgl.Func2) |
C.List<T> |
each(Osgl.Function<? super T,?> visitor)
Alias of
C.Traversable.accept(Osgl.Function) |
C.List<T> |
eager()
Returns this traversable and make sure
C.Feature.LAZY is unset |
C.List<T> |
filter(Osgl.Function<? super T,Boolean> predicate)
Returns an new traversable that contains all elements in the current traversable
except that does not pass the test of the filter function specified.
|
<R> C.List<R> |
flatMap(Osgl.Function<? super T,? extends Iterable<? extends R>> mapper)
Returns a traversable consisting of the results of replacing each element of this
stream with the contents of the iterable produced by applying the provided mapping
function to each element.
|
C.List<T> |
forEach(Osgl.Func2<Integer,? super T,?> indexedVisitor)
Alias of
accept(Osgl.Func2) |
C.List<T> |
forEach(Osgl.Function<? super T,?> visitor)
Alias of
C.Traversable.accept(Osgl.Function) |
C.List<T> |
head(int n)
Alias of
C.Sequence.take(int) |
C.List<T> |
insert(int index,
List<T> subList)
Insert a sub list at the position specified by
index. |
C.List<T> |
insert(int index,
T... ta)
Insert an array of elements at the position specified by
index. |
C.List<T> |
insert(int index,
T t)
Insert an element at the position specified by
index. |
C.List<T> |
lazy()
Returns this traversable and make sure
C.Feature.LAZY is set |
C.List.Cursor<T> |
locate(Osgl.Function<T,Boolean> predicate)
Locate any one element in the list that matches the predicate.
|
C.List.Cursor<T> |
locateFirst(Osgl.Function<T,Boolean> predicate)
Find the first element in this list that matches the predicate.
|
C.List.Cursor<T> |
locateLast(Osgl.Function<T,Boolean> predicate)
Locate the first element in this list that matches the predicate.
|
<R> C.List<R> |
map(Osgl.Function<? super T,? extends R> mapper)
Returns an new traversable with a mapper function specified.
|
C.List<T> |
parallel()
Returns this traversable and make sure
C.Feature.PARALLEL is set |
C.List<T> |
prepend(C.List<T> list) |
C.List<T> |
prepend(Collection<? extends T> collection) |
C.List<T> |
prepend(T t)
Returns a sequence consists of the element specified followed by
all elements of this sequence.
|
C.List<T> |
readOnly()
Returns a view of this list that is readonly.
|
C.List<T> |
remove(Osgl.Function<? super T,Boolean> predicate)
For mutable list, remove all element that matches the predicate
specified from this List and return this list once done.
|
C.List<T> |
reverse()
Returns an new
Sequence that reverse this Sequence. |
C.List<T> |
sequential()
Returns this traversable and make sure
C.Feature.PARALLEL is unset |
C.List<T> |
snapshot()
Returns an immutable list contains all elements of the current list.
|
C.List<T> |
sorted()
Returns a sorted copy of this list.
|
C.List<T> |
sorted(Comparator<? super T> comparator)
Returns a sorted copy of this list.
|
Osgl.T2<C.List<T>,C.List<T>> |
split(Osgl.Function<? super T,Boolean> predicate)
Split this list into two list based on the predicate specified.
|
C.List<T> |
subList(int fromIndex,
int toIndex) |
C.List<T> |
tail()
Returns the rest part of the
Sequence except the first element |
C.List<T> |
tail(int n)
Returns a
Sequence consisting the last n elements from this Sequence
if number n is positive and the Sequence contains more than n elements |
C.List<T> |
take(int n)
Returns a
Sequence consisting the first n elements from this Sequence if
number n is positive and the Sequence contains more than n elements |
C.List<T> |
takeWhile(Osgl.Function<? super T,Boolean> predicate)
Returns an new
Sequence that takes the head of this Sequence until the predicate
evaluate to false: |
C.List<T> |
unique()
Return a list that contains unique set of this list and keep the orders.
|
C.List<T> |
unique(Comparator<T> comp)
Return a list that contains unique set as per the comparator specified of
this list and keep the orders.
|
C.List<T> |
without(Collection<? super T> col)
Returns a List contains all elements in this List and not in
the
col collection specified |
C.List<T> |
without(T element)
Returns a list contains all elements in the list except the
one specified
|
C.List<T> |
without(T element,
T... elements)
Returns a list contains all elements in the list except the
ones specified
|
<T2> C.List<Osgl.T2<T,T2>> |
zip(List<T2> list)
Returns a list formed from this list and another iterable
collection by combining corresponding elements in pairs.
|
<T2> C.List<Osgl.T2<T,T2>> |
zipAll(List<T2> list,
T def1,
T2 def2)
Returns a list formed from this list and another iterable
collection by combining corresponding elements in pairs.
|
C.Sequence<Osgl.T2<T,Integer>> |
zipWithIndex()
Zip this sequence with its indices
|
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, toArray, toArrayparallelStream, removeIf, streamappend, findLast, last, prepend, reduceRight, reduceRight, reverseIterator, zip, zipAllappend, append, append, append, count, findFirst, first, head, prepend, prepend, prepend, prepend, reduce, reduce, reduceLeft, reduceLeft, zip, zipAllallMatch, anyMatch, findOne, isEmpty, noneMatch, sizefeatures, isC.List<T> parallel()
C.Feature.PARALLEL is setparallel in interface C.ReversibleSequence<T>parallel in interface C.Sequence<T>parallel in interface C.Traversable<T>C.List<T> sequential()
C.Feature.PARALLEL is unsetsequential in interface C.ReversibleSequence<T>sequential in interface C.Sequence<T>sequential in interface C.Traversable<T>C.List<T> lazy()
C.Feature.LAZY is setlazy in interface C.ReversibleSequence<T>lazy in interface C.Sequence<T>lazy in interface C.Traversable<T>C.List<T> eager()
C.Feature.LAZY is unseteager in interface C.ReversibleSequence<T>eager in interface C.Sequence<T>eager in interface C.Traversable<T>C.List<T> snapshot()
readOnly()C.List<T> readOnly()
C.List<T> copy()
C.List<T> sorted()
Note if the element type T is not a Comparable then
this method returns a copy of this list without any order
changes
C.List<T> unique()
C.List<T> unique(Comparator<T> comp)
comp - the comparator check the duplicate elementsC.List<T> sorted(Comparator<? super T> comparator)
comparator - specify the order of elements in the result listboolean addAll(Iterable<? extends T> iterable)
Iterable into this list.
Return true if the list has changed as a result of
call.
Note if this list is immutable or readonly, UnsupportedOperationException
will be thrown out with this call
iterable - the iterable provides the elements to be
added into the listtrue if this list changed as result of adddC.List<T> head(int n)
C.Sequence.take(int)head in interface C.ReversibleSequence<T>head in interface C.Sequence<T>n - specify the number of elements to be included in the return listn items in this ListC.List<T> take(int n)
Sequence consisting the first n elements from this Sequence if
number n is positive and the Sequence contains more than n elements
If this Sequence contains less than n elements, then a Sequence consisting
the whole elements of this Sequence is returned. Note it might return this Sequence
itself if the Sequence is immutable.
If the number n is zero, then an empty Sequence is returned in reverse
order
If the number n is negative, then the last -n elements from this
Sequence is returned in an new Sequence, or throw UnsupportedOperationException
if this operation is not supported
Sequence seq = C.list(1, 2, 3, 4);
assertEquals(C.list(1, 2), seq.take(2));
assertEquals(C.list(1, 2, 3, 4), seq.take(100));
assertEquals(C.list(), seq.take(0));
assertEquals(C.list(3, 4), seq.take(-2));
assertEquals(C.list(1, 2, 3, 4), seq.take(-200));
This method does not alter the underline list
take in interface C.ReversibleSequence<T>take in interface C.Sequence<T>n - specify the number of elements to be taken from the head of this Sequencen items in this listC.Sequence.head(int)C.List<T> tail()
Sequence except the first elementtail in interface C.ReversibleSequence<T>tail in interface C.Sequence<T>C.Sequence.head(),
C.ReversibleSequence.tail(int)C.List<T> tail(int n)
Sequence consisting the last n elements from this Sequence
if number n is positive and the Sequence contains more than n elements
If this Sequence contains less than n elements, then a Sequence consisting
the whole elements of this Sequence is returned. Note it might return this Sequence
itself if the Sequence is immutable.
If the number n is zero, then an empty Sequence is returned in reverse
order
If the number n is negative, then the first -n elements from this
Sequence is returned in an new Sequence
Sequence seq = C1.list(1, 2, 3, 4);
assertEquals(C1.list(3, 4), seq.tail(2));
assertEquals(C1.list(1, 2, 3, 4), seq.tail(100));
assertEquals(C1.list(), seq.tail(0));
assertEquals(C1.list(1, 2, 3), seq.tail(-3));
assertEquals(C1.list(1, 2, 3, 4), seq.tail(-200));
This method does not mutate the underline container
This method does not alter the underline list
tail in interface C.ReversibleSequence<T>n - specify the number of elements to be taken from the tail of this Sequencen items in this listC.Feature.LIMITED,
C.Featured.is(org.osgl.util.C.Feature)C.List<T> drop(int n)
Sequence consisting of the elements from this Sequence except the first n
if number n is positive and the Sequence contains more than n elements
If this Sequence contains less than n elements, then an empty Sequence
is returned
If the number n is zero, then a copy of this Sequence or this Sequence
itself is returned depending on the implementation
If the number n is negative, then either IllegalArgumentException should
be thrown out if this sequence is not C.Feature.LIMITED or it drop
-n element starts from the tail side
C.Sequence seq = C.list(1, 2, 3, 4, 5);
assertEquals(C.list(3, 4, 5), seq.drop(2));
assertEquals(C.list(1, 2, 3, 4, 5), seq.drop(0));
assertEquals(C.list(), seq.drop(100));
Note this method does NOT modify the current sequence, instead it returns an new sequence structure containing the elements as required
This method does not alter the underline list
drop in interface C.ReversibleSequence<T>drop in interface C.Sequence<T>n - specify the number of elements to be taken from the head of this Sequence or
the -n number of elements to be taken from the tail of this sequence if n is
an negative numbern numberC.List<T> dropWhile(Osgl.Function<? super T,Boolean> predicate)
Sequence consisting of the elements from this sequence with leading elements
dropped until the predicate returns true
Sequence seq = C.list(1, 2, 3, 4, 3, 2, 1);
assertTrue(C.list(), seq.dropWhile(_.F.gt(100)));
assertTrue(C.list(4, 3, 2, 1), seq.dropWhile(_.F.lt(3)));
Note this method does NOT modify the current sequence, instead it returns an new sequence structure containing the elements as required
This method does not alter the underline list
dropWhile in interface C.ReversibleSequence<T>dropWhile in interface C.Sequence<T>predicate - the predicate functionC.List<T> takeWhile(Osgl.Function<? super T,Boolean> predicate)
Sequence that takes the head of this Sequence until the predicate
evaluate to false:
C.Sequence seq = C.list(1, 2, 3, 4, 5, 4, 3, 2, 1);
assertEquals(C.list(C.list(1, 2, 3), seq.takeWhile(_.F.lt(4)));
assertEquals(C.list(C.list(1, 2, 3, 3, 2, 1), seq.filter(_.F.lt(4)));
This method does not alter the underline list
takeWhile in interface C.ReversibleSequence<T>takeWhile in interface C.Sequence<T>predicate - specify which the elements in this Sequence will put into the new
SequenceC.List<T> remove(Osgl.Function<? super T,Boolean> predicate)
For immutable or readonly list, an new List contains all element from this list that does not match the predicate specified is returned
predicate - test whether an element should be removed frmo
return list<R> C.List<R> map(Osgl.Function<? super T,? extends R> mapper)
C.Sequence
Traversable traversable = C.list(23, _.NONE, null);
assertEquals(C.list(true, false, false), traversal.map(_.F.NOT_NULL));
assertEquals(C.list("23", "", ""), traversal.map(_.F.AS_STRING));
For Lazy Traversable, it must use lazy evaluation for this method. Otherwise it is up to implementation to decide whether use lazy evaluation or not
map in interface C.ReversibleSequence<T>map in interface C.Sequence<T>map in interface C.Traversable<T>R - the element type of the new traversalmapper - the function that applied to element in this traversal and returns element in the result traversalR that are mapped from this sequence<R> C.List<R> flatMap(Osgl.Function<? super T,? extends Iterable<? extends R>> mapper)
null,
this is treated as if the result is an empty traversable.flatMap in interface C.ReversibleSequence<T>flatMap in interface C.Sequence<T>flatMap in interface C.Traversable<T>R - the element type of the the new traversablemapper - the function produce an iterable when applied to an elementR type element that are mapped from this sequencesC.List<T> filter(Osgl.Function<? super T,Boolean> predicate)
C.Sequence
Traversable traversable = C.list(-1, 0, 1, -3, 7);
Traversable filtered = traversable.filter(_.F.gt(0));
assertTrue(filtered.contains(1));
assertFalse(filtered.contains(-3));
filter in interface C.ReversibleSequence<T>filter in interface C.Sequence<T>filter in interface C.Traversable<T>predicate - the function that test if the element in the traversable should be
kept in the resulting traversable. When applying the filter function
to the element, if the result is true then the element will
be kept in the resulting traversable.Sequence consists of elements that passed the predicateOsgl.T2<C.List<T>,C.List<T>> split(Osgl.Function<? super T,Boolean> predicate)
The function use the predicate to test all elements in this list. If test passed
then it add the element into left side list, otherwise the
element will be added into right side list. The result
is returned as a tuple contains the left and
right side lift
predicate - the function to test the elements in this listC.List.Cursor<T> locateFirst(Osgl.Function<T,Boolean> predicate)
-1
is returned.predicate - test the elementC.List.Cursor<T> locate(Osgl.Function<T,Boolean> predicate)
predicate - the function that used to check the element
at the cursorC.List.Cursor<T> locateLast(Osgl.Function<T,Boolean> predicate)
-1
is returned.predicate - test the elementC.List<T> insert(int index, T t) throws IndexOutOfBoundsException
index.
If this list is readonly or immutable, then an new list should be created with all elements in this list and the new element inserted at the specified position. The new list should have the same feature as this list
If index is less than zero then it will insert at
(size() + index)
index - specify the position where the element should be insertedt - the element to be insertedIndexOutOfBoundsException - Math.abs(index) > size()C.List<T> insert(int index, T... ta) throws IndexOutOfBoundsException
index.
If this list is readonly or immutable, then an new list should be created with all elements in this list and the new element inserted at the specified position. The new list should have the same feature as this list
If index is less than zero then it will insert at
(size() + index)
index - specify the position where the element should be insertedta - the array of elements to be insertedIndexOutOfBoundsException - Math.abs(index) > size()C.List<T> insert(int index, List<T> subList) throws IndexOutOfBoundsException
index.
If this list is readonly or immutable, then an new list should be created with all elements in this list and the elements of sub list inserted at the specified position. The new list should have the same feature as this list
If index is less than zero then it will insert at
(size() + index)
index - specify the position where the element should be insertedsubList - the sub list contains elements to be insertedIndexOutOfBoundsException - Math.abs(index) > size()C.List<T> append(T t)
an immutable Sequence must
return an new Sequence; while a mutable Sequence implementation
might append the element to this sequence instance
directly
append in interface C.ReversibleSequence<T>append in interface C.Sequence<T>t - the element to be appended to this sequencetC.List<T> append(Collection<? extends T> iterable)
iterable - the iterable from which elements will be appended to this listC.List<T> append(C.List<T> list)
A mutable List implementation might choose to add elements from the specified list directly to this list and return this list directly
For a read only or immutable list, it must create an new list to avoid update this list
list - the list in which elements will be appended
to this listC.List<T> prepend(T t)
C.ReversibleSequencean immutable Sequence must
return an new Sequence; while a mutable Sequence implementation
might append the element to this sequence instance
directly
prepend in interface C.ReversibleSequence<T>prepend in interface C.Sequence<T>t - the element to be appended to this sequencet
followed this seq's elementC.List<T> prepend(Collection<? extends T> collection)
C.List<T> reverse()
C.ReversibleSequenceSequence that reverse this Sequence.reverse in interface C.ReversibleSequence<T>SequenceC.Feature.LIMITED,
C.Featured.is(org.osgl.util.C.Feature)C.List<T> without(Collection<? super T> col)
col collection specifiedcol - the collection in which elements should
be excluded from the result ListC.List<T> without(T element)
element - the element that should not be in the resulting listC.List<T> without(T element, T... elements)
element - the element that should not be in the resulting listelements - the array contains elements that should not be in the resulting listC.List<T> accept(Osgl.Function<? super T,?> visitor)
C.TraversableTraversable with a visitor function. This method
does not specify the approach to iterate through this structure. The
implementation might choose iterate from left to right, or vice versa.
It might even choose to split the structure into multiple parts, and
iterate through them in parallelaccept in interface C.ReversibleSequence<T>accept in interface C.Sequence<T>accept in interface C.Traversable<T>visitor - a function that apply to element in this
Traversable. The return value
of the function is ignoredTraversable instance for chained callC.List<T> each(Osgl.Function<? super T,?> visitor)
C.TraversableC.Traversable.accept(Osgl.Function)each in interface C.ReversibleSequence<T>each in interface C.Sequence<T>each in interface C.Traversable<T>visitor - the visitor to tranverse the elementsTraversable instanceC.List<T> forEach(Osgl.Function<? super T,?> visitor)
C.TraversableC.Traversable.accept(Osgl.Function)forEach in interface C.ReversibleSequence<T>forEach in interface C.Sequence<T>forEach in interface C.Traversable<T>visitor - the visitor functionTraversable instanceC.List<T> acceptLeft(Osgl.Function<? super T,?> visitor)
C.SequenceacceptLeft in interface C.ReversibleSequence<T>acceptLeft in interface C.Sequence<T>visitor - the function to visit elements in this sequenceC.Traversable.accept(Osgl.Function),
C.ReversibleSequence.acceptRight(Osgl.Function)C.List<T> acceptRight(Osgl.Function<? super T,?> visitor)
C.ReversibleSequenceacceptRight in interface C.ReversibleSequence<T>visitor - the function to visit elements in this sequenceC.Traversable.accept(Osgl.Function),
C.Sequence.acceptLeft(Osgl.Function)C.List<T> accept(Osgl.Func2<Integer,? super T,?> indexedVisitor)
indexedVisitor - the function to be called on each element along with the indexC.List<T> each(Osgl.Func2<Integer,? super T,?> indexedVisitor)
accept(Osgl.Func2)indexedVisitor - the function to be called on each element along with the indexC.List<T> forEach(Osgl.Func2<Integer,? super T,?> indexedVisitor)
accept(Osgl.Func2)indexedVisitor - the function to be called on each element along with the indexC.List<T> acceptLeft(Osgl.Func2<Integer,? super T,?> indexedVisitor)
0 to size - 1. Call the indexedVisitor function
on each element along with the indexindexedVisitor - the function to be called on each element along with the indexC.List<T> acceptRight(Osgl.Func2<Integer,? super T,?> indexedVisitor)
size() - 1 to 0. Call the indexedVisitor function
on each element along with the indexindexedVisitor - the function to be called on each element along with the index<T2> C.List<Osgl.T2<T,T2>> zip(List<T2> list)
T2 - the type of the iterablelist - the part B to be zipped with this list<T2> C.List<Osgl.T2<T,T2>> zipAll(List<T2> list, T def1, T2 def2)
T2 - the type of the iterablelist - the part B to be zipped with this listdef1 - the element to be used to fill up the result if
this sequence is shorter than that iterabledef2 - the element to be used to fill up the result if
the iterable is shorter than this sequenceC.Sequence<Osgl.T2<T,Integer>> zipWithIndex()
zipWithIndex in interface C.Sequence<T>Copyright © 2017. All Rights Reserved.