org.archive.queue
Interface Queue<T>

All Known Subinterfaces:
Deque

public interface Queue<T>

An Abstract queue. It should implement FIFO semantics.

Author:
gojomo

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 obj)
          Add an entry to the end of queue
 java.util.Iterator<T> getIterator(boolean inCacheOnly)
          Returns an iterator for the queue.
 boolean isEmpty()
          is the queue empty?
 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().
 

Method Detail

enqueue

void enqueue(T obj)
Add an entry to the end of queue

Parameters:
obj - the entry to queue

isEmpty

boolean isEmpty()
is the queue empty?

Returns:
true if the queue has no elements

dequeue

T dequeue()
          throws java.util.NoSuchElementException
remove an entry from the start of the queue

Returns:
the object
Throws:
java.util.NoSuchElementException

length

long length()
get the number of elements in the queue

Returns:
the number of elements in the queue

release

void release()
release any OS/IO resources associated with Queue


peek

T peek()
Give the top object in the queue, leaving it in place to be returned by future peek() or dequeue() invocations.

Returns:
top object, without removing it

unpeek

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


getIterator

java.util.Iterator<T> getIterator(boolean inCacheOnly)
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.

Parameters:
inCacheOnly -
Returns:
an iterator for the queue

deleteMatchedItems

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.

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


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