A range of adjacent Enumerable values. Two values of an
enumerable type are considered adjacent if their
offset is of unit or zero magnitude.
Thus, a Range is a list of values where for every integer
index where both index and index+1 fall within the
indices of the range:
range[index+1].offset(range[index]).magnitude <= 1
A range is always nonempty, containing at least one value.
Thus, it is a Sequence.
A sequence of adjacent values may be represented very efficiently in memory, either:
first..last, orfirst:size.Furthermore, certain operations are much more efficient than for other lists, assuming that the enumerable type has efficient neighbour and offset functions.
The functions makeSpan() and
makeMeasure(), and corresponding operators
.. and : are used to create new instances of Range.
makeSpan(), makeMeasure()no subtypes hierarchy
| Initializer |
Range() |
| Attributes | |
coalesced | Source Codeshared actual Range<Element> coalescedReturns the range itself, since a range cannot contain null elements. Refines Iterable.coalesced |
decreasing | Source Codeshared formal Boolean decreasingDetermines if the range is decreasing, that is, if predecessors occur after successors. |
distinct | Source Codeshared actual Range<Element> distinctReturns the range itself, since a range cannot contain duplicate elements. Refines Iterable.distinct |
increasing | Source Codeshared formal Boolean increasingDetermines if the range is increasing, that is, if successors occur after predecessors. Since 1.1.0 |
| Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Collection<Element> |
Attributes inherited from: Correspondence<Key,Item> |
Attributes inherited from: Iterable<Element,Absent> |
Attributes inherited from: List<Element> |
Attributes inherited from: [Element+] |
Attributes inherited from: Element[] |
| Methods | |
contains | Source Codeshared actual Boolean contains(Object element)Returns For any instance element in c For most
However, it is possible to form a useful |
containsElement | Source Codeshared formal Boolean containsElement(Element element)Determines if this range includes the given value. |
includesRange | Source Codeshared formal Boolean includesRange(Range<Element> range)Determines if this range includes the given range. |
shifted | Source Codeshared formal Range<Element> shifted(Integer shift)Returns a range of the same length and type as this range, with its endpoints shifted by the given number of elements, where:
Since 1.1.0 |