summaryrefslogtreecommitdiff
path: root/framework/Collections/TPriorityList.php
diff options
context:
space:
mode:
authorjavalizard <>2010-10-04 03:16:29 +0000
committerjavalizard <>2010-10-04 03:16:29 +0000
commitd9fb4b20d14b9f090fa3d7c77d6c3134ca386dc9 (patch)
treeb3b9f3ed64b843ed20c6b59db47dc990fe91ad9f /framework/Collections/TPriorityList.php
parentb4b885d3bc63525fa58b8eedbd0495a1e357e443 (diff)
#247 Removed one redundant function. Change the unit test to reflect the function removal.
Diffstat (limited to 'framework/Collections/TPriorityList.php')
-rw-r--r--framework/Collections/TPriorityList.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/framework/Collections/TPriorityList.php b/framework/Collections/TPriorityList.php
index 6ce93d49..ebb90b91 100644
--- a/framework/Collections/TPriorityList.php
+++ b/framework/Collections/TPriorityList.php
@@ -368,18 +368,28 @@ class TPriorityList extends TList
* 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.
* @param mixed item the item to be removed.
+ * @param numeric priority of item to remove. without this parameter it defaults to false.
+ * A value of false means any priority. null will be filled in with the default priority.
* @return integer index within the flattened list at which the item is being removed
* @throws TInvalidDataValueException If the item does not exist
*/
- public function remove($item)
+ public function remove($item,$priority=false)
{
if($this->getReadOnly())
throw new TInvalidOperationException('list_readonly',get_class($this));
- if(($priority=$this->priorityOf($item, true))!==false)
+ if(($p=$this->priorityOf($item, true))!==false)
{
- $this->removeAtIndexInPriority($priority[1], $priority[0]);
- return $priority[2];
+ if($priority !== false) {
+ if($priority === null)
+ $priority = $this->getDefaultPriority();
+ $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
+
+ if($p[0] != $priority)
+ throw new TInvalidDataValueException('list_item_inexistent');
+ }
+ $this->removeAtIndexInPriority($p[1], $p[0]);
+ return $p[2];
}
else
throw new TInvalidDataValueException('list_item_inexistent');