Prado\Collections\TPriorityList::removeAt PHP Method

removeAt() public method

Removes an item at the specified index in the flattened list.
public removeAt ( $index ) : mixed
return mixed the removed item.
    public function removeAt($index)
    {
        if ($this->getReadOnly()) {
            throw new TInvalidOperationException('list_readonly', get_class($this));
        }
        if (($priority = $this->priorityAt($index, true)) !== false) {
            return $this->removeAtIndexInPriority($priority[1], $priority[0]);
        }
        throw new TInvalidDataValueException('list_index_invalid', $index);
    }

Usage Example

Beispiel #1
0
 public function testRemoveAtTPriorityList()
 {
     $plist = new TPriorityList($this->plist);
     $this->assertEquals($this->pitem1, $plist->removeAt(1));
     $this->assertEquals(-1, $plist->indexOf($this->pitem1));
     $this->assertEquals(1, $plist->indexOf($this->pitem2));
     $this->assertEquals(0, $plist->indexOf($this->pfirst));
     try {
         $plist->removeAt(3);
         $this->fail('exception not raised when removing item with invalid index');
     } catch (TInvalidDataValueException $e) {
     }
 }