public class CircularQueue<E> extends Object
Constructor and Description |
---|
CircularQueue(int size) |
Modifier and Type | Method and Description |
---|---|
boolean |
addFirst(E e)
Put a new element at the head of the queue.
|
boolean |
addLast(E e)
Put a new element at the tail of the queue.
|
void |
clear()
Removes all the content of the queue
|
E |
get(int index)
Get the
index element of the queue, 0 being the last element |
int |
indexOf(E elem)
Search an element equal to the parameter in the
CircularQueue , and return its index (0 is the last element) |
boolean |
isEmpty() |
E |
pollFirst()
Removes the first element of the queue and returns it
This method is the main reason we re-wrote the class. |
E |
pollLast()
Removes the last element of the queue and returns it
This method is the main reason we re-wrote the class. |
E |
remove()
This method is the main reason we re-wrote the class.
|
boolean |
remove(E e)
Remove the first element equal to the value given as parameter
|
E |
remove(int index)
Removes the
index element of the queue and removes the resulting gap
This method is the main reason we re-wrote the class. |
int |
size()
Get the current number of elements
|
public boolean isEmpty()
public void clear()
public int size()
public E get(int index)
index
element of the queue, 0 being the last elementindex
- index of the element to retrieveindexOf(Object)
public boolean addFirst(E e)
CircularQueue
grows by itself if it reaches its max capacitye
- element to addpublic boolean addLast(E e)
CircularQueue
grows by itself if it reaches its max capacitye
- element to addpublic int indexOf(E elem)
CircularQueue
, and return its index (0 is the last element)elem
- element to query in the CircularQueue
CircularQueue
, -1 if the element does not existspublic E pollFirst()
public E pollLast()
public E remove()
public E remove(int index)
index
element of the queue and removes the resulting gap
index
- indexOf(Object)
public boolean remove(E e)
e
- value to remove from the CircularQueue
Copyright © 2018. All rights reserved.