Prado\Collections\TPriorityList::insertAfter PHP Method

insertAfter() public method

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.
public insertAfter ( $indexitem, $item ) : integer
return integer where the item has been inserted in the flattened list
    public function insertAfter($indexitem, $item)
    {
        if ($this->getReadOnly()) {
            throw new TInvalidOperationException('list_readonly', get_class($this));
        }
        if (($priority = $this->priorityOf($indexitem, true)) === false) {
            throw new TInvalidDataValueException('list_item_inexistent');
        }
        $this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]);
        return $priority[2] + 1;
    }

Usage Example

コード例 #1
0
ファイル: TPriorityListTest.php プロジェクト: pradosoft/prado
 public function testInsertAfterTPriorityList()
 {
     $plist = new TPriorityList($this->plist);
     $this->assertEquals(4, $plist->getCount());
     $plist->insertAfter($this->pfirst, $this->pitem4);
     $this->assertEquals(-10000000, $plist->priorityOf($this->pitem4));
 }