writeattributes
Class AddressEdit.PriorityQueue

java.lang.Object
  extended by writeattributes.AddressEdit.PriorityQueue
Enclosing class:
AddressEdit

private class AddressEdit.PriorityQueue
extends java.lang.Object

Priority queue used to order the writing of attributes.

This queue stores AttributeRegions in tab order. Queue elements are accessible randomly by index, and in either the forward or reverse direction using a queue iterator.

The index is a partial order on the queue contents, so that for all queue indices i and j:

q.get(i).getRow() < q.get(j).getRow if and only if i < j.


Nested Class Summary
private  class AddressEdit.PriorityQueue.PQIterator
          Priority queue iterator.
 
Field Summary
private  int generation
          Counter which is incremented whenever a change is made to the queue.
private  java.util.ArrayList queue
          The priority queue.
 
Constructor Summary
AddressEdit.PriorityQueue()
          Create a default-sized queue.
AddressEdit.PriorityQueue(int size)
          Create a queue with a given initial size.
 
Method Summary
 void add(AddressEdit.AttributeRegion ar)
          Insert an element into the queue in index order.
 AddressEdit.AttributeRegion get(int index)
          Return the queue element with the given index.
 int getGeneration()
          Return the generation of the queue.
 java.util.Iterator queueIterator(int direction)
          Return iterator over the queue contents.
 int size()
          Return the queue size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

private final java.util.ArrayList queue
The priority queue.

The queue order reflects the tab order on the screen. In this case the tab order is given by the row number of each attribute's position.


generation

private int generation
Counter which is incremented whenever a change is made to the queue.

Constructor Detail

AddressEdit.PriorityQueue

public AddressEdit.PriorityQueue()
Create a default-sized queue.


AddressEdit.PriorityQueue

public AddressEdit.PriorityQueue(int size)
Create a queue with a given initial size.

Parameters:
size - initial queue size
Method Detail

add

public void add(AddressEdit.AttributeRegion ar)
Insert an element into the queue in index order.

This implementation assumes small-sized queues, so a simple linear insertion algorithm is used.

Parameters:
ar - the attribute and region to be inserted

getGeneration

public int getGeneration()
Return the generation of the queue.

Returns:
number of modifications since queue was created

queueIterator

public java.util.Iterator queueIterator(int direction)
Return iterator over the queue contents.

Parameters:
direction - negative to iterate from high to low, else low to high
Returns:
iterator for this queue

size

public int size()
Return the queue size.

Returns:
number of elements in queue.

get

public AddressEdit.AttributeRegion get(int index)
Return the queue element with the given index.

Parameters:
index - index number (0 <= index < queue.size())
Returns:
attribute region at that index
Throws:
java.lang.IllegalArgumentException - if index out of range