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
public var end: TUpper bound — included.
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.
Initializers
public init(T, T)
public init(T, T)Builds the closed 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: ClosedRange[T]) -> Bool
public func isEqual(to: ClosedRange[T]) -> BoolEqual when both bounds match.
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 = ClosedRangeIterator[T]
type TargetIterator = ClosedRangeIterator[T]Methods
public func iter() -> ClosedRangeIterator[T]
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]
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])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