TPriorityList class
TPriorityList implements a priority ordered list collection class. It allows you to specify any numeric for priorities down to a specific precision. The lower the numeric, the high the priority of the item in the list. Thus -10 has a higher priority than -5, 0, 10 (the default), 18, 10005, etc. Per http://www.php.net/round, precision may be negative and thus rounding can go by 10, 100, 1000, etc, instead of just .1, .01, .001, etc. The default precision allows for 8 decimal places. There is also a default priority of 10, if no different default priority is specified or no item specific priority is indicated. If you replace TList with this class it will work exactly the same with items inserted set to the default priority, until you start using different priorities than the default priority.
As you access the PHP array features of this class, it flattens and caches the results. If at all possible, this will keep the cache fresh even when manipulated. If this is not possible the cache is cleared. When an array of items are needed and the cache is outdated, the cache is recreated from the items and their priorities
You can access, append, insert, remove an item by using itemAt, add, insertAt, and remove. To get the number of the items in the list, use getCount. TPriorityList can also be used like a regular array as follows,
To extend TPriorityList for doing your own operations with each addition or removal, override insertAtIndexInPriority() and removeAtIndexInPriority() and then call the parent.
Located in /Collections/TPriorityList.php (line 50)
TComponent | --TList | --TPriorityList
Constructor.
Initializes the list with an array or an iterable object.
Appends an item into the list at the end of the specified priority. The position of the added item may not be at the end of the list.
Removes all items in the priority list by calling removeAtIndexInPriority from the last item to the first.
Copies iterable data into the priority list.
Note, existing data in the map will be cleared first.
Returns the number of items in the list.
This method is required by Countable interface.
This flattens the priority list into a flat array [0,...,n-1]
Returns the total number of items in the list
Returns an iterator for traversing the items in the list.
This method is required by the interface IteratorAggregate.
This returns a list of the priorities within this list, ordered lowest to highest.
Gets the number of items at a priority within the list
This inserts an item after another item within the list. It uses the same priority as the found index item and places the new item after it.
Inserts an item at an index. It reads the priority of the item at index within the flattened list and then inserts the item at that priority-index.
Inserts an item at the specified index within a priority. Override and call this method to insert your own functionality.
This inserts an item before another item within the list. It uses the same priority as the found index item and places the new item before it.
Returns the item at the index of a flattened priority list.
offsetGet calls this method.
Returns the item at an index within a priority
Gets all the items at a specific priority.
Merges iterable data into the priority list.
New data will be appended to the end of the existing data. If another TPriorityList is merged, the incoming parameter items will be appended at the priorities they are present. These items will be added to the end of the existing items with equal priorities, if there are any.
Returns whether there is an element at the specified offset.
This method is required by the interface ArrayAccess.
Returns the element at the specified offset.
This method is required by the interface ArrayAccess.
Sets the element at the specified offset. This method is required by the interface ArrayAccess.
Setting elements in a priority list is not straight forword when appending and setting at the end boundary. When appending without an offset (a null offset), the item will be added at the default priority. The item may not be the last item in the list. When appending with an offset equal to the count of the list, the item will get be appended with the last items priority.
All together, when setting the location of an item, the item stays in that location, but appending an item into a priority list doesn't mean the item is at the end of the list.
Unsets the element at the specified offset.
This method is required by the interface ArrayAccess.
Retutrns the priority of an item at a particular flattened index.
Returns the priority of a particular item
Removes an item from the priority list.
The list will search for the item. The first matching item found will be removed from the list.
Removes an item at the specified index in the flattened list.
Removes the item at a specific index within a priority. Override and call this method to insert your own functionality.
This must be called internally or when instantiated.
This must be called internally or when instantiated.
This orders the priority list internally.
Combines the map elements which have a priority above the parameter value
Combines the map elements which have a priority below the parameter value
Inherited From TList
TList::__construct()
TList::add()
TList::clear()
TList::contains()
TList::copyFrom()
TList::count()
TList::getCount()
TList::getIterator()
TList::getReadOnly()
TList::indexOf()
TList::insertAfter()
TList::insertAt()
TList::insertBefore()
TList::itemAt()
TList::mergeWith()
TList::offsetExists()
TList::offsetGet()
TList::offsetSet()
TList::offsetUnset()
TList::remove()
TList::removeAt()
TList::setReadOnly()
TList::toArray()
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::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()
Documentation generated on Mon, 25 Jun 2012 14:38:54 +0200 by phpDocumentor 1.4.3