Instance Methodswift-nio 2.72.0NIOCore
index(before:)
Returns the index before index
.
func index(before: Index) -> Index
Other members in extension
Types
struct Index
An opaque
CircularBuffer
index.
Typealiases
Type members
init(
) Allocates an empty buffer.
init(arrayLiteral: Element...
) init(initialCapacity: Int
) Allocates a buffer that can hold up to
initialCapacity
elements and initialise an empty ring backed by the buffer. When the ring grows to more thaninitialCapacity
elements the buffer will be expanded.
Instance members
var capacity: Int
The total number of elements that the ring can contain without allocating new storage.
var count: Int
Returns the number of element in the ring.
var description: String
Returns a human readable description of the ring.
var endIndex: Index
The
CircularBuffer
’s “past the end” position—that is, the position one greater than the last valid subscript argument.var first: Element?
The first
Element
of theCircularBuffer
(ornil
if empty).var isEmpty: Bool
Returns whether the ring is empty.
var startIndex: Index
The position of the first element in a nonempty
CircularBuffer
.subscript(Range<Index>
) -> SubSequence subscript(Index
) -> Element Accesses the element at the specified index.
subscript(offset: Int
) -> Element Return element
offset
from first element.func append(Element
) Append an element to the end of the ring buffer.
func distance(from: CircularBuffer<Element>.Index, to: CircularBuffer<Element>.Index
) -> Int func index(Index, offsetBy: Int
) -> Index Returns the index offset by
distance
fromindex
.func index(after: Index
) -> Index func modify<Result>(Index, (inout Element) throws -> Result
) rethrows -> Result Modify the element at
index
.func popFirst(
) -> Element? Removes and returns the first element of the
CircularBuffer
.func popLast(
) -> Element? Removes and returns the last element of the
CircularBuffer
.func prepend(Element
) Prepend an element to the front of the ring buffer.
func remove(at: Index
) -> Element Removes & returns the item at
position
from the bufferfunc removeAll(keepingCapacity: Bool
) Removes all members from the circular buffer whist keeping the capacity.
func removeFirst(
) -> Element Removes and returns the first element of the
CircularBuffer
.func removeFirst(Int
) Removes the specified number of elements from the beginning of the
CircularBuffer
.func removeLast(
) -> Element Removes and returns the last element of the
CircularBuffer
.func removeLast(Int
) Removes the specified number of elements from the end of the
CircularBuffer
.func removeSubrange(Range<Index>
) Removes the elements in the specified subrange from the circular buffer.
func replaceSubrange<C>(Range<Index>, with: C
) Replaces the specified subrange of elements with the given
CircularBuffer
.func reserveCapacity(Int
) Prepares the
CircularBuffer
to store the specified number of elements.
Show implementation details (4)
Hide implementation details
func _copyContents(initializing: UnsafeMutableBufferPointer<Element>
) -> (Iterator, UnsafeMutableBufferPointer<Element>.Index) func _failEarlyRangeCheck(Index, bounds: ClosedRange<Index>
) func _failEarlyRangeCheck(Index, bounds: Range<Index>
) func _failEarlyRangeCheck(Range<Index>, bounds: Range<Index>
)