org.primordion.xholon.base
Interface IQueue

All Superinterfaces:
IXholon
All Known Implementing Classes:
Queue, QueueStupidModel10, QueueStupidModel11, QueueStupidModel12, QueueStupidModel13, QueueStupidModel14, QueueStupidModel15, QueueStupidModel16, QueueStupidModel16nl, QueueStupidModel9

public interface IQueue
extends IXholon

This is a generic Queue data structure that can be used to store references to any type of data. Items are added at one end of the Queue and taken off at the other end, which is why a Queue is called a First In First Out (FIFO) structure. WARNING: A Queue can fill up to maximum capacity, or it may become empty. Check the return value when calling the enqueue and dequeue functions to see if it is Q_FULL or null.

Since:
0.6 (Created on April 16, 2007)
Author:
Ken Webb

Field Summary
static int Q_FULL
           
static int Q_OK
           
 
Fields inherited from interface org.primordion.xholon.base.IXholon
DEFAULT_SIZE_MSG_Q, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx
 
Method Summary
 java.lang.Object dequeue()
          Take an object off the queue.
 int enqueue(java.lang.Object p_item)
          Add an object to the queue.
 java.util.Vector getItems()
          Get the internal item array.
 int getMaxSize()
          Get maximum number of items that can be in the queue.
 int getSize()
          Get number of items currently in the queue.
 void setMaxSize(int maxSize)
          Set the maximum number of items that can be in the queue, and allocate space for that many items.
 void shuffle()
          Randomize the order of the items in the queue.
 void sort()
          Sort the items in the queue.
 
Methods inherited from interface org.primordion.xholon.base.IXholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, sendMessage, sendMessage, sendMessage, setAttributeVal, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, treeSize, writeXml
 

Field Detail

Q_FULL

public static final int Q_FULL
See Also:
Constant Field Values

Q_OK

public static final int Q_OK
See Also:
Constant Field Values
Method Detail

enqueue

public int enqueue(java.lang.Object p_item)
Add an object to the queue.

Parameters:
p_item - The object.
Returns:
Q_OK or Q_FULL

dequeue

public java.lang.Object dequeue()
Take an object off the queue.

Returns:
An instance of Object, or null.

getSize

public int getSize()
Get number of items currently in the queue.

Returns:
Current queue size.

getMaxSize

public int getMaxSize()
Get maximum number of items that can be in the queue.

Returns:
Maximum queue size.

setMaxSize

public void setMaxSize(int maxSize)
Set the maximum number of items that can be in the queue, and allocate space for that many items. If there are already some items in the queue, then the method will atttempt to move all of them into the new internal data structure. If the new maxSize is less than the old maxSize, then some of the existing items may be lost.

Parameters:
maxSize - Maximum queue size.

shuffle

public void shuffle()
Randomize the order of the items in the queue.


sort

public void sort()
Sort the items in the queue. To use this capability, the Java class of the items in the queue must implement Comparable, with its "public int compareTo(Object o)" method.


getItems

public java.util.Vector getItems()
Get the internal item array. This should be used for debugging purposes only.

Returns:
An array of Object items.