DequeSlice

A Deque is a data structure comprised of two queues. This implementation has a front queue, which is a reversed ArraySlice, and a back queue, which is an ArraySlice. Operations at either end of the Deque have the same complexity as operations on the end of either ArraySlice.

Because an ArraySlice presents a view onto the storage of some larger array even after the original array’s lifetime ends, storing the slice may prolong the lifetime of elements that are no longer accessible, which can manifest as apparent memory and object leakage. To prevent this effect, use DequeSlice only for transient computation.

  • The front and back queues. The front queue is stored in reverse

    Declaration

    Swift

    public var front, back: ArraySlice<Element>
  • Initialise an empty DequeSlice

    Declaration

    Swift

    public init() { (front, back) = ([], []) }