Livt packages

Livt.Collections

Version 1.4.2

Fixed-capacity FIFOs, queues, stacks, circular buffers, lists, and bit sets for Livt hardware.

Published files (62)

src/circular/ICircularBuffer.lvt

namespace Livt.Collections.Circular

/**
 * Contract for a typed fixed-capacity circular buffer.
 *
 * Writes to a full buffer overwrite the oldest value. Empty reads return the
 * element type's zero value.
 */
interface ICircularBuffer<T>
{
	/**
	 * Appends a value, overwriting the oldest value when full.
	 */
	fn Write(value: T)

	/**
	 * Removes and returns the oldest value, or zero when empty.
	 */
	fn Read() T

	/**
	 * Returns the oldest value without removing it, or zero when empty.
	 */
	fn Peek() T

	/**
	 * Returns true when the buffer contains no values.
	 */
	fn IsEmpty() bool

	/**
	 * Returns true when the buffer has reached its fixed capacity.
	 */
	fn IsFull() bool

	/**
	 * Returns the current number of buffered values.
	 */
	fn GetSize() int

	/**
	 * Resets the logical buffer state without erasing storage.
	 */
	fn Clear()
}