ContiguousSegmentCollection
public struct ContiguousSegmentCollection <Segment: Intervallic>
where Segment.Metric: Hashable & Additive
extension ContiguousSegmentCollection: Intervallic
extension ContiguousSegmentCollection: RandomAccessCollectionWrapping
extension ContiguousSegmentCollection: ExpressibleByArrayLiteral
extension ContiguousSegmentCollection: CustomStringConvertible
extension ContiguousSegmentCollection: Fragmentable where
Metric: Zero,
Segment: IntervallicFragmentable,
Segment.Fragment: IntervallicFragmentable,
Segment.Fragment.Fragment == Segment.Fragment
extension ContiguousSegmentCollection: Equatable where Segment: Equatable
extension ContiguousSegmentCollection: Hashable where Segment: Hashable
A generic collection of contiguous Intervallic-type value wherein Intervallic types are
stored by their offset.
Example Usage
let collection: ContiguousSegmentCollection = [1,2,1,3]
This creates a ContiguousSegmentCollection<Int>, where the Metric and Intervallic types
are both Int. Each segment is the length of a given value, and is stored by the accumulating
offset.
The resulting structure could be represented like this:
offset: 0 1 3 4 7
|-|--|-|---|
length: 1 2 1 3
-
The type which is used to measure the
Segment.Declaration
Swift
public typealias Metric = Segment.Metric
-
ContiguousSegmentCollectionwith no segments.Declaration
Swift
public static var empty: ContiguousSegmentCollection { get }
-
Creates a
ContiguousSegmentCollectionwith the givenpresortedSortedDictionaryof values.Declaration
Swift
public init(_ presorted: SortedDictionary<Metric, Segment>) -
Creates a
ContiguousSegmentCollectionwith the givensequenceof segments.Declaration
Swift
public init<S>(_ sequence: S, offset: Metric = .zero) where Segment == S.Element, S : Sequence -
Creates a
ContiguousSegmentCollectionwith the givencollectionof segments.Declaration
Swift
public init <C: Collection> (_ collection: C, offset: Metric = .zero) where C.Element == Segment -
Creates a
ContiguousSegmentCollectionwith the givenpresortedcollection of key-value pairs.Declaration
Swift
public init<C>(presorted: C) where C : Collection, C.Element == (Segment.Metric, Segment)
-
Declaration
Swift
public var offsets: AnyCollection<Metric> { get }Return Value
A collection of the offsets of each spanner contained herein.
-
Declaration
Swift
public var segments: AnyCollection<Segment> { get }Return Value
A collection of the spanners contained herein.
-
Declaration
Swift
public var normalized: ContiguousSegmentCollection { get }Return Value
A
ContiguousSegmentCollectionwith alloffsetsreduced such that the first offset is0.
-
Declaration
Swift
public var base: SortedDictionary<Metric, Segment> { get }Return Value
A view of the underlying storage producing a
RandomAccessCollectioninterface.
-
A fragment of a
See moreContiguousSegmentCollection.Declaration
Swift
public struct Fragmentextension ContiguousSegmentCollection.Fragment: RandomAccessCollectionWrappingextension ContiguousSegmentCollection.Fragment: IntervallicFragmentableextension ContiguousSegmentCollection.Fragment: Equatable where Segment: Equatable, Segment.Fragment: Equatable -
Declaration
Swift
public func indexOfSegment(containing offset: Metric) -> Int?Return Value
The index of the segment containing the given
offset, if it exists. Otherwise,nil.
-
Creates a
ContiguousSegmentCollectionwith the given array literal.Declaration
Swift
public init(arrayLiteral elements: Segment...)
-
Declaration
Swift
public var description: String { get }
View on GitHub
Install in Dash
ContiguousSegmentCollection Structure Reference