OLEB_Queue

public protocol OLEB_Queue

This was taken straight from the objc.io book “Advanced Swift.” It’s so damn useful, that I have it made into a standard tool.

The original design was done by Ole Begemann and Chris Eidhof. I have modified it slightly; but not much.

It is fast all git-go.

A type that can efficiently “enqueue” and “dequeue” elements. It works on one element at a time. You cannot dequeue groups of elements.

  • Defines the type for the Elements

    Declaration

    Swift

    associatedtype Element
  • This will push the single element into the 0th (first) place.

    Declaration

    Swift

    mutating func cutTheLine(_: Element)
  • Adds a new Element to the end (back) of the queue

    Declaration

    Swift

    mutating func enqueue(_: Element)
  • Adds a new Array of Element to the end (back) of the queue

    Declaration

    Swift

    mutating func enqueue(_: [Element])
  • Removes and returns the first element from the beginning (front) of the queue. nil, if the queue is empty.

    Declaration

    Swift

    mutating func dequeue() -> Element?
  • Deletes all data in the queue.

    Declaration

    Swift

    mutating func removeAll()