The Vector classIntroductionA Vector is a sequence of values in a contiguous buffer that grows and shrinks automatically. It’s the most efficient sequential structure because a value’s index is a direct mapping to its index in the buffer, and the growth factor isn't bound to a specific multiple or exponent. Strengths
Weaknesses
Class synopsis
Ds\Vector
class Ds\Vector
implements Ds\Sequence, ArrayAccess {
/* Constants */
const
int
Ds\Vector::MIN_CAPACITY = 10;
/* Methods */
public void allocate(int
$capacity )public void apply(callable
$callback )public int capacity()
public void clear()
public bool contains(mixed
...$values )public Ds\Vector copy()
public Ds\Vector filter(callable
$callback = ?)public mixed find(mixed
$value )public mixed first()
public mixed get(int
$index )public void insert(int
$index , mixed ...$values )public bool isEmpty()
public string join(string
$glue = ?)public mixed last()
public Ds\Vector map(callable
$callback )public Ds\Vector merge(mixed
$values )public mixed pop()
public void push(mixed
...$values )public mixed reduce(callable
$callback , mixed $initial = ?)public mixed remove(int
$index )public void reverse()
public Ds\Vector reversed()
public void rotate(int
$rotations )public void set(int
$index , mixed $value )public mixed shift()
public Ds\Vector slice(int
$index , int $length = ?)public void sort(callable
$comparator = ?)public Ds\Vector sorted(callable
$comparator = ?)public intfloat sum()
public array toArray()
public void unshift(mixed
}$values = ?)Predefined Constants
Changelog
|