Range
public struct Range[T] where T: Steppable, T: Comparable { /* private fields */ }Half-open range [start, end) — produced by the ..< operator.
Range is Iterable, so for x in 0..<10 { … } works directly.
T must be Steppable (defines successor()) and Comparable (so
the iterator knows when to stop). Empty ranges (start >= end) yield
nothing.
Examples
for i in 0..<3 { print(i) } // 0, 1, 2
(0..<10).contains(5) // true
(0..<0).isEmpty() // true
Representation
Two values: start and end. No heap allocation.
Properties
public var end: T
public var end: TUpper bound — excluded from the range.
public var isEmpty: Bool { get }
public var isEmpty: Bool { get }true when start >= end (no values are produced).
public var start: T
public var start: TLower bound — included in the range.
Initializers
public init(T, T)
public init(T, T)Builds the range [start, end).
Methods
public func contains(T) -> Bool
public func contains(T) -> BoolReturns true iff start <= value < end.
ImplementsEquatable
Associated Types
type Output = Bool
type Output = BoolMethods
public func equal(to: Self) -> Bool
public func equal(to: Self) -> BoolBridges Equal.equal(to:) to Equatable.isEqual(to:).
public func isEqual(to: Range[T]) -> Bool
public func isEqual(to: Range[T]) -> BoolEqual when both bounds match. Useful for range-keyed lookups and tests, not a structural property of the iteration order.
public func notEqual(to: Self) -> Bool
public func notEqual(to: Self) -> BoolDefault !=: delegates to == so there's a single source of truth.
ImplementsIterable
Associated Types
type Item = T
type Item = Ttype TargetIterator = RangeIterator[T]
type TargetIterator = RangeIterator[T]Methods
public func iter() -> RangeIterator[T]
public func iter() -> RangeIterator[T]Returns a fresh iterator over the range. Multiple calls produce
independent iterators — Range is value-typed.
ImplementsSeqIndex
Associated Types
type SeqOutput = ArraySlice[T]
type SeqOutput = ArraySlice[T]Methods
public func readSeq(from: ArraySlice[T]) -> ArraySlice[T]
public func readSeq(from: ArraySlice[T]) -> ArraySlice[T]public func readSeqChecked(from: ArraySlice[T]) -> ArraySlice[T]?
public func readSeqChecked(from: ArraySlice[T]) -> ArraySlice[T]?public func readSeqUnchecked(from: ArraySlice[T]) -> ArraySlice[T]
public func readSeqUnchecked(from: ArraySlice[T]) -> ArraySlice[T]public func writeSeq(to: ArraySlice[T], with: ArraySlice[T])
public func writeSeq(to: ArraySlice[T], with: ArraySlice[T])public func writeSeqUnchecked(to: ArraySlice[T], with: ArraySlice[T])
public func writeSeqUnchecked(to: ArraySlice[T], with: ArraySlice[T])ImplementsSeqClampable
Associated Types
type SeqClampedOutput = ArraySlice[T]
type SeqClampedOutput = ArraySlice[T]Methods
public func readSeqClamped(from: ArraySlice[T]) -> ArraySlice[T]
public func readSeqClamped(from: ArraySlice[T]) -> ArraySlice[T]public func writeSeqClamped(to: ArraySlice[T], with: ArraySlice[T])
public func writeSeqClamped(to: ArraySlice[T], with: ArraySlice[T])ImplementsSeqRange
Methods
public func resolve(Int64) -> Range[Int64]
public func resolve(Int64) -> Range[Int64]ImplementsBytesIndex
Associated Types
type BytesYield = BytesView
type BytesYield = BytesViewMethods
public func readBytes(from: BytesView) -> BytesView
public func readBytes(from: BytesView) -> BytesViewpublic func readBytesChecked(from: BytesView) -> BytesView?
public func readBytesChecked(from: BytesView) -> BytesView?public func readBytesUnchecked(from: BytesView) -> BytesView
public func readBytesUnchecked(from: BytesView) -> BytesViewImplementsBytesClampable
Associated Types
type BytesClampedYield = BytesView
type BytesClampedYield = BytesViewMethods
public func readBytesClamped(from: BytesView) -> BytesView
public func readBytesClamped(from: BytesView) -> BytesViewImplementsBytesWrappable
Associated Types
type BytesWrappedYield = BytesView
type BytesWrappedYield = BytesViewMethods
public func readBytesWrapped(from: BytesView) -> BytesView
public func readBytesWrapped(from: BytesView) -> BytesViewImplementsBytesSubstringIndex
Methods
public func readBytesSubstring(from: BytesView) -> String
public func readBytesSubstring(from: BytesView) -> StringImplementsCharsIndex
Associated Types
type CharsYield = CharsView
type CharsYield = CharsViewMethods
public func readChars(from: CharsView) -> CharsView
public func readChars(from: CharsView) -> CharsViewpublic func readCharsChecked(from: CharsView) -> CharsView?
public func readCharsChecked(from: CharsView) -> CharsView?ImplementsCharsClampable
Associated Types
type CharsClampedYield = CharsView
type CharsClampedYield = CharsViewMethods
public func readCharsClamped(from: CharsView) -> CharsView
public func readCharsClamped(from: CharsView) -> CharsViewImplementsCharsWrappable
Associated Types
type CharsWrappedYield = CharsView
type CharsWrappedYield = CharsViewMethods
public func readCharsWrapped(from: CharsView) -> CharsView
public func readCharsWrapped(from: CharsView) -> CharsViewImplementsCharsSubstringIndex
Methods
public func readCharsSubstring(from: CharsView) -> String
public func readCharsSubstring(from: CharsView) -> StringImplementsGraphemesIndex
Associated Types
type GraphemesYield = GraphemesView
type GraphemesYield = GraphemesViewMethods
public func readGraphemes(from: GraphemesView) -> GraphemesView
public func readGraphemes(from: GraphemesView) -> GraphemesViewpublic func readGraphemesChecked(from: GraphemesView) -> GraphemesView?
public func readGraphemesChecked(from: GraphemesView) -> GraphemesView?ImplementsGraphemesClampable
Associated Types
type GraphemesClampedYield = GraphemesView
type GraphemesClampedYield = GraphemesViewMethods
public func readGraphemesClamped(from: GraphemesView) -> GraphemesView
public func readGraphemesClamped(from: GraphemesView) -> GraphemesViewImplementsGraphemesWrappable
Associated Types
type GraphemesWrappedYield = GraphemesView
type GraphemesWrappedYield = GraphemesViewMethods
public func readGraphemesWrapped(from: GraphemesView) -> GraphemesView
public func readGraphemesWrapped(from: GraphemesView) -> GraphemesViewImplementsGraphemesSubstringIndex
Methods
public func readGraphemesSubstring(from: GraphemesView) -> String
public func readGraphemesSubstring(from: GraphemesView) -> StringImplementsLinesIndex
Associated Types
type LinesYield = LinesView
type LinesYield = LinesViewMethods
public func readLines(from: LinesView) -> LinesView
public func readLines(from: LinesView) -> LinesViewpublic func readLinesChecked(from: LinesView) -> LinesView?
public func readLinesChecked(from: LinesView) -> LinesView?ImplementsLinesClampable
Associated Types
type LinesClampedYield = LinesView
type LinesClampedYield = LinesViewMethods
public func readLinesClamped(from: LinesView) -> LinesView
public func readLinesClamped(from: LinesView) -> LinesViewImplementsLinesWrappable
Associated Types
type LinesWrappedYield = LinesView
type LinesWrappedYield = LinesViewMethods
public func readLinesWrapped(from: LinesView) -> LinesView
public func readLinesWrapped(from: LinesView) -> LinesViewImplementsLinesSubstringIndex
Methods
public func readLinesSubstring(from: LinesView) -> String
public func readLinesSubstring(from: LinesView) -> StringDefined in lang/std/core/range.ks