ELEMENT - the element typepublic static interface C.Range<ELEMENT> extends C.Sequence<ELEMENT>
from()
until to(). The from element should be contained in the range, while the to
element should be exclusive from the range. While the from and to defines the boundary of
an range, the step() defines how to step from one element to another in the range.C.Featured.Factory| Modifier and Type | Method and Description |
|---|---|
C.Range<ELEMENT> |
accept(Osgl.Function<? super ELEMENT,?> visitor)
Iterate this
Traversable with a visitor function. |
C.Range<ELEMENT> |
acceptLeft(Osgl.Function<? super ELEMENT,?> visitor)
Iterate through this sequence from head to tail with
the visitor function specified
|
C.Range<ELEMENT> |
acceptRight(Osgl.Function<? super ELEMENT,?> visitor)
iterate through the range from tail to head
|
boolean |
contains(ELEMENT element)
Check if an element is contained in this range
|
boolean |
containsAll(C.Range<ELEMENT> r2)
|
C.Range<ELEMENT> |
each(Osgl.Function<? super ELEMENT,?> visitor)
Alias of
C.Traversable.accept(Osgl.Function) |
Osgl.Option<ELEMENT> |
findLast(Osgl.Function<? super ELEMENT,Boolean> predicate) |
C.Range<ELEMENT> |
forEach(Osgl.Function<? super ELEMENT,?> visitor)
Alias of
C.Traversable.accept(Osgl.Function) |
ELEMENT |
from()
Returns the
from value (inclusive) in the range |
ELEMENT |
last() |
C.Range<ELEMENT> |
merge(C.Range<ELEMENT> r2)
Returns an new range this range and another range
r2 merged together. |
Comparator<ELEMENT> |
order()
Returns a
$.Func2 function that takes two elements in the range domain and returns an integer to
determine the order of the two elements. |
Osgl.Option<ELEMENT> |
reduceRight(Osgl.Func2<ELEMENT,ELEMENT,ELEMENT> accumulator) |
<R> R |
reduceRight(R identity,
Osgl.Func2<R,ELEMENT,R> accumulator) |
C.Range<ELEMENT> |
reverse() |
Iterator<ELEMENT> |
reverseIterator() |
Osgl.Func2<ELEMENT,Integer,ELEMENT> |
step()
Returns a
$.Func2 function that applied to an element in this Range and
an integer n indicate the number of steps. |
C.Range<ELEMENT> |
tail(int n) |
ELEMENT |
to()
Returns the
to value (exclusive) of the range |
append, append, append, append, append, count, drop, dropWhile, eager, filter, findFirst, first, flatMap, head, head, lazy, map, parallel, prepend, prepend, prepend, prepend, prepend, reduce, reduce, reduceLeft, reduceLeft, sequential, tail, take, takeWhile, zip, zipAll, zipWithIndexallMatch, anyMatch, findOne, isEmpty, noneMatch, sizeforEach, iterator, spliteratorfeatures, isELEMENT from()
from value (inclusive) in the rangefromELEMENT to()
to value (exclusive) of the rangetoboolean contains(ELEMENT element)
element - the element to be checkedtrue if the element specified is contained in the rangeboolean containsAll(C.Range<ELEMENT> r2)
order() and step()).r2 - the range to be testedtrue if this range contains all elements of r2Comparator<ELEMENT> order()
$.Func2 function that takes two elements in the range domain and returns an integer to
determine the order of the two elements. See Comparator.compare(Object, Object) for
semantic of the function.
If any one of the element applied is null the function should throw out
NullPointerException
Osgl.Func2<ELEMENT,Integer,ELEMENT> step()
$.Func2 function that applied to an element in this Range and
an integer n indicate the number of steps. The result of the function is an element in
the range or the range domain after moving n steps based on the element.
If the element apply is null, the function should throw out
NullPointerException; if the resulting element is not defined in the range
domain, the function should throw out NoSuchElementException
C.Range<ELEMENT> merge(C.Range<ELEMENT> r2)
r2 merged together. The two ranges must have
the equal step() and order() operator to be merged, otherwise,
InvalidArgException will be thrown out
The two ranges must be either overlapped or immediately connected to each other as per
step() definition. Otherwise an InvalidArgException
will be throw out:
InvalidArgException will be thrown out if the two ranges does not connected
to each otherr2 - the range to be merged with this rangeInvalidArgException - if the two ranges does not have
the same step() operator or does not connect to each otherELEMENT last()
<R> R reduceRight(R identity,
Osgl.Func2<R,ELEMENT,R> accumulator)
Osgl.Option<ELEMENT> reduceRight(Osgl.Func2<ELEMENT,ELEMENT,ELEMENT> accumulator)
Osgl.Option<ELEMENT> findLast(Osgl.Function<? super ELEMENT,Boolean> predicate)
C.Range<ELEMENT> accept(Osgl.Function<? super ELEMENT,?> visitor)
Traversable 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.Sequence<ELEMENT>accept in interface C.Traversable<ELEMENT>visitor - a function that apply to element in this
Traversable. The return value
of the function is ignoredC.Range<ELEMENT> each(Osgl.Function<? super ELEMENT,?> visitor)
C.TraversableC.Traversable.accept(Osgl.Function)each in interface C.Sequence<ELEMENT>each in interface C.Traversable<ELEMENT>visitor - the visitor to tranverse the elementsTraversable instanceC.Range<ELEMENT> forEach(Osgl.Function<? super ELEMENT,?> visitor)
C.TraversableC.Traversable.accept(Osgl.Function)forEach in interface C.Sequence<ELEMENT>forEach in interface C.Traversable<ELEMENT>visitor - the visitor functionTraversable instanceC.Range<ELEMENT> acceptLeft(Osgl.Function<? super ELEMENT,?> visitor)
acceptLeft in interface C.Sequence<ELEMENT>visitor - the function to visit elements in this sequenceC.Traversable.accept(Osgl.Function),
C.ReversibleSequence.acceptRight(Osgl.Function)C.Range<ELEMENT> acceptRight(Osgl.Function<? super ELEMENT,?> visitor)
visitor - a function to visit elements in the rangeCopyright © 2017. All Rights Reserved.