LinkedList
public class LinkedList<Value> : Sequence, CustomStringConvertibleextension LinkedList: Equatable where Value: EquatableA doubly linked list.
Discussion
A workflow is ultimately a doubly linked list. This is the underlying sequence type used.
-  
          
         The beginning index of the linked list (0 indexed). Complexity O(1)DeclarationSwift public var startIndex: LinkedList.Index { get }
-  
          
         The last index in the list. Complexity O(n). The linked list must traverse to the end.DeclarationSwift public var endIndex: LinkedList.Index { get }
-  
          
         A textual representation of the linked list and its elements. DeclarationSwift public var description: String { get }
-  
          
         A boolean to indicate whether the linked list contains any values. Complexity O(1)DeclarationSwift public var isEmpty: Bool { get }
-  
          
         The number of elements in the linked list. Complexity O(n). The linked list must traverse to the end to determine the count.DeclarationSwift public var count: LinkedList.Index { get }
-  
          
         The first node in the linked list. DeclarationSwift public var first: Element?
-  
          
         The last node in the linked list. Complexity O(n). The linked list must traverse to the end.DeclarationSwift public var last: Element? { get }
-  
          
         Creates a copy of a LinkedListby providing the first node and copying it.DeclarationSwift public required init(_ node: Element? = nil)
-  
          
         Creates a LinkedListby providing the first node in the list.Important This can potentially cause memory retention issues, you are passing a reference, be aware.DeclarationSwift public required init(withoutCopying node: Element?)
-  
          
         Returns an iterator over the elements of this sequence. DeclarationSwift public func makeIterator() -> Iterator
-  
          
         Returns the last element of the sequence that satisfies the given predicate. Complexity O(n). The linked list must traverse to the end.ExampleThis example uses the last(where:)method to find the last negative number in an array of integers:let numbers = LinkedList([3, 7, 4, -2, 9, -6, 10, 1]) if let lastNegative = numbers.last(where: { $0.value < 0 }) { print("The last negative number is \(lastNegative).") } // Prints "The last negative number is -6."ParameterspredicateA closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element is a match. Return ValueThe last element of the sequence that satisfies predicate, ornilif there is no element that satisfiespredicate.
-  
          
         Appends a new node to the end of the linked list. Important This operation mutates the originalLinkedList.DeclarationSwift public func append(_ element: Value)Parameterselementthe concrete value that should be appended. 
-  
          
         Appends a collection of nodes to the end of the linked list. Important This operation mutates the originalLinkedList.DeclarationSwift public func append<S>(contentsOf newElements: S) where Value == S.Element, S : SequenceParametersnewElementsa sequence of concrete elements that should be appended. 
-  
          
         Inserts a new node at a specified location. Important This operation mutates the originalLinkedList.DeclarationSwift public func insert(_ element: Value, atIndex i: Index)Parameterselementthe concrete value that should be inserted. ithe index the value should be inserted at. 
-  
          
         Inserts a sequence of new nodes at a specified location. Important This operation mutates the originalLinkedList.DeclarationSwift public func insert<C>(contentsOf newElements: C, at i: Index) where Value == C.Element, C : CollectionParametersnewElementsa sequence of concrete values that should be inserted. ithe index the sequence should be inserted at. 
-  
          
         Removes a node at the specified index. Important This operation mutates the originalLinkedList.Important If you pass an index greater than the count of the LinkedList this will be a NO-OP.DeclarationSwift public func remove(at i: Index)Parametersithe index the value should be removed from. 
-  
          
         Removes a node at the specified index. Important This operation mutates the originalLinkedList.DeclarationSwift public func remove(where predicate: (Element) -> Bool)Parameterspredicatea closure indicating whether that node should be removed. 
-  
          
         Removes the first n nodes from the linked list. Important This operation mutates the originalLinkedList.Important If you pass a value greater than the count of the linked list you will remove all items.DeclarationSwift public func removeFirst(_ n: Int = 1)Parametersnthe number of nodes that should be removed. 
-  
          
         Removes the last n nodes from the linked list. Important This operation mutates the originalLinkedList.Important If you pass a value greater than the count of the linked list you will remove all items.DeclarationSwift public func removeLast(_ n: Int = 1)Parametersnthe number of nodes that should be removed. 
-  
          
         Removes the last node from the linked list; returns the removed concrete type. Important This operation mutates the originalLinkedList.DeclarationSwift public func popLast() -> Value?Return Valuethe concrete type the node encapsulated that was removed; nil if no node exists. 
-  
          
         Removes all nodes from the linked list. Important This operation mutates the originalLinkedList.DeclarationSwift public func removeAll()
