#include <kvector.hpp>
Public Types | |
typedef T | type |
Type of objects contained in the vector. | |
enum | { beg = BEG } |
Public Member Functions | |
void | resize (K_UINT_32 n) |
Resizes the vector. Resulting vector contents are undefined. | |
KVector & | operator= (const T &a) |
Assigns a copy of a to all elements of the vector. | |
KVector & | operator= (const KVector &v) |
Copy assignment operator. Performs a deep copy. | |
void | assign (K_UINT_32 n, const T *v) |
Copies an array of n instances of T . | |
void | swap (KVector &v) |
Constant-time swap function between two vectors. | |
Constructors and destructor. | |
KVector () | |
Default constructor. Creates an empty vector. | |
KVector (K_UINT_32 n) | |
Creates a vector of n default instances of T . | |
KVector (K_UINT_32 n, const T &a) | |
Creates a vector of n copies of a . | |
KVector (K_UINT_32 n, const T *v) | |
Creates a vector from an array of n instances of T . | |
KVector (const KVector &v) | |
Copy constructor. Performs a deep copy. | |
~KVector () | |
Destructor. | |
Member access functions. | |
T & | operator() (K_UINT_32 i) |
Returns the i'th element. | |
const T & | operator() (K_UINT_32 i) const |
Returns the i'th element, const version. | |
K_UINT_32 | size () const |
Returns the vector size. | |
Streaming functions | |
void | get (std::istream &is) |
Reads a vector from a stream. | |
void | put (std::ostream &os) const |
Writes a vector to a stream. |
This vector class does not define any fancy linear algebra functions, nor even any operator between vectors. Its sole purpose is to well encapsulate an extensible array representing a vector, and also to allow starting index to be 0 or 1.
T
: Type of elements contained in the vector. Usually float
or double
.BEG
: Starting index of vector. Can be either 0 or 1.DGB
: Debug flag. If true
, then bound-checking will be performed, and OutOfBoundError
exceptions can be thrown.T
must be default constructible.T
must be assignable.T
must be serializable.t1
, t2
are instances of T
, is
is of type istream
and os
is of type ostream
, the following expressions must be valid : -T(); T t1;
T t1 = t2; T t1(t2); T(t1);
t1 = t2;
is >> t1;
operator>>()
-os << t1;
operator<<()
Finally, note that operator>>()
and operator<<()
must be compatible. Also, operator&()
must not have been overloaded.
|
|
|
Creates a vector of
|
|
Creates a vector of
|
|
Creates a vector from an array of
This function allows to transform a C-style array of
|
|
Copy constructor. Performs a deep copy.
|
|
Returns the
|
|
Returns the
|
|
Returns the vector size.
|
|
Resizes the vector. Resulting vector contents are undefined.
|
|
Assigns a copy of
|
|
Copy assignment operator. Performs a deep copy.
|
|
Copies an array of
|
|
Constant-time swap function between two vectors. This function is fast, since it exchanges pointers to underlying implementation without copying any element.
|
|
Reads a vector from a stream.
This function will extract
|
|
Writes a vector to a stream. This function will send all the vector elements to a stream, while considering the formatting constraints of the current vector printing context.
|