Spec-Zone.ru › Pony

RingBuffer[A: A]

[Source]

A ring buffer.

class ref RingBuffer[A: A]

Constructors

create

[Source]

Create a ring buffer with a fixed size. The size will be rounded up to the next power of 2.

new ref create(
  len: USize val)
: RingBuffer[A] ref^

Parameters

  • len: USize val

Returns

  • RingBuffer[A] ref^

Public Functions

head

[Source]

The first read that will succeed. If nothing has been written to the ring, this will raise an error.

fun box head()
: USize val ?

Returns

  • USize val ?

size

[Source]

The number of elements that have been added to the ring.

fun box size()
: USize val

Returns

  • USize val

space

[Source]

The available space in the ring.

fun box space()
: USize val

Returns

  • USize val

apply

[Source]

Get the i-th element from the ring. If the i-th element has not yet been added or is no longer available, this will raise an error.

fun box apply(
  i: USize val)
: this->A ?

Parameters

  • i: USize val

Returns

  • this->A ?

push

[Source]

Add an element to the ring. If the ring is full, this will drop the oldest element in the ring. Returns true if an element was dropped.

fun ref push(
  value: A)
: Bool val

Parameters

  • value: A

Returns

  • Bool val

clear

[Source]

Clear the queue.

fun ref clear()
: None val

Returns

  • None val

© 2016-2020, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/collections-RingBuffer

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API