Prado\Collections\TPriorityList::insertAfter PHP Метод

insertAfter() публичный Метод

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
Результат 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
 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));
 }