T
- Type of the item's to add in this queuepublic class CircularLossyQueue<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicReference<T>[] |
circularArray |
private java.util.concurrent.atomic.AtomicLong |
currentIndex |
private int |
maxSize |
Constructor and Description |
---|
CircularLossyQueue(int size)
Constructs the circular queue with the specified capacity
|
Modifier and Type | Method and Description |
---|---|
int |
depth()
Returns the number of items currently in the queue
|
private int |
getCurrentIndex() |
private int |
getIndex(int index) |
boolean |
isEmtpy()
Returns true if the queue is empty, otherwise false
|
T |
peek()
Returns value at the tail of the queue
|
void |
push(T newVal)
Adds a new item
|
T[] |
toArray(T[] type)
Returns an array of the current elements in the queue.
|
private final java.util.concurrent.atomic.AtomicReference<T>[] circularArray
private final int maxSize
private final java.util.concurrent.atomic.AtomicLong currentIndex
public CircularLossyQueue(int size)
size
- public void push(T newVal)
newVal
- public T[] toArray(T[] type)
type
- private int getIndex(int index)
public T peek()
public boolean isEmtpy()
private int getCurrentIndex()
public int depth()