Header:
plang/factor/vector_.hpp
Class:
vector_ : factor

    vector is built-in data type represents dynamic array. In C++ code boost::shared_ptr<vector_> is class corresponding to vector.
vector has std::vector<factor::shared_ptr> data type member named v which holds values of that object.

Members
v
dynamic array

Methods

constructors

vector()

vector(vector& x)

vector(unsigned int size)

vector(unsigned int size, T& value)
operators


vector& operator =(vector& x)
methods


bool empty()

unsigned int size()

T pop_back()

nil clear()

T& back()

T& front()

T& at(unsigned int pos)

T& push_back(T value)

nil swap(vector& x)

nil resize(unsigned int size)

nil resize(unsigned int size, T value)

T1& replace(unsigned int pos, T2 value)

vector()
default constructor, set empty vector

effects
v=vector_type()


vector(vector& x)
copy constructor, deepcopy x.v

parameters
vector& x - copy this

effects
deepcopy(x.v)


vector(unsigned int size)
create vector contains size of nil elements

parameters
unsigned int size - size of array

effects
resize(size,nil())


template<class T> vector(unsigned int size, T value)
create vector holds size of elements, which are copyof(value)

parameters
unsigned int size - size of array
T value - value of elements

effects
resize(size,value)


vector& operator =(vector& x)
deepcopy x.v

parameters
vector& x - copy this

effects
deepcopy(x.v)


bool empty()
test if v is empty

returns

v.empty()


unsigned int size()
get size of array

returns
v.size()


template<class T> T pop_back()
delete last element from v

effects
remove v[size()-1] from v

returns
return removed object

exceptions
range_error - if v is empty


nil clear()
destroy all elements in v

effects
v.clear()


template<class T> T& back()
get last element in v, v[size()-1]

returns
v.back()

exceptions
range_error - if v is empty


template<class T> T& front()
get first element in v, v[0]

returns
v.front()

exceptions
range_error - if v is empty()


template<class T> T& at(unsigned int pos)
get element at position pos in v

parameters
unsigned int pos
position in vector
domain error occurs if pos >= size()

returns
v.at(pos)

exceptions
range_error - if pos >= size()


template<class T> T& push_back(T value)
add new element copyof(value) to v

parameters
T value - value to be added

returns
v.back()


nil swap(vector& x)
swap v with x.v

parameters
vector& x - object to be swaped


nil resize(unsigned int size)
resize v to contain size elements

parameters
unsigned int size - new vector size

effects
if size > size(), expand v by inserting copies of nil at the end to reach a size of size elements
if size < size(), reduce v to first size elements


template<class T> nil resize(unsigned int size, T value)
resize v to contain size elements

parameters
unsigned int size - new vector size
T value - object whose content is copied to be added at the end for expansion

effects
if size > size(), expand v by inserting copies of copyof(value) at the end to reach a size of size elements
if size < size(), reduce v to first size elements


template<class T1, class T2> T1& replace(unsigned int pos, T2 value)
replace v[pos] with copyof(value)

parameters
unsigned int pos
position in v
domain error occurs if pos >= size()
T2 value - object whose content is copied to be replaced

effects
v[pos] = copyof(value)

exceptions
range_error - if pos >= size()