PIP
0.4.0_beta2
Platform-Independent Primitives
|
Dynamic array of any type. More...
Inherited by PIQueue< T >, and PIStack< T >.
Public Member Functions | |
PIVector () | |
size_t | size () const |
Elements count. | |
ssize_t | size_s () const |
Elements count. | |
bool | isEmpty () const |
Return "true" if vector is empty, i.e. size = 0. | |
T & | back () |
Last element of the vector. | |
const T & | back () const |
Last element of the vector. | |
T & | front () |
First element of the vector. | |
const T & | front () const |
First element of the vector. | |
bool | operator== (const PIVector< T > &t) const |
Compare with vector "t". | |
bool | operator!= (const PIVector< T > &t) const |
Compare with vector "t". | |
bool | contains (const T &v) const |
Return "true" if vector has at least one element equal "t". | |
int | etries (const T &v) const |
Return how many times element "t" appears in vector. | |
PIVector< T > & | clear () |
Clear vector. Equivalent to call "resize(0)" | |
PIVector< T > & | fill (const T &f=T()) |
Fill vector with elements "t" leave size is unchanged and return reference to vector. More... | |
PIVector< T > & | resize (size_t new_size, const T &f=T()) |
Resize vector to size "size". More... | |
PIVector< T > & | remove (size_t index, size_t count=1) |
Remove one element by index "index" and return reference to vector. More... | |
PIVector< T > & | sort (CompareFunc compare=compare_func) |
Sort vector using quick sort algorithm and standard compare function. More... | |
PIVector< T > & | enlarge (llong piv_size) |
Increase vector size with "size" elements. | |
PIVector< T > & | removeOne (const T &v) |
Remove no more than one element equal "v" and return reference to vector. More... | |
PIVector< T > & | removeAll (const T &v) |
Remove all elements equal "v" and return reference to vector. More... | |
PIVector< T > & | push_back (const T &v) |
Add new element "t" at the end of vector and return reference to vector. | |
PIVector< T > & | operator<< (const PIVector< T > &other) |
Add vector "t" at the end of vector and return reference to vector. | |
PIVector< T > & | push_front (const T &v) |
Add new element "t" at the beginning of vector and return reference to vector. | |
PIVector< T > & | pop_back () |
Remove one element from the end of vector and return reference to vector. | |
PIVector< T > & | pop_front () |
Remove one element from the beginning of vector and return reference to vector. | |
T | take_back () |
Remove one element from the end of vector and return it. | |
T | take_front () |
Remove one element from the beginning of vector and return it. | |
Static Public Member Functions | |
static int | compare_func (const T *t0, const T *t1) |
Standard compare function for type "Type". Return 0 if t0 = t1, -1 if t0 < t1 and 1 if t0 > t1. | |
Dynamic array of any type.
This class used to store dynamic array of any type of data. In memory data stored linear. You can insert item in any place of remove some items from any place. For quick add elements this is stream operator <<.
Fill vector with elements "t" leave size is unchanged and return reference to vector.
Example:
|
inline |
Resize vector to size "size".
Elements removed from end of vector if new size < old size, or added new elements = "new_type" if new size > old size.
Example:
|
inline |
Remove one element by index "index" and return reference to vector.
Remove "count" elements by first index "index" and return reference to vector.
Example:
Example:
|
inline |
Sort vector using quick sort algorithm and standard compare function.
Example:
With custom compare function:
Remove no more than one element equal "v" and return reference to vector.
Example:
Remove all elements equal "v" and return reference to vector.
Example: