ELEMENT - the element typepublic static interface C.Range<ELEMENT> extends C.Sequence<ELEMENT>
Define a Range data structure which contains a discrete sequence of elements start from 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(Lang.Visitor<? super ELEMENT> visitor)
Iterate this
Traversable with a visitor function. |
C.Range<ELEMENT> |
acceptLeft(Lang.Visitor<? super ELEMENT> visitor)
Iterate through this sequence from head to tail with the visitor function specified
|
C.Range<ELEMENT> |
acceptRight(Lang.Visitor<? 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(Lang.Visitor<? super ELEMENT> visitor)
Alias of
C.Traversable.accept(Lang.Visitor) |
Lang.Option<ELEMENT> |
findLast(Lang.Function<? super ELEMENT,Boolean> predicate) |
C.Range<ELEMENT> |
forEach(Lang.Visitor<? super ELEMENT> visitor)
Alias of
C.Traversable.accept(Lang.Visitor) |
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
Lang.Func2 function that takes two elements in the range domain and returns an integer to determine the order of the two elements. |
Lang.Option<ELEMENT> |
reduceRight(Lang.Func2<ELEMENT,ELEMENT,ELEMENT> accumulator) |
<R> R |
reduceRight(R identity,
Lang.Func2<R,ELEMENT,R> accumulator) |
C.Range<ELEMENT> |
reverse() |
Iterator<ELEMENT> |
reverseIterator() |
Lang.Func2<ELEMENT,Integer,ELEMENT> |
step()
Returns a
Lang.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, asList, collect, 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()
Returns the from value (inclusive) in the range
fromELEMENT to()
Returns the to value (exclusive) of the range
toboolean contains(ELEMENT element)
Check if an element is contained in this range
element - the element to be checkedtrue if the element specified is contained in the rangeboolean containsAll(C.Range<ELEMENT> r2)
Check if this range contains all elements of another range of the same type (identified by order() and step()).
r2 - the range to be testedtrue if this range contains all elements of r2Comparator<ELEMENT> order()
Returns a Lang.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
Lang.Func2<ELEMENT,Integer,ELEMENT> step()
Returns a Lang.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)
Returns an new range this range and another range 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,
Lang.Func2<R,ELEMENT,R> accumulator)
Lang.Option<ELEMENT> reduceRight(Lang.Func2<ELEMENT,ELEMENT,ELEMENT> accumulator)
Lang.Option<ELEMENT> findLast(Lang.Function<? super ELEMENT,Boolean> predicate)
C.Range<ELEMENT> accept(Lang.Visitor<? super ELEMENT> visitor)
Iterate this 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 parallel
accept 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(Lang.Visitor<? super ELEMENT> visitor)
C.TraversableAlias of C.Traversable.accept(Lang.Visitor)
each in interface C.Sequence<ELEMENT>each in interface C.Traversable<ELEMENT>visitor - the visitor to tranverse the elementsTraversable instanceC.Range<ELEMENT> forEach(Lang.Visitor<? super ELEMENT> visitor)
C.TraversableAlias of C.Traversable.accept(Lang.Visitor)
forEach in interface C.Sequence<ELEMENT>forEach in interface C.Traversable<ELEMENT>visitor - the visitor functionTraversable instanceC.Range<ELEMENT> acceptLeft(Lang.Visitor<? super ELEMENT> visitor)
Iterate through this sequence from head to tail with the visitor function specified
acceptLeft in interface C.Sequence<ELEMENT>visitor - the function to visit elements in this sequenceC.Traversable.accept(Lang.Visitor),
C.ReversibleSequence.acceptRight(Lang.Visitor)C.Range<ELEMENT> acceptRight(Lang.Visitor<? super ELEMENT> visitor)
iterate through the range from tail to head
visitor - a function to visit elements in the rangeCopyright © 2014–2019 OSGL (Open Source General Library). All rights reserved.