8.18
top
← prev up next →

Ring BuffersπŸ”— i

Jay McCarthy <jay@racket-lang.org>

This package defines an imperative, overwritting ring buffer that holds a finite number of elements and may be used as a sequence.

procedure

( ring-buffer? v)boolean?

v:any/c
Determines if v is a ring buffer.

procedure

( empty-ring-buffer max)ring-buffer?

Constructs an empty ring buffer that may hold max elements.

Returns the length of rb.

procedure

( ring-buffer-push! rbv)void?

Pushes v on to the end of rb, potentially pushing the first element of rb off.

Examples:
> (for/list ([vrb])v)

'(1 2 3)

> (for/list ([vrb])v)

'(2 3 4)

procedure

( ring-buffer-pop! rb)(and/c any/c (not/c false/c ))

Pops a value from the end of rb.

Examples:
> (for/list ([vrb])v)

'(1 2 3)

3

> (for/list ([vrb])v)

'(1 2)

> (for/list ([vrb])v)

'(1 2 4)

procedure

( ring-buffer-ref rbi)(or/c any/c false/c )

Returns the value in the ith position of rb.

This interacts with ring-buffer-push! .

Examples:
> (for/list ([vrb])v)

'(1 2 3)

2

3

procedure

( ring-buffer-set! rbiv)void?

Sets the value in the ith position of rb to v

This interacts with ring-buffer-push! .

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /