LinkedList


STRUCT

LinkedList

Swift
1public struct LinkedList<T>: ExpressibleByArrayLiteral

A doubly linked list implementation.

This implementation utilizes copy on write semantics and is optimized for forward and backwards traversal and appending items (which requires accessing last).

It is not optimized for prepending or insertion of items.

Properties

Swift
1public var head: Node

The head (first) node in the list

last

Swift
1public var last: Node

The last node in the list

Methods

init(_:)

Swift
1public init(_ headValue: T)

init(array:)

Swift
1public init(array: [T])

init(arrayLiteral:)

Swift
1public init(arrayLiteral segments: T...)

append(_:)

Swift
1public mutating func append(_ value: T)

append(_:)

Swift
1public mutating func append<S: Sequence>(_ sequence: S) where S.Element == T

appending(_:)

Swift
1public func appending(_ value: T) -> LinkedList<T>

appending(_:)

Swift
1public func appending<S: Sequence>(
2  _ sequence: S
3) -> LinkedList<T> where S.Element == T

mutateLast(_:)

Swift
1public mutating func mutateLast(_ mutate: (T) -> T)

mutatingLast(_:)

Swift
1public func mutatingLast(_ mutate: (T) -> T) -> LinkedList<T>

+(_:_:)

Swift
1public static func +<S: Sequence>(
2  lhs: LinkedList<T>,
3  rhs: S
4) -> LinkedList<T> where S.Element == T

+=(_:_:)

Swift
1public static func +=<S: Sequence>(
2  lhs: inout LinkedList<T>,
3  rhs: S
4) where S.Element == T
Feedback

Edit on GitHub

Forums