| Package: MachII.util |
| Inherits from: util.Queue |
| A specialization of Queue to limit size. |
<!--- License: Copyright 2006 Mach-II Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: Mach-II Corporation Author: Ben Edwards (ben@ben-edwards.com) $Id: SizedQueue.cfc 4352 2006-08-29 20:35:15Z pfarrell $ Created version: 1.0.0 ---> |
| 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. |
| 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 |
|---|
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>