-  
          
         Swaps the concrete values of 2 nodes. Important This operation mutates the originalLinkedList.Important If you call this with an invalid index you will cause afatalErrorand stop execution of the process.DeclarationSwift public func swapAt(_ i: Int, _ j: Int)Parametersithe index of the first item to be swapped. jthe index of the second item to be swapped. 
-  
          
         Replaces the concrete value of the node at the specified index. Important This operation mutates the originalLinkedList.Important If you call this with an invalid index this will be a NO-OP.DeclarationSwift public func replace(atIndex index: Int, withItem newItem: Value)Parametersindexthe index of the node with the value to be replaced. newItemthe concrete value that should replace the old value. 
-  
          
         Reverses the linked list. Important This operation mutates the originalLinkedList.DeclarationSwift public func reverse()
-  
          
         Sorts the linked list. Important This operation mutates the originalLinkedList.Important This will not mutate any references to nodes you have, for memory and performance reasons this sorts theLinkedListwithout modifying original nodes.Complexity O(n log(n)) This uses Merge Sort under the covers and is more performant than the built in alternative.DeclarationSwift public func sort(by comparator: (Value, Value) -> Bool)Parameterscomparatora closure that takes in 2 concrete types and indicates how they should be sorted. 
-  
          
         Returns a new version of the LinkedList with all elements reversed. DeclarationSwift public func reversed() -> LinkedList<Value>
-  
          
         Returns a new version of the linked list with a specific element replaced. DeclarationSwift public func replacing(atIndex index: Int, withItem newItem: Value) -> LinkedList<Value>Parametersindexthe index of the node whose concrete value should be replaced. newItemthe concrete value to replace. 
-  
          
         Returns a new, sorted version of the linked list. Complexity O(n log(n)) This uses Merge Sort under the covers and is more performant than the built in alternative.DeclarationSwift public func sorted(by comparator: (Value, Value) -> Bool) -> LinkedList<Value>Parameterscomparatora closure that takes in 2 concrete types and indicates how they should be sorted. 
-  
          
         Returns a new version of the linked list without the first n items. Important If you pass in an index that is out of the range of the linked list an emptyLinkedListwill be returned.DeclarationSwift public func dropFirst(_ n: Int = 1) -> SubSequenceParametersnthe number of items to drop from the start of the list. 
-  
          
         Returns a new version of the linked list without the last n items. Important If you pass in an index that is out of the range of the linked list an emptyLinkedListwill be returned.DeclarationSwift public func dropLast(_ n: Int = 1) -> SubSequenceParametersnthe number of items to drop from the end of the list. 
-  
          
         Returns a linked list by skipping elements while predicate returns true and returning the remaining elements. DeclarationSwift public func drop(while predicate: (Value) throws -> Bool) rethrows -> SubSequenceParameterspredicatea closure that takes a concrete type of the node as its argument and returns true if the element should be skipped or false if it should be included. Once the predicate returns false it will not be called again. 
-  
          
         Returns a new version of the linked list with just the first n items. Important If you pass in an index that is greater than the size of the linked list you’ll get the full list. If you send in an index of 0 or smaller, you’ll get an empty list back.DeclarationSwift public func prefix(_ maxLength: Int) -> SubSequenceParametersmaxLengththe number of items to return. 
-  
          
         Returns a linked list containing the initial elements until predicate returns false and skipping the remaining elements. DeclarationSwift public func prefix(while predicate: (Value) throws -> Bool) rethrows -> SubSequenceParameterspredicatea closure that takes a concrete type of the node as its argument and returns true if the element should be included or false if it should be excluded. Once the predicate returns false it will not be called again. 
-  
          
         Returns a new version of the linked list with just the last n items. DeclarationSwift public func suffix(_ maxLength: Int) -> SubSequenceParametersmaxLengththe number of items to return. 
-  
          
         Sorts the linked list in place using a merge sort. Important This will not mutate any references to nodes you have, for memory and performance reasons this sorts theLinkedListwithout modifying original nodes.DeclarationSwift public func sort()
-  
          
         Returns a sorted version of the linked list. DeclarationSwift public func sorted() -> LinkedList<Value>
-  
          
         Returns the maximum concrete value in the linked list; nil if there is none. DeclarationSwift public func max() -> Value?
-  
          
         Returns the minimum concrete value in the linked list; nil if there is none. DeclarationSwift public func min() -> Value?
-  
          
         Returns a boolean indicating whether the given value is present in the linked list. DeclarationSwift public func contains(_ element: Element.Value) -> BoolParameterselementthe value to check against the linked list. 
 View on GitHub
 View on GitHub  LinkedList Class Reference
 LinkedList Class Reference