DoublyLinkedList
public struct DoublyLinkedList<Element>
extension DoublyLinkedList: BidirectionalCollection, MutableCollection
extension DoublyLinkedList: ExpressibleByArrayLiteral
extension DoublyLinkedList: CustomStringConvertible
extension DoublyLinkedList: Equatable where Element: Equatable
extension DoublyLinkedList: Hashable where Element: Hashable
extension DoublyLinkedList: Sendable where Element: Sendable
A doubly linked list.
-
The address of an element in a doubly linked list.
See moreDeclaration
Swift
public struct Address : Hashable, Sendableextension DoublyLinkedList.Address: CustomStringConvertible -
A collection with the addresses of a doubly-linked list.
See moreDeclaration
Swift
public struct Addresses : @unchecked Sendableextension DoublyLinkedList.Addresses: BidirectionalCollection -
A bucket in the internal storage of a doubly linked list.
See moreNote
A bucket is said to be used if its element is notnil.Declaration
-
The number of elements in the list.
Declaration
Swift
public private(set) var count: Int { get } -
The offset of the list head.
Declaration
Swift
private var headOffset: Int -
The offset of the list tail.
Declaration
Swift
private var tailOffset: Int -
The position of the next free bucket in the list buffer.
Declaration
Swift
private var freeOffset: Int -
The elements in list.
Declaration
Swift
fileprivate var storage: [Bucket] -
Creates an empty list.
Declaration
Swift
public init() -
The number of elements that can be stored in the list without allocating new storage.
Declaration
Swift
public var capacity: Int { get } -
The address of the first element.
Declaration
Swift
public var firstAddress: Address? { get } -
Returns the first address at which an element satisfies the given predicate.
Declaration
Swift
public func firstAddress(where predicate: (Element) throws -> Bool) rethrows -> Address? -
The address of the last element.
Declaration
Swift
public var lastAddress: Address? { get } -
Returns the last address at which an element satisfies the given predicate.
Declaration
Swift
public func lastAddress(where predicate: (Element) throws -> Bool) rethrows -> Address? -
The address of the element that immediately follows the element at
address. -
The address of the element that immediately precedes the element at
address. -
The addresses in the list.
Declaration
Swift
public var addresses: Addresses { get } -
Accesses the element at
address.Declaration
Swift
public subscript(address: Address) -> Element { get set } -
Inserts
newElementat the end of the list and returns its address.Declaration
Swift
@discardableResult public mutating func append(_ newElement: Element) -> Address -
Inserts
newElementat the start of the list and returns its address.Declaration
Swift
@discardableResult public mutating func prepend(_ newElement: Element) -> Address -
Inserts
newElementafter the element ataddressand returns its address.Requires
addressmust be a valid an address inself.Declaration
-
Inserts
newElementbefore the element ataddressand returns its address.Requires
addressmust be the address of an element inself.Declaration
-
Inserts
newElementat the given position and returns its address.The new element is inserted before the element currently at
position. You can pass a “past the end” index to appendnewElementat the end ofself.Declaration
-
Removes the element at
address.Declaration
Swift
@discardableResult public mutating func remove(at address: Address) -> Element -
Reserves enough space to store the
minimumCapacityelements without allocating new storage.Declaration
Swift
public mutating func reserveCapacity(_ minimumCapacity: Int) -
Returns whether
addressis in bounds.Declaration
Swift
private func isInBounds(_ address: Address) -> Bool -
Declaration
Swift
public struct Index : Comparable, Hashable, Sendable -
Declaration
Swift
public var isEmpty: Bool { get } -
The first element of the list.
Declaration
Swift
public var first: Element? { get } -
The last element of the list.
Declaration
Swift
public var last: Element? { get } -
Declaration
Swift
public var startIndex: Index { get } -
Declaration
Swift
public var endIndex: Index { get } -
-
-
Declaration
Swift
public subscript(position: Index) -> Element { get set } -
Declaration
Swift
public init(arrayLiteral elements: Element...) -
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public static func == (l: `Self`, r: `Self`) -> Bool
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
View on GitHub