|
Class TPriorityMap
-
TComponent
-
TMap
implements
IteratorAggregate,
ArrayAccess,
Countable
-
TPriorityMap
Methods summary
public
|
#
__construct( map|array|Iterator|TPriorityMap $data = null, boolean $readOnly = false, numeric $defaultPriority = 10, integer $precision = 8 )
Constructor. Initializes the array with an array or an iterable object.
Constructor. Initializes the array with an array or an iterable object.
Parameters
- $data
map|array|Iterator|TPriorityMap the intial data. Default is null, meaning no initialization.
- $readOnly
boolean whether the list is read-only
- $defaultPriority
numeric the default priority of items without specified priorities.
- $precision
integer the precision of the numeric priorities
Throws
Overrides
|
public
boolean
|
#
getReadOnly( )
Returns
boolean whether this map is read-only or not. Defaults to false.
Overrides
|
protected
|
#
setReadOnly( boolean $value )
Parameters
- $value
boolean whether this list is read-only or not
Overrides
|
public
numeric
|
#
getDefaultPriority( )
Returns
numeric gets the default priority of inserted items without a specified priority
|
protected
|
#
setDefaultPriority( numeric $value )
This must be called internally or when instantiated.
This must be called internally or when instantiated.
Parameters
- $value
numeric sets the default priority of inserted items without a specified priority
|
public
integer
|
#
getPrecision( )
Returns
integer The precision of numeric priorities, defaults to 8
|
protected
|
#
setPrecision( integer $value )
This must be called internally or when instantiated.
This must be called internally or when instantiated.
Parameters
- $value
integer The precision of numeric priorities.
|
public
Iterator
|
#
getIterator( )
Returns an iterator for traversing the items in the map. This method is
required by the interface IteratorAggregate.
Returns an iterator for traversing the items in the map. This method is
required by the interface IteratorAggregate.
Returns
Iterator an iterator for traversing the items in the map.
Overrides
|
protected
|
#
sortPriorities( )
Orders the priority list internally.
Orders the priority list internally.
|
protected
array
|
#
flattenPriorities( )
This flattens the priority map into a flat array [0,...,n-1]
This flattens the priority map into a flat array [0,...,n-1]
Returns
array array of items in the list in priority and index order
|
public
integer
|
#
count( )
Returns the number of items in the map. This method is required by Countable
interface.
Returns the number of items in the map. This method is required by Countable
interface.
Returns
integer number of items in the map.
Overrides
|
public
integer
|
#
getCount( )
Returns
integer the number of items in the map
Overrides
|
public
integer
|
#
getPriorityCount( numeric $priority = null )
Gets the number of items at a priority within the map.
Gets the number of items at a priority within the map.
Parameters
Returns
integer the number of items in the map at the specified priority
|
public
array
|
#
getPriorities( )
This returns a list of the priorities within this map, ordered lowest to
highest.
This returns a list of the priorities within this map, ordered lowest to
highest.
Returns
array the array of priority numerics in decreasing priority order
|
public
array
|
#
getKeys( )
Returns the keys within the map ordered through the priority of each
key-value pair
Returns the keys within the map ordered through the priority of each
key-value pair
Returns
array the key list
Overrides
|
public
mixed
|
#
itemAt( mixed $key, mixed $priority = false )
Returns the item with the specified key. If a priority is specified, only
items within that specific priority will be selected
Returns the item with the specified key. If a priority is specified, only
items within that specific priority will be selected
Parameters
- $key
mixed the key
- $priority
mixed the priority. null is the default priority, false is any priority, and numeric
is a specific priority. default: false, any priority.
Returns
mixed the element at the offset, null if no element is found at the offset
Overrides
|
public
numeric
|
#
setPriorityAt( mixed $key, numeric|null $priority = null )
This changes an item's priority. Specify the item and the new priority. This
method is exactly the same as TPriorityMap::offsetGet() .
This changes an item's priority. Specify the item and the new priority. This
method is exactly the same as TPriorityMap::offsetGet() .
Parameters
- $key
mixed the key
- $priority
numeric|null the priority. default: null, filled in with the default priority numeric.
Returns
numeric old priority of the item
|
public
array
|
#
itemsAtPriority( numeric $priority = null )
Gets all the items at a specific priority.
Gets all the items at a specific priority.
Parameters
- $priority
numeric priority of the items to get. Defaults to null, filled in with the default
priority, if left blank.
Returns
array all items at priority in index order, null if there are no items at that
priority
|
public
numeric
|
#
priorityOf( mixed $item )
Returns the priority of a particular item within the map. This searches the
map for the item.
Returns the priority of a particular item within the map. This searches the
map for the item.
Parameters
- $item
mixed item to look for within the map
Returns
numeric priority of the item in the map
|
public
numeric
|
#
priorityAt( integer $key )
Retutrns the priority of an item at a particular flattened index.
Retutrns the priority of an item at a particular flattened index.
Parameters
- $key
integer index of the item within the map
Returns
numeric priority of the item in the map
|
public
numeric
|
#
add( mixed $key, mixed $value, numeric|null $priority = null )
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.
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.
Parameters
- $key
mixed key
- $value
mixed value
- $priority
numeric|null priority, default: null, filled in with default priority
Returns
numeric priority at which the pair was added
Throws
Overrides
|
public
mixed
|
#
remove( mixed $key, numeric|false|null $priority = false )
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.
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.
Parameters
- $key
mixed the key of the item to be removed
- $priority
numeric|false|null priority. False is any priority, null is the default priority, and numeric is a
specific priority
Returns
mixed the removed value, null if no such key exists.
Throws
Overrides
|
public
|
|
public
boolean
|
#
contains( mixed $key )
Parameters
Returns
boolean whether the map contains an item with the specified key
Overrides
|
public
array
|
#
toArray( )
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.
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.
Returns
array the list of items in array
Overrides
|
public
array
|
#
toArrayBelowPriority( numeric $priority, boolean $inclusive = false )
Combines the map elements which have a priority below the parameter value
Combines the map elements which have a priority below the parameter value
Parameters
- $priority
numeric the cut-off priority. All items of priority less than this are returned.
- $inclusive
boolean whether or not the input cut-off priority is inclusive. Default: false, not
inclusive.
Returns
array the array of priorities keys with values of arrays of items that are below a
specified priority. The priorities are sorted so important priorities, lower
numerics, are first.
|
public
array
|
#
toArrayAbovePriority( numeric $priority, boolean $inclusive = true )
Combines the map elements which have a priority above the parameter value
Combines the map elements which have a priority above the parameter value
Parameters
- $priority
numeric the cut-off priority. All items of priority greater than this are returned.
- $inclusive
boolean whether or not the input cut-off priority is inclusive. Default: true,
inclusive.
Returns
array the array of priorities keys with values of arrays of items that are above a
specified priority. The priorities are sorted so important priorities, lower
numerics, are first.
|
public
|
#
copyFrom( mixed $data )
Copies iterable data into the map. Note, existing data in the map will be
cleared first.
Copies iterable data into the map. Note, existing data in the map will be
cleared first.
Parameters
- $data
mixed the data to be copied from, must be an array, object implementing Traversable,
or a TPriorityMap
Throws
Overrides
|
public
|
#
mergeWith( mixed $data )
Merges iterable data into the map. Existing data in the map will be kept and
overwritten if the keys are the same.
Merges iterable data into the map. Existing data in the map will be kept and
overwritten if the keys are the same.
Parameters
- $data
mixed the data to be merged with, must be an array, object implementing Traversable,
or a TPriorityMap
Throws
Overrides
|
public
boolean
|
#
offsetExists( mixed $offset )
Returns whether there is an element at the specified offset. This method is
required by the interface ArrayAccess.
Returns whether there is an element at the specified offset. This method is
required by the interface ArrayAccess.
Parameters
- $offset
mixed the offset to check on
Returns
boolean
Overrides
|
public
mixed
|
#
offsetGet( integer $offset )
Returns the 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.
Parameters
- $offset
integer the offset to retrieve element.
Returns
mixed the element at the offset, null if no element is found at the offset
Overrides
|
public
|
#
offsetSet( integer $offset, mixed $item )
Sets 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.
Parameters
- $offset
integer the offset to set element
- $item
mixed the element value
Overrides
|
public
|
#
offsetUnset( mixed $offset )
Unsets 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.
Parameters
- $offset
mixed the offset to unset element
Overrides
|
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()
|
|