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:

  • via its endpoints, first..last, or
  • via an endpoint and length, first: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.

no subtypes hierarchy

coalescedSource Codeshared actual Range<Element> coalesced

Returns the range itself, since a range cannot contain null elements.

decreasingSource Codeshared formal Boolean decreasing

Determines if the range is decreasing, that is, if predecessors occur after successors.

distinctSource Codeshared actual Range<Element> distinct

Returns the range itself, since a range cannot contain duplicate elements.

increasingSource Codeshared formal Boolean increasing

Determines 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[]
containsSource Codeshared actual Boolean contains(Object element)

Returns true if the given value belongs to this Category, that is, if it is an element of this Category, or false otherwise.

For any instance c of Category, c.contains(element) may be written using the in operator:

element in c

For most Categorys, the following relationship is satisfied by every pair of elements x and y:

  • if x==y, then x in category == y in category

However, it is possible to form a useful Category consistent with some other equivalence relation, for example ===. Therefore implementations of contains() which do not satisfy this relationship are tolerated.

Refines Sequence.contains ultimately refines Category.contains
containsElementSource Codeshared formal Boolean containsElement(Element element)

Determines if this range includes the given value.

includesRangeSource Codeshared formal Boolean includesRange(Range<Element> range)

Determines if this range includes the given range.

shiftedSource 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
Inherited Methods
Methods inherited from: Object
Methods inherited from: Category<Element>
Methods inherited from: Collection<Element>
Methods inherited from: Correspondence<Key,Item>
Methods inherited from: Iterable<Element,Absent>
Methods inherited from: List<Element>
Methods inherited from: Ranged<Index,Element,Subrange>
Methods inherited from: [Element+]
Methods inherited from: Element[]