Class IndirectPriorityQueues.SynchronizedIndirectPriorityQueue<K>
- All Implemented Interfaces:
IndirectPriorityQueue<K>
- Enclosing class:
IndirectPriorityQueues
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidNotifies this queue that the all elements have changed (optional operation).voidchanged()Notifies this queue that the first element has changed (optional operation).voidchanged(int i) Notifies this queue that the specified element has changed (optional operation).voidclear()Removes all elements from this queue.Comparator<? super K> Returns the comparator associated with this queue, ornullif it uses its elements' natural ordering.booleancontains(int index) Checks whether a given index belongs to this queue (optional operation).intdequeue()Dequeues the first element from this queue.voidenqueue(int x) Enqueues a new element.intfirst()Returns the first element of this queue.intfront(int[] a) Retrieves the front of this queue in a given array (optional operation).booleanisEmpty()Checks whether this queue is empty.intlast()Returns the last element of this queue, that is, the element the would be dequeued last (optional operation).booleanremove(int i) Removes the specified element from this queue (optional operation).intsize()Returns the number of elements in this queue.
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
-
Method Details
-
enqueue
public void enqueue(int x) Description copied from interface:IndirectPriorityQueueEnqueues a new element.- Specified by:
enqueuein interfaceIndirectPriorityQueue<K>- Parameters:
x- the element to enqueue.
-
dequeue
public int dequeue()Description copied from interface:IndirectPriorityQueueDequeues the first element from this queue.- Specified by:
dequeuein interfaceIndirectPriorityQueue<K>- Returns:
- the dequeued element.
-
contains
public boolean contains(int index) Description copied from interface:IndirectPriorityQueueChecks whether a given index belongs to this queue (optional operation).This default implementation just throws an
UnsupportedOperationException.- Specified by:
containsin interfaceIndirectPriorityQueue<K>- Parameters:
index- an index possibly in the queue.- Returns:
- true if the specified index belongs to this queue.
-
first
public int first()Description copied from interface:IndirectPriorityQueueReturns the first element of this queue.- Specified by:
firstin interfaceIndirectPriorityQueue<K>- Returns:
- the first element.
-
last
public int last()Description copied from interface:IndirectPriorityQueueReturns the last element of this queue, that is, the element the would be dequeued last (optional operation).This default implementation just throws an
UnsupportedOperationException.- Specified by:
lastin interfaceIndirectPriorityQueue<K>- Returns:
- the last element.
-
isEmpty
public boolean isEmpty()Description copied from interface:IndirectPriorityQueueChecks whether this queue is empty.This default implementation checks whether
IndirectPriorityQueue.size()is zero.- Specified by:
isEmptyin interfaceIndirectPriorityQueue<K>- Returns:
- true if this queue is empty.
-
size
public int size()Description copied from interface:IndirectPriorityQueueReturns the number of elements in this queue.- Specified by:
sizein interfaceIndirectPriorityQueue<K>- Returns:
- the number of elements in this queue.
-
clear
public void clear()Description copied from interface:IndirectPriorityQueueRemoves all elements from this queue.- Specified by:
clearin interfaceIndirectPriorityQueue<K>
-
changed
public void changed()Description copied from interface:IndirectPriorityQueueNotifies this queue that the first element has changed (optional operation).This default implementation just calls
IndirectPriorityQueue.changed(int)with argumentIndirectPriorityQueue.first().- Specified by:
changedin interfaceIndirectPriorityQueue<K>
-
allChanged
public void allChanged()Description copied from interface:IndirectPriorityQueueNotifies this queue that the all elements have changed (optional operation).This default implementation just throws an
UnsupportedOperationException.- Specified by:
allChangedin interfaceIndirectPriorityQueue<K>
-
changed
public void changed(int i) Description copied from interface:IndirectPriorityQueueNotifies this queue that the specified element has changed (optional operation).Note that the specified element must belong to this queue.
This default implementation just throws an
UnsupportedOperationException.- Specified by:
changedin interfaceIndirectPriorityQueue<K>- Parameters:
i- the element that has changed.
-
remove
public boolean remove(int i) Description copied from interface:IndirectPriorityQueueRemoves the specified element from this queue (optional operation).This default implementation just throws an
UnsupportedOperationException.- Specified by:
removein interfaceIndirectPriorityQueue<K>- Parameters:
i- the element to be removed.- Returns:
- true if the index was in the queue.
-
comparator
Description copied from interface:IndirectPriorityQueueReturns the comparator associated with this queue, ornullif it uses its elements' natural ordering.- Specified by:
comparatorin interfaceIndirectPriorityQueue<K>- Returns:
- the comparator associated with this sorted set, or
nullif it uses its elements' natural ordering.
-
front
public int front(int[] a) Description copied from interface:IndirectPriorityQueueRetrieves the front of this queue in a given array (optional operation).The front of an indirect queue is the set of indices whose associated elements in the reference array are equal to the element associated to the first index. These indices can be always obtain by dequeueing, but this method should retrieve efficiently such indices in the given array without modifying the state of this queue.
This default implementation just throws an
UnsupportedOperationException.- Specified by:
frontin interfaceIndirectPriorityQueue<K>- Parameters:
a- an array large enough to hold the front (e.g., at least long as the reference array).- Returns:
- the number of elements actually written (starting from the first position of
a).
-