CircularQueue

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

The CircularQueue provides a circular queue that can be used to store the latest 'cap' elements.

Value parameters

cap

the capacity or maximum number of elements that can be stored

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def +=(elem: A): this.type

Add element 'elem' to the front of 'this' circular queue, overwriting the oldest element when queue is full.

Add element 'elem' to the front of 'this' circular queue, overwriting the oldest element when queue is full.

Value parameters

elem

the element to add

Attributes

def dequeue(): A

Remove the oldest element from the rear of 'this' circular queue, throwing an exception when the queue is empty

Remove the oldest element from the rear of 'this' circular queue, throwing an exception when the queue is empty

Attributes

def dequeueOrNull(): A

Remove the oldest element from the rear of 'this' circular queue, returning null when the queue is empty.

Remove the oldest element from the rear of 'this' circular queue, returning null when the queue is empty.

Attributes

def enqueue(elem: A): this.type

Add element 'elem' to the front of 'this' circular queue, throwing an exeception when the queue is full.

Add element 'elem' to the front of 'this' circular queue, throwing an exeception when the queue is full.

Value parameters

elem

the element to add

Attributes

def isEmpty: Boolean

Return whether the queue is empty (i.e., has no element).

Return whether the queue is empty (i.e., has no element).

Attributes

def isFull: Boolean

Return whether the queue is full (i.e., no space left for new elements).

Return whether the queue is full (i.e., no space left for new elements).

Attributes

def size: Int

Return the current size of the queue (number of elements contained).

Return the current size of the queue (number of elements contained).

Attributes

override def toString: String

Convert 'this' circular queue into a string. FIX - also print empty slot

Convert 'this' circular queue into a string. FIX - also print empty slot

Attributes

Definition Classes
Any