#include <barray.h>
Inheritance diagram for PLib::BasicArray< T >:
Public Types | |
typedef const T * | const_iterator |
Public Member Functions | |
int | n () const |
BasicArray () | |
BasicArray (const int ni) | |
BasicArray (const BasicArray< T > &f2) | |
BasicArray (T *ap, const int size) | |
BasicArray (BasicList< T > &list) | |
virtual | ~BasicArray () |
BasicArray< T > & | operator= (const BasicArray< T > &f2) |
int | size () const |
void | resize (const int nsize) |
void | resize (const BasicArray< T > &A) |
void | trim (const int nsize) |
void | clear () |
void | untrim () |
T & | push_back (const T i, int end_buffer=10, double end_mult=-1) |
virtual void | reset (const T val=0.0) |
T | operator= (const T val) |
T & | operator[] (const int i) |
T | operator[] (const int i) const |
T * | memory () const |
void | width (const int w) |
ostream & | print (ostream &os) const |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
template<> | |
ostream & | print (ostream &os) const |
Public Attributes | |
FRIEND_ARRAY_ALLOCATOR typedef T * | iterator |
Protected Attributes | |
int | rsize |
int | wdth |
int | destruct |
int | sze |
T * | x |
Friends | |
int | operator!= (const BasicArray< T > &, const BasicArray< T > &) |
int | operator== (const BasicArray< T > &, const BasicArray< T > &) |
istream & | operator>> (istream &is, BasicArray< T > &arry) |
ostream & | operator<< (ostream &os, const BasicArray< T > &arry) |
This is a basis array class, the only particularity is that the resize is not destructive.
PLib::BasicArray< T >::BasicArray | ( | ) |
default constructor
PLib::BasicArray< T >::BasicArray | ( | const int | ni | ) |
constructor with size specified
ni | the size of the basic array |
PLib::BasicArray< T >::BasicArray | ( | const BasicArray< T > & | f2 | ) |
PLib::BasicArray< T >::BasicArray | ( | T * | ap, | |
const int | size | |||
) |
copy constructor from a pointer
The BasicArray is constructed from a pointer and a specified size. The desctructor of the class will { not} delete this pointer when it is finished with it. It is up to the function which created it to delete it.
ap | a pointer to an array | |
size | the size of the ap array |
PLib::BasicArray< T >::BasicArray | ( | BasicList< T > & | list | ) |
constructor from a linked list
list | the linked list to copy |
PLib::BasicArray< T >::~BasicArray | ( | ) | [virtual] |
destructor
int PLib::BasicArray< T >::n | ( | ) | const [inline] |
< the perceived size of the array
BasicArray< T > & PLib::BasicArray< T >::operator= | ( | const BasicArray< T > & | f2 | ) |
assignment operator
f2 | the BasicArray to copy from |
Reimplemented in PLib::Vector< T >, PLib::Vector< float >, PLib::Vector< int >, PLib::Vector< PLib::HPoint_nD< float, N > >, PLib::Vector< PLib::Point_nD< float, 3 > >, and PLib::Vector< PLib::HPoint_nD< T, N > >.
int PLib::BasicArray< T >::size | ( | ) | const [inline] |
< returns the size of the array
void PLib::BasicArray< T >::resize | ( | const BasicArray< T > & | A | ) | [inline] |
A | resize the array with the same dimension of the vector A |
void PLib::BasicArray< T >::trim | ( | const int | nsize | ) |
shortens the array without destroying the components
nsize | the new size of the vector |
void PLib::BasicArray< T >::clear | ( | ) |
clear
Clears the memory and reset the size to 0. You must resize the basic array before using it again.
T & PLib::BasicArray< T >::push_back | ( | const T | i, | |
int | end_buffer = 10 , |
|||
double | end_mult = -1 | |||
) |
adds a new element at the end of the vector
i | the element to add | |
end_buffer | allocate that amount of data if the size needs to be increased | |
end_mult | multiplies the size of the buffer by that amount if multiplier is greater than 1. |
void PLib::BasicArray< T >::reset | ( | const T | val = 0.0 |
) | [virtual] |
reset all values of the vetor to val
val | resets the elements of the array to this value |
T PLib::BasicArray< T >::operator= | ( | const T | val | ) | [inline] |
val | set all elements of the vector to val |
Reimplemented in PLib::Vector< T >, PLib::Vector< float >, PLib::Vector< int >, PLib::Vector< PLib::HPoint_nD< float, N > >, PLib::Vector< PLib::Point_nD< float, 3 > >, and PLib::Vector< PLib::HPoint_nD< T, N > >.
T& PLib::BasicArray< T >::operator[] | ( | const int | i | ) | [inline] |
i | no range checks are performed |
T PLib::BasicArray< T >::operator[] | ( | const int | i | ) | const [inline] |
T* PLib::BasicArray< T >::memory | ( | ) | const [inline] |
< returns the data pointer
void PLib::BasicArray< T >::width | ( | const int | w | ) | [inline] |
w | set output columns |
ostream & PLib::BasicArray< T >::print | ( | ostream & | os | ) | const |
sends a BasicArray to an ostream
Sends a BasicArray to an ostream
os | output stream |
int operator!= | ( | const BasicArray< T > & | a, | |
const BasicArray< T > & | b | |||
) | [friend] |
compares two arrays to see if they're different
This checks if one of the components of the two arrays are different. A check is made after each comparison to see if they are the same, this speeds up the calculation if the arrays have early different components, otherwise the use of the == operator would yield a faster result.
a | the first array to compare | |
b | the second array to compare |
int operator== | ( | const BasicArray< T > & | a, | |
const BasicArray< T > & | b | |||
) | [friend] |
checks if two arrays are identical
a | the first array to compare | |
b | the second array to compare |
istream& operator>> | ( | istream & | is, | |
BasicArray< T > & | arry | |||
) | [friend] |
stores an input string into a vector
is | the input stream | |
arry | the array initialized by is |
ostream& operator<< | ( | ostream & | os, | |
const BasicArray< T > & | arry | |||
) | [friend] |
sends a BasicArray to the ostream
os | output stream | |
arry | the array to send to the stream |
int PLib::BasicArray< T >::rsize [protected] |
the actual size of the array
int PLib::BasicArray< T >::wdth [protected] |
the number of output columns
int PLib::BasicArray< T >::destruct [protected] |
specifies if the data should be destroyed on exit
int PLib::BasicArray< T >::sze [protected] |
the known size of the array
T* PLib::BasicArray< T >::x [protected] |
the data pointer