ClosedRange

public struct ClosedRange[T] where T: Steppable, T: Comparable { /* private fields */ }

Closed range [start, end] — produced by the ..= operator. Both endpoints are included in iteration.

Examples

for i in 0..=3 { print(i) } // 0, 1, 2, 3 (0..=10).contains(10) // true (vs Range, which excludes the upper)

Representation

Two values: start and end. No heap allocation.

Properties

public var end: T

Upper bound — included.

public var isEmpty: Bool { get }

true when start > end (no values are produced).

public var start: T

Lower bound — included.

Initializers

public init(T, T)

Builds the closed range [start, end].

Methods

public func contains(T) -> Bool

Returns true iff start <= value <= end.

ImplementsEquatable

Associated Types

type Output = Bool

Methods

public func equal(to: Self) -> Bool

Bridges Equal.equal(to:) to Equatable.isEqual(to:).

public func isEqual(to: ClosedRange[T]) -> Bool

Equal when both bounds match.

public func notEqual(to: Self) -> Bool

Default !=: delegates to == so there's a single source of truth.

ImplementsIterable

Associated Types

type Item = T
type TargetIterator = ClosedRangeIterator[T]

Methods

public func iter() -> ClosedRangeIterator[T]

Returns a fresh iterator over the range. The element count is distance(start, end) + 1; an empty range (start > end) yields a non-positive count and so produces nothing.

ImplementsSeqIndex

Associated Types

type SeqOutput = ArraySlice[T]

Methods

public func readSeq(from: ArraySlice[T]) -> ArraySlice[T]
public func readSeqChecked(from: ArraySlice[T]) -> ArraySlice[T]?
public func readSeqUnchecked(from: ArraySlice[T]) -> ArraySlice[T]
public func writeSeq(to: ArraySlice[T], with: ArraySlice[T])
public func writeSeqUnchecked(to: ArraySlice[T], with: ArraySlice[T])

ImplementsSeqRange

Methods

public func resolve(Int64) -> Range[Int64]

ImplementsBytesIndex

Associated Types

type BytesYield = BytesView

Methods

public func readBytes(from: BytesView) -> BytesView
public func readBytesChecked(from: BytesView) -> BytesView?
public func readBytesUnchecked(from: BytesView) -> BytesView

ImplementsBytesClampable

Associated Types

type BytesClampedYield = BytesView

Methods

public func readBytesClamped(from: BytesView) -> BytesView

ImplementsBytesWrappable

Associated Types

type BytesWrappedYield = BytesView

Methods

public func readBytesWrapped(from: BytesView) -> BytesView

ImplementsBytesSubstringIndex

Methods

public func readBytesSubstring(from: BytesView) -> String

ImplementsCharsIndex

Associated Types

type CharsYield = CharsView

Methods

public func readChars(from: CharsView) -> CharsView
public func readCharsChecked(from: CharsView) -> CharsView?

ImplementsCharsClampable

Associated Types

type CharsClampedYield = CharsView

Methods

public func readCharsClamped(from: CharsView) -> CharsView

ImplementsCharsWrappable

Associated Types

type CharsWrappedYield = CharsView

Methods

public func readCharsWrapped(from: CharsView) -> CharsView

ImplementsCharsSubstringIndex

Methods

public func readCharsSubstring(from: CharsView) -> String

ImplementsGraphemesIndex

Associated Types

type GraphemesYield = GraphemesView

Methods

public func readGraphemes(from: GraphemesView) -> GraphemesView
public func readGraphemesChecked(from: GraphemesView) -> GraphemesView?

ImplementsGraphemesClampable

Associated Types

type GraphemesClampedYield = GraphemesView

Methods

public func readGraphemesClamped(from: GraphemesView) -> GraphemesView

ImplementsGraphemesWrappable

Associated Types

type GraphemesWrappedYield = GraphemesView

Methods

public func readGraphemesWrapped(from: GraphemesView) -> GraphemesView

ImplementsGraphemesSubstringIndex

Methods

public func readGraphemesSubstring(from: GraphemesView) -> String

ImplementsLinesIndex

Associated Types

type LinesYield = LinesView

Methods

public func readLines(from: LinesView) -> LinesView
public func readLinesChecked(from: LinesView) -> LinesView?

ImplementsLinesClampable

Associated Types

type LinesClampedYield = LinesView

Methods

public func readLinesClamped(from: LinesView) -> LinesView

ImplementsLinesWrappable

Associated Types

type LinesWrappedYield = LinesView

Methods

public func readLinesWrapped(from: LinesView) -> LinesView

ImplementsLinesSubstringIndex

Methods

public func readLinesSubstring(from: LinesView) -> String

Defined in lang/std/core/range.ks