Linear

  • Two-dimensional matrix with user-definable dimensions, parameterized over the generic Element.

    Example Usage

    It is quite pleasant to fill a new Matrix value.

    let matrix = Matrix(height: 3, width: 3, initial: 0)
    // => 0,0,0
    //    0,0,0
    //    0,0,0
    

    You can ask what the value is at a given row and column.

    Warning: Your program will crash if the row or column is invalid — so, be careful!

    matrix[row: 1, column: 2] // => 0
    

    You can also set the value at the given row and column.

    matrix[row: 0, column: 1] = 1
    // => 0,1,0
    //    0,0,0
    //    0,0,0
    
    See more

    Declaration

    Swift

    public struct Matrix<Element>
    extension Matrix: SequenceWrapping
    extension Matrix: CustomStringConvertible
    extension Matrix: Equatable where Element: Equatable
  • The LinkedList.

    See more

    Declaration

    Swift

    public enum LinkedList<Element>
    extension LinkedList: Collection
    extension LinkedList: ExpressibleByArrayLiteral
    extension LinkedList: Equatable where Element: Equatable
  • Stack structure.

    See more

    Declaration

    Swift

    public struct Stack<Element>
    extension Stack: Collection
    extension Stack: BidirectionalCollection
    extension Stack: ExpressibleByArrayLiteral
    extension Stack: CustomStringConvertible
    extension Stack: Additive
    extension Stack: Monoid
    extension Stack: Equatable where Element: Equatable
  • First-in-first-out linear data structure.

    Remark

    Consider using two linked lists instead of an Array as the internal storage. Array gives O(*n*) performance for remove(at:), which is used by dequeue.
    See more

    Declaration

    Swift

    public struct Queue<Element>
  • Array that keeps itself sorted.

    See more

    Declaration

    Swift

    public struct SortedArray <Element: Comparable>:
        RandomAccessCollectionWrapping,
        SortedCollectionWrapping
    extension SortedArray: Equatable
    extension SortedArray: Additive
    extension SortedArray: Monoid
    extension SortedArray: ExpressibleByArrayLiteral
    extension SortedArray: Hashable where Element: Hashable
  • Array-like structure that allows retrieval of elements at indices outside of the bounds of the internal storage.

    Example Usage

    let loop: CircularArray = [0,1,2,3,4,5]
    loop[circular: 6] // => 0
    loop[from: 2, through: 7] // => [2,3,4,5,0,1]
    
    See more

    Declaration

    Swift

    public struct CircularArray<Element>
    extension CircularArray: RandomAccessCollectionWrapping
    extension CircularArray: BidirectionalCollection
    extension CircularArray: RangeReplaceableCollection
    extension CircularArray: ExpressibleByArrayLiteral
    extension CircularArray: Equatable where Element: Equatable