Pillarbox

public class Pillarbox<Element> where Element : Decodable, Element : Encodable

A object-based queue which is persisted to the disk. Supports both FIFO and LIFO strategies. Should be thread-safe as well.

Creating a Pillarbox

Performing Queue Operations

  • Retrieves, but does not remove, the head of the queue, or returns nil f the queue is empty. If the strategy is fifo, the first inserted item will be returned, for lifo it will be the last one.

    Declaration

    Swift

    @inlinable
    func peek() -> Element?

    Return Value

    The retrieved element or nil

  • Retrieves and removes the head of the queue, or returns nil if the queue is empty. Writes the updated queue to the disk and removes the persisted element. If the strategy is fifo, the first inserted item will be returned, for lifo it will be the last one.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func pop() -> Element?

    Return Value

    The retrieved element or nil

  • Pushes the specified element into the queue and persist it on the disk.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func push(_ element: Element) -> String

    Parameters

    element

    The element to push into the queue.

    Return Value

    The key which identifies the element

  • A Boolean value indicating whether the queue is empty.

    Declaration

    Swift

    @inlinable
    var isEmpty: Bool { get }
  • The number of elements in the queue.

    Declaration

    Swift

    @inlinable
    var count: Int { get }
  • All elements in the queue

    Declaration

    Swift

    @inlinable
    var elements: [Element] { get }
  • Undocumented

    Declaration

    Swift

    @inlinable
    subscript(key: String) -> Element? { get }