joeq.Allocator
Class CircularAddressQueue

java.lang.Object
  extended by joeq.Allocator.CircularAddressQueue
All Implemented Interfaces:
AddressQueue

public class CircularAddressQueue
extends Object
implements AddressQueue

An implementation of an address queue that uses a circular buffer.

Version:
$Id: CircularAddressQueue.java,v 1.5 2004/09/30 03:35:30 joewhaley Exp $
Author:
John Whaley

Field Summary
static int QUEUE_WORDS
          Size of block (in words) to allocate when we need more space in a queue.
static boolean TRACE
           
 
Constructor Summary
CircularAddressQueue()
          Create a new CircularAddressQueue.
 
Method Summary
 void free()
          Free the memory associated with this reference queue.
 void growQueue(int words)
          Grows the queue to the specified size in words.
 Address peek()
          Returns the first address from this queue, or null if the queue is empty.
 Address pull()
          Returns and removes an address from this queue, or returns null if the queue is empty.
 void push(Address a)
          Add the given address to the reference queue.
 int size()
          Return the number of elements in this queue.
 int space()
          Return the amount of free space (in words) in this queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE

public static final boolean TRACE
See Also:
Constant Field Values

QUEUE_WORDS

public static int QUEUE_WORDS
Size of block (in words) to allocate when we need more space in a queue.

Constructor Detail

CircularAddressQueue

public CircularAddressQueue()
Create a new CircularAddressQueue. Does not allocate any memory yet.

Method Detail

free

public void free()
Description copied from interface: AddressQueue
Free the memory associated with this reference queue.

Specified by:
free in interface AddressQueue

growQueue

public void growQueue(int words)
Description copied from interface: AddressQueue
Grows the queue to the specified size in words.

Specified by:
growQueue in interface AddressQueue

size

public int size()
Description copied from interface: AddressQueue
Return the number of elements in this queue.

Specified by:
size in interface AddressQueue
Returns:
number of elements in this queue

space

public int space()
Description copied from interface: AddressQueue
Return the amount of free space (in words) in this queue.

Specified by:
space in interface AddressQueue
Returns:
amount of free space (in words) in this queue

push

public void push(Address a)
Description copied from interface: AddressQueue
Add the given address to the reference queue.

Specified by:
push in interface AddressQueue
Parameters:
a - address to add

pull

public Address pull()
Description copied from interface: AddressQueue
Returns and removes an address from this queue, or returns null if the queue is empty.

Specified by:
pull in interface AddressQueue
Returns:
address, or null if queue is empty

peek

public Address peek()
Description copied from interface: AddressQueue
Returns the first address from this queue, or null if the queue is empty.

Specified by:
peek in interface AddressQueue
Returns:
address, or null if queue is empty


Copyright © 2001-2005 John Whaley. All Rights Reserved.