LimitedQueue

public class LimitedQueue<T> : Sequence

A Queue with a limited capacity backed by the array

When the queue is full, the oldest element is removed from the queue if append is called

Note

the queue is not thread safe
  • Undocumented

    Declaration

    Swift

    public init(limit: Int)
  • Appends the element to the end of the queue

    Declaration

    Swift

    @discardableResult
    public func append(_ element: T) -> T?

    Return Value

    the oldest element if the queue is full, nil otherwise

  • Undocumented

    Declaration

    Swift

    public func append(contentsOf elements: any Sequence<T>)
  • Undocumented

    Declaration

    Swift

    public subscript(index: Int) -> T { get set }
  • Undocumented

    Declaration

    Swift

    public var count: Int { get }
  • Declaration

    Swift

    public func makeIterator() -> IndexingIterator<[T]>
  • Undocumented

    Declaration

    Swift

    public func removeFirst() -> T?
  • Undocumented

    Declaration

    Swift

    public func dequeue() -> T?
  • Undocumented

    Declaration

    Swift

    public var isEmpty: Bool { get }
  • Undocumented

    Declaration

    Swift

    public var isFull: Bool { get }
  • Undocumented

    Declaration

    Swift

    public var last: T? { get }
  • Undocumented

    Declaration

    Swift

    public var first: T? { get }
  • Undocumented

    Declaration

    Swift

    public var asArray: [T] { get }
  • Undocumented

    Declaration

    Swift

    public func extendLimit(by offset: Int)
  • Undocumented

    Declaration

    Swift

    public func shrinkTo(limit: Int)
  • Undocumented

    Declaration

    Swift

    public func clear()