DoublyLinkedList

public class DoublyLinkedList<Element> where Element : Equatable

DoublyLinkedList data structure

Important

Supports traversal from both next and prev nodes
  • First node of the list

    Declaration

    Swift

    private(set) public var head: DoublyLinkedListItem<Element>? { get }
  • Last Node of the list

    Declaration

    Swift

    private(set) public var tail: DoublyLinkedListItem<Element>? { get }
  • Indicates whether list is empty or not

    Declaration

    Swift

    public var isEmpty: Bool { get }
  • Inserts element at the front

    Declaration

    Swift

    public func insert(_ element: Element)

    Parameters

    element

    new element that need to be inserted

  • Appends new element at the end of the list

    Declaration

    Swift

    public func append(_ element: Element)

    Parameters

    element

    new element that need to be added

  • Deletes item from front

    Declaration

    Swift

    public func delete()
  • Fetches all the elements in the list

    Declaration

    Swift

    public func getAllIElements() -> [Element]

    Return Value

    Array of elelements

  • Removes all the elements from the list

    Declaration

    Swift

    public func clear()