Ring

scalation.Ring
class Ring[A](cap: Int, zero: A)(implicit evidence$1: ClassTag[A])

The Ring class provides a circular array that can be used to store the latest cap elements. Example to add elements 1, 2, 3, 4, 5, 6, 7 keeping the most recebt 5: [ 1, 2, 3, 4, 5 ] f = 0, l = 4 [ 6, 7, 3, 4, 5 ] f = 2, l = 1

Value parameters

cap

the capacity or maximum number of elements that can be stored

zero

an element that indicates zero for type A

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def add(elem: A): Unit

Add an element into the next available location which will be either the next open location or the oldest location in use (over-writing the element at that location).

Add an element into the next available location which will be either the next open location or the oldest location in use (over-writing the element at that location).

Value parameters

elem

the next element to be added to the ring

Attributes

def apply(i: Int): A

Return the i-th element in logical order [ old, ..., recent ]. Calling apply(0) returns the oldest element stored.

Return the i-th element in logical order [ old, ..., recent ]. Calling apply(0) returns the oldest element stored.

Value parameters

i

the logical index

Attributes

def reset(): Unit

Reset/clear the ring.

Reset/clear the ring.

Attributes

def show(): Unit

Show/print the elements in the ring in logical order.

Show/print the elements in the ring in logical order.

Attributes

override def toString: String

Convert this ring into a string showing the storage/physical view.

Convert this ring into a string showing the storage/physical view.

Attributes

Definition Classes
Any
def update(i: Int, elem: A): Unit

Update the i-th element in logical order [ old, ..., recent ]. Calling apply(0) returns the oldest element stored.

Update the i-th element in logical order [ old, ..., recent ]. Calling apply(0) returns the oldest element stored.

Value parameters

elem

the element to be assigned

i

the logical index

Attributes