The Vector class
(No version information available, might only be in Git)
简介
A 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
- Supports array syntax (square brackets).
- Uses less overall memory than an array for the same number of values.
- Automatically frees allocated memory when its size drops low enough.
- Capacity does not have to be a power of 2.
-
get(),
set(),
push(),
pop() are all O(1).
Weaknesses
-
shift(),
unshift(),
insert() and
remove() are all O(n).
类摘要
Ds\Vector
implements Ds\Sequence
{
public void clear
(
void
)
public Ds\Vector copy
(
void
)
public mixed first
(
void
)
public mixed get
(
int $index
)
public void insert
(
int $index
[,
mixed $...values
] )
public string join
([
string $glue
] )
public mixed last
(
void
)
public mixed pop
(
void
)
public mixed remove
(
int $index
)
public void rotate
(
int $rotations
)
public void set
(
int $index
,
mixed $value
)
public mixed shift
(
void
)
public Ds\Vector slice
(
int $index
[,
int $length
] )
public number sum
(
void
)
}
预定义常量
Ds\Vector::MIN_CAPACITY
-
Table of Contents
User Contributed Notes
There are no user contributed notes for this page.