MarkedCircularBuffer

public struct MarkedCircularBuffer<E> : CustomStringConvertible, AppendableCollection

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:
      • initialRingCapacity: The initial capacity of the internal storage.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public mutating func removeFirst() -> E
  • The first element in the buffer.

    Declaration

    Swift

    public var first: E? { get }
  • If the buffer is empty.

    Declaration

    Swift

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

    Declaration

    Swift

    public var count: Int { get }
  • Retrieves the element at the given index from the buffer, without removing it.

    Declaration

    Swift

    public subscript(index: Int) -> E { get set }
  • The valid indices into the buffer.

    Declaration

    Swift

    public var indices: RangeType<Int> { get }
  • Declaration

    Swift

    public var startIndex: Int { get }
  • Declaration

    Swift

    public var endIndex: Int { get }
  • Declaration

    Swift

    public func index(after i: Int) -> Int
  • Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public func markedElementIndex() -> Int?
  • Returns the marked element.

    Declaration

    Swift

    public func markedElement() -> E?
  • Returns tre if the buffer has been marked at all.

    Declaration

    Swift

    public func hasMark() -> Bool