TPriorityMap class
TPriorityMap implements a collection that takes key-value pairs with a priority to allow key-value pairs to be ordered. This ordering is important when flattening the map. When flattening the map, if some key-value pairs are required to be before or after others, use this class to keep order to your map.
You can access, add or remove an item with a key by using itemAt, add, and remove. These functions can optionally take a priority parameter to allow access to specific priorities. TPriorityMap is functionally backward compatible with TMap.
To get the number of the items in the map, use getCount. TPriorityMap can also be used like a regular array as follows,
An item that doesn't specify a priority will receive the default priority. The default priority is set during the instantiation of a new TPriorityMap. If no custom default priority is specified, the standard default priority of 10 is used.
Priorities with significant digits below precision will be rounded.
A priority may also be a numeric with decimals. This is set during the instantiation of a new TPriorityMap. The default is 8 decimal places for a priority. If a negative number is used, rounding occurs into the integer space rather than in the decimal space. See http://www.php.net/round.
Located in /Collections/TPriorityMap.php (line 60)
TComponent | --TMap | --TPriorityMap
Constructor.
Initializes the array with an array or an iterable object.
Adds an item into the map. A third parameter may be used to set the priority of the item within the map. Priority is primarily used during when flattening the map into an array where order may be and important factor of the key-value pairs within the array.
Note, if the specified key already exists, the old value will be overwritten. No duplicate keys are allowed regardless of priority.
Removes all items in the map. remove is called on all items.
Copies iterable data into the map.
Note, existing data in the map will be cleared first.
Returns the number of items in the map.
This method is required by Countable interface.
This flattens the priority map into a flat array [0,...,n-1]
Returns an iterator for traversing the items in the map.
This method is required by the interface IteratorAggregate.
Returns the keys within the map ordered through the priority of each key-value pair
This returns a list of the priorities within this map, ordered lowest to highest.
Gets the number of items at a priority within the map.
Returns the item with the specified key. If a priority is specified, only items
within that specific priority will be selected
Gets all the items at a specific priority.
Merges iterable data into the map.
Existing data in the map will be kept and overwritten if the keys are the same.
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.
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 within the map. This searches the map for the item.
Removes an item from the map by its key. If no priority, or false, is specified
then priority is irrelevant. If null is used as a parameter for priority, then the priority will be the default priority. If a priority is specified, or the default priority is specified, only key-value pairs in that priority will be affected.
This must be called internally or when instantiated.
This must be called internally or when instantiated.
This changes an item's priority. Specify the item and the new priority.
This method is exactly the same as offsetGet.
Orders the priority list internally.
When the map is flattened into an array, the priorities are taken into account and elements of the map are ordered in the array according to their priority.
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 TMap
TMap::__construct()
TMap::add()
TMap::clear()
TMap::contains()
TMap::copyFrom()
TMap::count()
TMap::getCount()
TMap::getIterator()
TMap::getKeys()
TMap::getReadOnly()
TMap::itemAt()
TMap::mergeWith()
TMap::offsetExists()
TMap::offsetGet()
TMap::offsetSet()
TMap::offsetUnset()
TMap::remove()
TMap::setReadOnly()
TMap::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:55 +0200 by phpDocumentor 1.4.3