SizedQueue

Package: MachII.util
Inherits from: util.Queue
A specialization of Queue to limit size.
Method Summary
public SizedQueue init([numeric maxSize="100"])

Initializes the queue.

public numeric getMaxSize()

Returns the maximum size of the queue.

public boolean isFull()

Returns whether or not the queue is full.

public void put(any item)

Queues the item.

public void setMaxSize(numeric maxSize)

Sets the maximum size of the queue.

Methods inherited from util.Queue:   peek , isEmpty , getSize , get , clear
Method Detail
getMaxSize

public numeric getMaxSize( )

Returns the maximum size of the queue.

Parameters:

Code:

	<cffunction name="getMaxSize" access="public" returntype="numeric" output="false"
		hint="Returns the maximum size of the queue.">
		<cfreturn variables.maxSize />
	</cffunction> 

init

public SizedQueue init( [numeric maxSize="100"] )

Initializes the queue.

Parameters:
[numeric maxSize="100"]

Code:

	<cffunction name="init" access="public" returntype="SizedQueue" output="false"
		hint="Initializes the queue.">
		<cfargument name="maxSize" type="numeric" required="false" default="100" />
		
		<cfset super.init() />
		<cfset setMaxSize(arguments.maxSize) />
		
		<cfreturn this />
	</cffunction> 

isFull

public boolean isFull( )

Returns whether or not the queue is full.

Parameters:

Code:

	<cffunction name="isFull" access="public" returntype="boolean" output="false"
		hint="Returns whether or not the queue is full.">
		<cfreturn getSize() EQ getMaxSize() />
	</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" />
		
		<cfif NOT isFull()>
			<cfset super.put(arguments.item) />
		<cfelse>
			<cfthrow message="Max size of SizedQueue is #getMaxSize()# and has been exceeded." />
		</cfif>
	</cffunction> 

setMaxSize

public void setMaxSize( numeric maxSize )

Sets the maximum size of the queue.

Parameters:
numeric maxSize

Code:

	<cffunction name="setMaxSize" access="public" returntype="void" output="false"
		hint="Sets the maximum size of the queue.">
		<cfargument name="maxSize" type="numeric" required="true" />
		<cfset variables.maxSize = arguments.maxSize />
	</cffunction>