class::var::Vector

class var::Vector
  : public var::Data

The Vector class is similar to std::vector but is embedded friendly.

Summary

[Vector](#classvar_1_1_vector_1a2a340125c20c98a2fa8531d6e464c29b)()

[Vector](#classvar_1_1_vector_1aea263c5e7764f80ed3c4128c7dce344d)(  

const arg::Count count
)

[Vector](#classvar_1_1_vector_1aa294795bde4a32671306034db96ba06d)(  

const Vector< T > & a
)

[Vector](#classvar_1_1_vector_1ae89018f74600d2cd6a86689da9bc9d9a)(  

Vector< T > && a
)

[~Vector](#classvar_1_1_vector_1a7256560ecfa86587abe65d80e2e9209c)()

T & at(

u32 pos
)

const T & at(

u32 pos
) const

T * begin()

const T * begin() const

u32 capacity() const

virtual void clear()

u32 count() const

T * end()

const T * end() const

virtual void fill(

const T & value
)

u32 find(

const T & a
)

u32 find(

const T & a,
bool(*)(const T &a, const T &b) compare
)

int free()

int insert(

u32 pos,
const T & value
)

Vector< T > operator *(

const Vector< T > & a
) const

Vector< T > operator *(

const T & a
) const

Vector< T > operator -(

const Vector< T > & a
) const

Vector< T > operator -(

const T & a
) const

Vector< T > operator >>(

u32 a
) const

Vector< T > operator+(

const Vector< T > & a
) const

Vector< T > operator+(

const T & a
) const

Vector< T > operator/(

const Vector< T > & a
) const

Vector< T > operator/(

const T & a
) const

Vector< T > & operator<<(

const T & a
)

Vector< T > & operator<<(

const Vector< T > & a
)

Vector< T > operator<<(

u32 a
) const

Vector & operator=(

Vector< T > && a
)

Vector & operator=(

const Vector< T > & a
)

const T & operator[](

u32 idx
) const

T & operator[](

u32 idx
)

void pop_back()

int push_back(

const T & value
)

void reserve(

const arg::ImplicitSize new_capacity
)

int resize(

const arg::Count count
)

T * search(

const T & a
)

T * search(

const T & a,
int(*)(const void *, const void *) compare
)

void shrink_to_fit()

virtual u32 size() const

void sort(

sort_compartor_t compare_function
)

T * vector_data()

const T * vector_data_const() const

static int ascending(

const void * a,
const void * b
)

static int descending(

const void * a,
const void * b
)

protected Vector< T > operate(

const Vector< T > & a,
T(*)(const T &, const T &) fn
) const

protected Vector< T > operate_single(

const T & a,
T(*)(const T &, const T &) fn
) const

typedef std::iterator< std::random_access_iterator_tag, const T, ptrdiff_t, const T *, const T & > const_iterator

typedef std::iterator< std::random_access_iterator_tag, T, ptrdiff_t, T *, T & > iterator

typedef int(* sort_compartor_t

Members

Vector()

Constructs an empty object.


Vector(

const arg::Count count
)

Constructs a vector with count uninitialized items.


Vector(

const Vector< T > & a
)


Vector(

Vector< T > && a
)


~Vector()

T & at(

u32 pos
)

Returns a referece to the element at the specified position.

Parameters

  • pos The position in the vector to access.

If pos is not a valid value, reference to the first eleemnt will be returned.

If there are zero elements in the vector and no memory has been allocated, this method will dereference a null-pointer and cause the application to crash.

If there are no elements and the vector has been allocated memory, this method will return a value that is no longer valid.


const T & at(

u32 pos
) const

Provides a read-only reference to an element in the Vector.

The same limitations apply to this method as apply to the read-write version.


T * begin()

const T * begin() const

u32 capacity() const

Returns the number of elements that are able to fit in the memory that is already allocated.


virtual void clear()

Removes all elements from the vector.

This method sets the count() to zero. It doesn’t free any memory associated with the object.


u32 count() const

Returns the number of elemens in the Vector.

The count includes the number of elements added to the vector using push_back() or insert(). If the resize() method is called, it will directly set the count() and ensure there is enough memory available to hold count() items.


T * end()

const T * end() const

virtual void fill(

const T & value
)

Fills the vector will the specified value.

Parameters

  • value The value to assign to each element of the vector

u32 find(

const T & a
)

Finds an object in the array.

Parameters

  • a The equivalent object to find

Returns

The index of the object or count() it if wasn’t found


u32 find(

const T & a,
bool(*)(const T &a, const T &b) compare
)


int free()

int insert(

u32 pos,
const T & value
)

Inserts an element at the specified position.

Parameters

  • pos The position to insert the object.

  • value The element to insert

If pos is at or past the end, value will be push_back() is used to add the element.


Vector< T > operator *(

const Vector< T > & a
) const


Vector< T > operator *(

const T & a
) const


Vector< T > operator -(

const Vector< T > & a
) const


Vector< T > operator -(

const T & a
) const


Vector< T > operator >>(

u32 a
) const


Vector< T > operator+(

const Vector< T > & a
) const


Vector< T > operator+(

const T & a
) const


Vector< T > operator/(

const Vector< T > & a
) const


Vector< T > operator/(

const T & a
) const


Vector< T > & operator<<(

const T & a
)


Vector< T > & operator<<(

const Vector< T > & a
)


Vector< T > operator<<(

u32 a
) const


Vector & operator=(

Vector< T > && a
)


Vector & operator=(

const Vector< T > & a
)


const T & operator[](

u32 idx
) const

Provides un-bounded access to the specified element (read-only).

If the Vector has no data, this method may dereference a null pointer and cause the program to crash.


T & operator[](

u32 idx
)

Provides un-bounded access to the specified element.

If the Vector has no data, this method may dereference a null pointer and cause the program to crash.


void pop_back()

Removes the last element of the vector.

This makes the last element inaccessible. It does not affect the memory allocation of the vector. Once items are popped, the memory can be freed using the method shrink_to_fit().


int push_back(

const T & value
)

Adds an element to the end of the Vector.

If the element won’t fit, space will be added. If space cannot be added, nothing will happen.


void reserve(

const arg::ImplicitSize new_capacity
)

Reserves enough data for the specified number of elements.

Parameters

  • new_capacity The number of elements to make room for.

int resize(

const arg::Count count
)

Resizes the vector.

Parameters

  • count The new number of element for the vector to have

This method will increase/decrease the number of elements in the vector. If elements are added, they will not be initialized.

The method shrink_to_fit() will free memory that is no longer needed. It doesn’t affect the count() of the object.

The method reserve() will increase the memory that is available but does not affect the count() of the object().


T * search(

const T & a
)


T * search(

const T & a,
int(*)(const void *, const void *) compare
)


void shrink_to_fit()

Frees unused memory that is reserved for this Vector.


virtual u32 size() const

Returns the number of bytes used by the Vector.

This accounts only for valid objects. Reserved space is not counted. To return the total number of bytes including reserve, use capacity() * sizeof(T).


void sort(

sort_compartor_t compare_function
)


T * vector_data()

const T * vector_data_const() const

static int ascending(

const void * a,
const void * b
)


static int descending(

const void * a,
const void * b
)


protected Vector< T > operate(

const Vector< T > & a,
T(*)(const T &, const T &) fn
) const


protected Vector< T > operate_single(

const T & a,
T(*)(const T &, const T &) fn
) const


typedef std::iterator< std::random_access_iterator_tag, const T, ptrdiff_t, const T *, const T & > const_iterator

typedef std::iterator< std::random_access_iterator_tag, T, ptrdiff_t, T *, T & > iterator

typedef int(* sort_compartor_t

X

Thanks for Coming!

Subscribe to news and updates