MarkedCircularBuffer

public struct MarkedCircularBuffer<Element> : CustomStringConvertible

A circular buffer that allows one object at a time to be marked and easily identified and retrieved later.

This object is used extensively within SwiftNIO to handle flushable buffers. It can be used to store buffered writes and mark how far through the buffer the user has flushed, and therefore how far through the buffer is safe to write.

  • Create a new instance.

    • paramaters:
      • initialCapacity: The initial capacity of the internal storage.

    Declaration

    Swift

    @inlinable
    public init(initialCapacity: Int)
  • Appends an entry to the buffer, expanding it if needed.

    Declaration

    Swift

    @inlinable
    public mutating func append(_ value: Element)
  • Removes the first element from the buffer.

    Declaration

    Swift

    @inlinable
    public mutating func removeFirst() -> Element
  • Undocumented

    Declaration

    Swift

    @inlinable
    public mutating func popFirst() -> Element?
  • The first element in the buffer.

    Declaration

    Swift

    @inlinable
    public var first: Element? { get }
  • If the buffer is empty.

    Declaration

    Swift

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

    Declaration

    Swift

    @inlinable
    public var count: Int { get }
  • Declaration

    Swift

    @inlinable
    public var description: String { get }
  • Marks the buffer at the current index, making the last index in the buffer marked.

    Declaration

    Swift

    @inlinable
    public mutating func mark()
  • Returns true if the buffer is currently marked at the given index.

    Declaration

    Swift

    @inlinable
    public func isMarked(index: Index) -> Bool
  • Returns the index of the marked element.

    Declaration

    Swift

    @inlinable
    public var markedElementIndex: Index? { get }
  • Returns the marked element.

    Declaration

    Swift

    @inlinable
    public var markedElement: Element? { get }
  • Returns true if the buffer has been marked at all.

    Declaration

    Swift

    @inlinable
    public var hasMark: Bool { get }