PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class TQueue

TQueue class

TQueue implements a queue.

The typical queue operations are implemented, which include TQueue::enqueue(), TQueue::dequeue() and TQueue::peek(). In addition, TQueue::contains() can be used to check if an item is contained in the queue. To obtain the number of the items in the queue, check the getCount Count property.

Items in the queue may be traversed using foreach as follows,

foreach($queue as $item) ...
TComponent
Extended by TQueue implements IteratorAggregate, Countable
Package: System\Collections
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Author: Knut Urdalen <knut.urdalen@gmail.com>
Version: $Id$
Since: 3.1
Located at Collections/TQueue.php
Methods summary
public
# __construct( array|Iterator $data = null )

Constructor. Initializes the queue with an array or an iterable object.

Constructor. Initializes the queue with an array or an iterable object.

Parameters

$data
array|Iterator
the intial data. Default is null, meaning no initialization.

Throws

TInvalidDataTypeException
If data is not null and neither an array nor an iterator.

Overrides

TComponent::__construct()
public array
# toArray( )

Returns

array
the list of items in queue
public
# copyFrom( mixed $data )

Copies iterable data into the queue. Note, existing data in the list will be cleared first.

Copies iterable data into the queue. Note, existing data in the list will be cleared first.

Parameters

$data
mixed
the data to be copied from, must be an array or object implementing Traversable

Throws

TInvalidDataTypeException
If data is neither an array nor a Traversable.
public
# clear( )

Removes all items in the queue.

Removes all items in the queue.

public boolean
# contains( mixed $item )

Parameters

$item
mixed
the item

Returns

boolean
whether the queue contains the item
public mixed
# peek( )

Returns the first item at the front of the queue. Unlike TQueue::dequeue(), this method does not remove the item from the queue.

Returns the first item at the front of the queue. Unlike TQueue::dequeue(), this method does not remove the item from the queue.

Returns

mixed
item at the top of the queue

Throws

TInvalidOperationException
if the queue is empty
public mixed
# dequeue( )

Removes and returns the object at the beginning of the queue.

Removes and returns the object at the beginning of the queue.

Returns

mixed
the item at the beginning of the queue

Throws

TInvalidOperationException
if the queue is empty
public
# enqueue( mixed $item )

Adds an object to the end of the queue.

Adds an object to the end of the queue.

Parameters

$item
mixed
the item to be appended into the queue
public Iterator
# getIterator( )

Returns an iterator for traversing the items in the queue. This method is required by the interface IteratorAggregate.

Returns an iterator for traversing the items in the queue. This method is required by the interface IteratorAggregate.

Returns

Iterator
an iterator for traversing the items in the queue.

Implementation of

IteratorAggregate::getIterator()
public integer
# getCount( )

Returns

integer
the number of items in the queue
public integer
# count( )

Returns the number of items in the queue. This method is required by Countable interface.

Returns the number of items in the queue. This method is required by Countable interface.

Returns

integer
number of items in the queue.

Implementation of

Countable::count()
Methods inherited from TComponent
__call(), __destruct(), __get(), __isset(), __set(), __sleep(), __unset(), __wakeup(), addParsedObject(), asa(), attachBehavior(), attachBehaviors(), attachClassBehavior(), attachEventHandler(), canGetProperty(), canSetProperty(), clearBehaviors(), createdOnTemplate(), detachBehavior(), detachBehaviors(), detachClassBehavior(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), evaluateStatements(), fxAttachClassBehavior(), fxDetachClassBehavior(), getAutoGlobalListen(), getBehaviorsEnabled(), getClassHierarchy(), getEventHandlers(), getListeningToGlobalEvents(), getSubProperty(), hasEvent(), hasEventHandler(), hasProperty(), isa(), listen(), raiseEvent(), setSubProperty(), unlisten()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO