Class Queue.UniqQImpl
All Packages Class Hierarchy This Package Previous Next Index
Class Queue.UniqQImpl
java.lang.Object
|
+----Queue.UniqQImpl
- public class UniqQImpl
- extends Object
- implements UniqueQueue
Class UniqQImpl implements the interface UniqueQueue.
Operations on the queue are synchronized to allow
concurrent access.
- See Also:
- Queue
-
hash_table
- item hash table
-
head_node
- refers to the head node
-
num_elem
- keep track of queue size
-
tail_node
- refers to the tail node
-
UniqQImpl()
- Constructor, creates an empty queue.
-
clone()
- Returns a shallow copy of the queue.
-
elements()
- Returns an enumeration of the elements in the queue.
-
firstElement()
- Returns the first element of the queue without removing the
element.
-
insertFirst(Object)
- Insert the specified element into the front of the queue.
-
insertLast(Object)
- Insert the specified element into the back of the queue.
-
isInside(Object)
- Returns true if the specified element is inside the queue.
-
lastElement()
- Returns the last element of the queue without removing the
element.
-
removeElement(Object)
- Remove the specified element from the queue.
-
removeFirst()
- Remove and return an element from the front of the queue.
-
removeLast()
- Remove and return an element from the back of the queue.
-
size()
- Returns the number of elements in the queue.
num_elem
protected int num_elem
- keep track of queue size
head_node
protected QNodeImpl head_node
- refers to the head node
tail_node
protected QNodeImpl tail_node
- refers to the tail node
hash_table
protected Hashtable hash_table
- item hash table
UniqQImpl
public UniqQImpl()
- Constructor, creates an empty queue.
lastElement
public synchronized Object lastElement() throws NoSuchElementException
- Returns the last element of the queue without removing the
element.
- Returns:
- the last element
firstElement
public synchronized Object firstElement() throws NoSuchElementException
- Returns the first element of the queue without removing the
element.
- Returns:
- the first element
insertFirst
public synchronized void insertFirst(Object elem)
- Insert the specified element into the front of the queue.
- Parameters:
- elem - element to be inserted
insertLast
public synchronized void insertLast(Object elem)
- Insert the specified element into the back of the queue.
- Parameters:
- elem - element to be inserted
removeFirst
public synchronized Object removeFirst() throws NoSuchElementException
- Remove and return an element from the front of the queue.
- Returns:
- the element at the front of the queue
- Throws: NoSuchElementException
- thrown when there are no
elements in the queue
removeLast
public synchronized Object removeLast() throws NoSuchElementException
- Remove and return an element from the back of the queue.
- Returns:
- the element at the back of the queue
- Throws: NoSuchElementException
- thrown when there are no
elements in the queue
size
public synchronized int size()
- Returns the number of elements in the queue.
elements
public synchronized Enumeration elements()
- Returns an enumeration of the elements in the queue.
- Returns:
- the enumeration
- See Also:
- Enumeration
clone
public synchronized Object clone()
- Returns a shallow copy of the queue.
- Overrides:
- clone in class Object
- See Also:
- clone
isInside
public synchronized boolean isInside(Object element)
- Returns true if the specified element is inside the queue.
False is returned otherwise.
- Parameters:
- element - the specified element
- Returns:
- true or false
removeElement
public synchronized void removeElement(Object element) throws NoSuchElementException
- Remove the specified element from the queue. If the element
is not inside the queue, then exception NoSuchElementException
will be thrown.
- Parameters:
- element - the specified element
- Throws: NoSuchElementException
- thrown when specified element
is not inside the queue.
All Packages Class Hierarchy This Package Previous Next Index