Prado\Collections\TPriorityList::add PHP 메소드

add() 공개 메소드

Appends an item into the list at the end of the specified priority. The position of the added item may not be at the end of the list.
public add ( $item, $priority = null ) : integer
리턴 integer the index within the flattened array
    public function add($item, $priority = null)
    {
        if ($this->getReadOnly()) {
            throw new TInvalidOperationException('list_readonly', get_class($this));
        }
        return $this->insertAtIndexInPriority($item, false, $priority, true);
    }

Usage Example

예제 #1
0
 public function testOffsetUnsetTPriorityList()
 {
     $list = new TPriorityList();
     $list->add(2);
     $list->add(1, 5);
     $list->add(3, 15);
     $list->offsetUnset(1);
     self::assertEquals(array(1, 3), $list->toArray());
 }