org.archive.queue
Class MemQueue<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<T>
                  extended by org.archive.queue.MemQueue<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Deque<T>, java.util.List<T>, java.util.Queue<T>

public class MemQueue<T>
extends java.util.LinkedList<T>
implements Queue<T>

An in-memory implementation of a Queue.

Author:
Gordon Mohr
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
MemQueue()
          Create a new, empty MemQueue
 
Method Summary
 long deleteMatchedItems(org.apache.commons.collections.Predicate matcher)
          All objects in the queue where matcher.match(object) returns true will be deleted from the queue.
 T dequeue()
          remove an entry from the start of the queue
 void enqueue(T o)
          Add an entry to the end of queue
 java.util.Iterator<T> getIterator(boolean inCacheOnly)
          Returns an iterator for the queue.
 long length()
          get the number of elements in the queue
 T peek()
          Give the top object in the queue, leaving it in place to be returned by future peek() or dequeue() invocations.
 void release()
          release any OS/IO resources associated with Queue
 void unpeek()
          Releases queue from the obligation to return in the next peek()/dequeue() the same object as returned by any previous peek().
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.archive.queue.Queue
isEmpty
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 
Methods inherited from interface java.util.Deque
iterator
 

Constructor Detail

MemQueue

public MemQueue()
Create a new, empty MemQueue

Method Detail

enqueue

public void enqueue(T o)
Description copied from interface: Queue
Add an entry to the end of queue

Parameters:
o - the entry to queue
See Also:
Queue.enqueue(Object)

dequeue

public T dequeue()
Description copied from interface: Queue
remove an entry from the start of the queue

Returns:
the object
See Also:
Queue.dequeue()

length

public long length()
Description copied from interface: Queue
get the number of elements in the queue

Returns:
the number of elements in the queue
See Also:
Queue.length()

release

public void release()
Description copied from interface: Queue
release any OS/IO resources associated with Queue

See Also:
Queue.release()

peek

public T peek()
Description copied from interface: Queue
Give the top object in the queue, leaving it in place to be returned by future peek() or dequeue() invocations.

Specified by:
peek in interface java.util.Deque<T>
Specified by:
peek in interface java.util.Queue<T>
Overrides:
peek in class java.util.LinkedList<T>
Returns:
top object, without removing it
See Also:
Queue.peek()

getIterator

public java.util.Iterator<T> getIterator(boolean inCacheOnly)
Description copied from interface: Queue
Returns an iterator for the queue.

The returned iterator's remove method is considered unsafe.

Editing the queue while using the iterator is not safe.

Returns:
an iterator for the queue
See Also:
Queue.getIterator(boolean)

deleteMatchedItems

public long deleteMatchedItems(org.apache.commons.collections.Predicate matcher)
Description copied from interface: Queue
All objects in the queue where matcher.match(object) returns true will be deleted from the queue.

Making other changes to the queue while this method is being processed is not safe.

Parameters:
matcher - a predicate
Returns:
the number of deleted items
See Also:
Queue.deleteMatchedItems(org.apache.commons.collections.Predicate)

unpeek

public void unpeek()
Description copied from interface: Queue
Releases queue from the obligation to return in the next peek()/dequeue() the same object as returned by any previous peek().



Copyright © 2003-2011 Internet Archive. All Rights Reserved.