org.archive.queue
Class DiskBackedDeque

java.lang.Object
  extended by org.archive.queue.DiskBackedQueue
      extended by org.archive.queue.DiskBackedDeque
All Implemented Interfaces:
java.io.Serializable, Deque, Queue, Stack

public class DiskBackedDeque
extends DiskBackedQueue
implements Deque, java.io.Serializable

Author:
gojomo
See Also:
Serialized Form

Field Summary
protected  DiskStack stack
           
 
Fields inherited from class org.archive.queue.DiskBackedQueue
DISCARD_BACKING_THRESHOLD, headMax, headQ, name, tailQ
 
Constructor Summary
DiskBackedDeque(java.io.File dir, java.lang.String name, boolean reuse, int headMax)
           
 
Method Summary
protected  java.lang.Object backingDequeue()
           
 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.
protected  void discardBacking()
           
 void disconnect()
          Release any file-handles in arecoverable way.
 java.util.Iterator getIterator(boolean inCacheOnly)
          Returns an iterator for the queue.
protected  int headTargetSize()
           
 long height()
          Number of items in the Stack.
 boolean isEmpty()
          is the queue empty?
 long length()
          get the number of elements in the queue
 int memoryLoad()
           
 java.lang.Object peek()
          Give the top object in the queue, leaving it in place to be returned by future peek() or dequeue() invocations.
 java.lang.Object pop()
          Remove and return item from top of Stack
 void push(java.lang.Object object)
          Add object to top of Stack
 void setHeadMax(int hm)
          Set the number of items to keep in memory, and adjust current head to match.
 
Methods inherited from class org.archive.queue.DiskBackedQueue
backingUpdate, canDiscardBacking, dequeue, enqueue, fillHeadQ, release, unpeek
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.archive.queue.Queue
dequeue, enqueue, release, unpeek
 
Methods inherited from interface org.archive.queue.Stack
release
 

Field Detail

stack

protected DiskStack stack
Constructor Detail

DiskBackedDeque

public DiskBackedDeque(java.io.File dir,
                       java.lang.String name,
                       boolean reuse,
                       int headMax)
                throws java.io.IOException
Parameters:
dir -
name -
reuse -
headMax -
Throws:
java.io.IOException
Method Detail

push

public void push(java.lang.Object object)
Description copied from interface: Stack
Add object to top of Stack

Specified by:
push in interface Stack

setHeadMax

public void setHeadMax(int hm)
Set the number of items to keep in memory, and adjust current head to match.

Overrides:
setHeadMax in class DiskBackedQueue
Parameters:
hm -

pop

public java.lang.Object pop()
Description copied from interface: Stack
Remove and return item from top of Stack

Specified by:
pop in interface Stack
Returns:
Item removed from top of Stack

peek

public java.lang.Object 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 Queue
Specified by:
peek in interface Stack
Overrides:
peek in class DiskBackedQueue
Returns:
top object, without removing it
See Also:
Queue.peek()

height

public long height()
Description copied from interface: Stack
Number of items in the Stack.

Specified by:
height in interface Stack

backingDequeue

protected java.lang.Object backingDequeue()
Overrides:
backingDequeue in class DiskBackedQueue
Returns:
backing dequeue queue instance.

discardBacking

protected void discardBacking()
Overrides:
discardBacking in class DiskBackedQueue

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.

Specified by:
deleteMatchedItems in interface Queue
Overrides:
deleteMatchedItems in class DiskBackedQueue
Parameters:
matcher - a predicate
Returns:
the number of deleted items
See Also:
Queue.deleteMatchedItems(org.apache.commons.collections.Predicate)

getIterator

public java.util.Iterator 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.

Specified by:
getIterator in interface Queue
Overrides:
getIterator in class DiskBackedQueue
Returns:
an iterator for the queue
See Also:
Queue.getIterator(boolean)

headTargetSize

protected int headTargetSize()
Overrides:
headTargetSize in class DiskBackedQueue
Returns:
Maximum size of head queue.

isEmpty

public boolean isEmpty()
Description copied from interface: Queue
is the queue empty?

Specified by:
isEmpty in interface Queue
Specified by:
isEmpty in interface Stack
Overrides:
isEmpty in class DiskBackedQueue
Returns:
true if the queue has no elements
See Also:
Queue.isEmpty()

length

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

Specified by:
length in interface Queue
Overrides:
length in class DiskBackedQueue
Returns:
the number of elements in the queue
See Also:
Queue.length()

disconnect

public void disconnect()
Description copied from class: DiskBackedQueue
Release any file-handles in arecoverable way.

Overrides:
disconnect in class DiskBackedQueue

memoryLoad

public int memoryLoad()
Returns:
Memory load.


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