LinkedList
public final class LinkedList<T> where T : Equatable
An elementary example of a singly linked list
-
Create a new linked list
Declaration
Swift
public convenience init(_ element: T)
Parameters
element
An element to add to the list.
-
Create a new linked list
Declaration
Swift
public init(elements: [T])
Parameters
elements
A list of zero or more elements to add to the list.
-
The current number of elements in the list
Declaration
Swift
public private(set) var count: Int
-
Appends an element to the end of the linked list.
a -> b -> c a -> b -> c -> [d]
Declaration
Swift
public func append(_ element: T)
Parameters
element
An element to append to the linked list.
-
Removes an element from the linked list.
Declaration
Swift
@discardableResult public func remove(_ element: T) -> T?
Parameters
element
An element remove from this linked list
Return Value
The element removed, if any.
-
Asserts true if the linked list contains the element.
Declaration
Swift
public func contains(_ element: T) -> Bool
Parameters
element
An element to test for membership.
Return Value
True if the linked list contains the element, false otherwise.
-
Declaration
Swift
public func makeIterator() -> LinkedListIterator<T>
-
Declaration
Swift
public convenience init(arrayLiteral: T...)