Queue

Package: MachII.util
A simple Queue component.
Method Summary
public Queue init()

Initializes the queue.

public void clear()

Clears the queue.

public any get()

Dequeues and returns the next item in the queue.

public numeric getSize()

Returns the size of the queue (number of elements).

public boolean isEmpty()

Returns whether or not the queue is empty.

public any peek()

Peeks the next item in the queue without removing it.

public void put(any item)

Queues the item.

Method Detail
clear

public void clear( )

Clears the queue.

Parameters:

Code:

	<cffunction name="clear" access="public" returntype="void" output="false"
		hint="Clears the queue.">
		<cfset ArrayClear(variables.queueArray) />
	</cffunction> 

get

public any get( )

Dequeues and returns the next item in the queue.

Parameters:

Code:

	<cffunction name="get" access="public" returntype="any" output="false"
		hint="Dequeues and returns the next item in the queue.">
		<cfset var nextItem = variables.queueArray[1] />
		<cfset ArrayDeleteAt(variables.queueArray, 1) />
		<cfreturn nextItem />
	</cffunction> 

getSize

public numeric getSize( )

Returns the size of the queue (number of elements).

Parameters:

Code:

	<cffunction name="getSize" access="public" returntype="numeric" output="false"
		hint="Returns the size of the queue (number of elements).">
		<cfreturn ArrayLen(variables.queueArray) />
	</cffunction> 

init

public Queue init( )

Initializes the queue.

Parameters:

Code:

	<cffunction name="init" access="public" returntype="Queue" output="false"
		hint="Initializes the queue.">
		<cfreturn this />
	</cffunction> 

isEmpty

public boolean isEmpty( )

Returns whether or not the queue is empty.

Parameters:

Code:

	<cffunction name="isEmpty" access="public" returntype="boolean" output="false"
		hint="Returns whether or not the queue is empty.">
		<cfreturn getSize() EQ 0 />
	</cffunction> 

peek

public any peek( )

Peeks the next item in the queue without removing it.

Parameters:

Code:

	<cffunction name="peek" access="public" returntype="any" output="false"
		hint="Peeks the next item in the queue without removing it.">
		<cfreturn variables.queueArray[1] />
	</cffunction> 

put

public void put( any item )

Queues the item.

Parameters:
any item

Code:

	<cffunction name="put" access="public" returntype="void" output="false"
		hint="Queues the item.">
		<cfargument name="item" type="any" required="true" />
		<cfset ArrayAppend(variables.queueArray, arguments.item) />
	</cffunction>