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 {@link 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
{@link itemAt}, {@link add}, {@link insertAt}, and {@link remove}.
To get the number of the items in the list, use {@link getCount}.
TPriorityList can also be used like a regular array as follows,
$list[]=$item; // append with the default priority. It may not be the last item if other items in the list are prioritized after the default priority
$list[$index]=$item; // $index must be between 0 and $list->Count-1. This sets the element regardless of priority. Priority stays the same.
$list[$index]=$item; // $index is $list->Count. This appends the item to the end of the list with the same priority as the last item in the list.
unset($list[$index]); // remove the item at $index
if(isset($list[$index])) // if the list has an item at $index
foreach($list as $index=>$item) // traverse each item in the list in proper priority order and add/insert order
$n=count($list); // returns the number of items in the list
To extend TPriorityList for doing your own operations with each addition or removal,
override {@link insertAtIndexInPriority()} and {@link removeAtIndexInPriority()} and then call the parent.