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,

  1. foreach($queue as $item) ...

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

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

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 91)

Removes all items in the queue.

  • access: public
void clear ()
contains (line 101)
  • return: whether the queue contains the item
  • access: public
boolean contains (mixed $item)
  • mixed $item: the item
copyFrom (line 73)

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
dequeue (line 125)

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 140)

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 159)
  • return: the number of items in the queue
  • access: public
integer getCount ()
getIterator (line 151)

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 112)

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 62)
  • 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 Sun, 14 Jan 2007 21:43:55 -0500 by phpDocumentor 1.3.0RC4