## Class TQueue

Description

Implements interfaces:

TQueue class

TQueue implements a queue.

The typical queue operations are implemented, which include enqueue(), dequeue() and peek(). In addition, 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 Count property.

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

     foreach($queue as $item) ...

- since: 3.1
- version: $Id$
- author: Qiang Xue <qiang.xue@gmail.com>
- author: Knut Urdalen <knut.urdalen@gmail.com>

Located in /Collections/TQueue.php (line 35)

    TComponent
       |
       --TQueue

Method Summary
TQueue __construct ([array|Iterator $data = null])
void clear ()
boolean contains (mixed $item)
void copyFrom (mixed $data)
integer count ()
mixed dequeue ()
void enqueue (mixed $item)
integer getCount ()
Iterator getIterator ()
mixed peek ()
array toArray ()
Methods
Constructor __construct (line 54)

Constructor.

Initializes the queue with an array or an iterable object.

- access: public
- throws: TInvalidDataTypeException If data is not null and neither an array nor an iterator.

TQueue __construct ([array|Iterator $data = null])

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

clear (line 92)

Removes all items in the queue.

- access: public

void clear ()
contains (line 102)

- return: whether the queue contains the item
- access: public

boolean contains (mixed $item)

- mixed $item: the item

copyFrom (line 74)

Copies iterable data into the queue.

Note, existing data in the list will be cleared first.

- access: public
- throws: TInvalidDataTypeException If data is neither an array nor a Traversable.

void copyFrom (mixed $data)

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

count (line 170)

Returns the number of items in the queue.

This method is required by Countable interface.

- return: number of items in the queue.
- access: public

integer count ()
dequeue (line 126)

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

- return: the item at the beginning of the queue
- access: public
- throws: TInvalidOperationException if the queue is empty

mixed dequeue ()
enqueue (line 141)

Adds an object to the end of the queue.

- access: public

void enqueue (mixed $item)

- mixed $item: the item to be appended into the queue

getCount (line 160)

- return: the number of items in the queue
- access: public

integer getCount ()
getIterator (line 152)

Returns an iterator for traversing the items in the queue.

This method is required by the interface IteratorAggregate.

- return: an iterator for traversing the items in the queue.
- access: public

Iterator getIterator ()
peek (line 113)

Returns the item at the top of the queue.

Unlike pop(), this method does not remove the item from the queue.

- return: item at the top of the queue
- access: public
- throws: TInvalidOperationException if the queue is empty

mixed peek ()
toArray (line 63)

- return: the list of items in queue
- access: public

array toArray ()

#### Inherited Methods

Inherited From TComponent

> TComponent::addParsedObject()
> TComponent::attachEventHandler()
> TComponent::canGetProperty()
> TComponent::canSetProperty()
> TComponent::createdOnTemplate()
> TComponent::detachEventHandler()
> TComponent::evaluateExpression()
> TComponent::evaluateStatements()
> TComponent::getEventHandlers()
> TComponent::getSubProperty()
> TComponent::hasEvent()
> TComponent::hasEventHandler()
> TComponent::hasProperty()
> TComponent::raiseEvent()
> TComponent::setSubProperty()
> TComponent::__get()
> TComponent::__set()

Documentation generated on Mon, 21 Apr 2008 11:35:54 -0400 by phpDocumentor 1.3.0RC4