PLib::BasicArray< T > Class Template Reference

A basic templated array class. More...

#include <barray.h>

Inheritance diagram for PLib::BasicArray< T >:

PLib::Vector< T > PLib::CVector< T > List of all members.

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)
operator= (const T val)
T & operator[] (const int i)
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)

Detailed Description

template<class T>
class PLib::BasicArray< T >

A basic templated array class.

This is a basis array class, the only particularity is that the resize is not destructive.

Author:
Philippe Lavoie
Date:
4 October 1996


Constructor & Destructor Documentation

template<class T>
PLib::BasicArray< T >::BasicArray  ) 
 

default constructor

Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
PLib::BasicArray< T >::BasicArray const int  ni  ) 
 

constructor with size specified

Parameters:
ni the size of the basic array
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
PLib::BasicArray< T >::BasicArray const BasicArray< T > &  f2  ) 
 

copy constructor

Parameters:
f2 the BasicArray to copy
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
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.

Parameters:
ap a pointer to an array
size the size of the ap array
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
PLib::BasicArray< T >::BasicArray BasicList< T > &  list  ) 
 

constructor from a linked list

Parameters:
list the linked list to copy
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
PLib::BasicArray< T >::~BasicArray  )  [virtual]
 

destructor

Author:
Philippe Lavoie
Date:
24 January 1997


Member Function Documentation

template<class T>
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.

Author:
Philippe Lavoie
Date:
17 September 1999

template<class T>
T* PLib::BasicArray< T >::memory  )  const [inline]
 

< returns the data pointer

template<class T>
int PLib::BasicArray< T >::n  )  const [inline]
 

< the perceived size of the array

template<class T>
T PLib::BasicArray< T >::operator= const T  val  )  [inline]
 

Parameters:
val  set all elements of the vector to val

Reimplemented in PLib::Vector< T >, PLib::Vector< HPoint_nD< float, N > >, PLib::Vector< float >, PLib::Vector< int >, PLib::Vector< HPoint_nD< T, N > >, and PLib::Vector< Point3Df >.

template<class T>
BasicArray< T > & PLib::BasicArray< T >::operator= const BasicArray< T > &  f2  ) 
 

assignment operator

Parameters:
f2 the BasicArray to copy from
Returns:
a reference to itself
Author:
Philippe Lavoie
Date:
24 January 1997

Reimplemented in PLib::Vector< T >, PLib::Vector< HPoint_nD< float, N > >, PLib::Vector< float >, PLib::Vector< int >, PLib::Vector< HPoint_nD< T, N > >, and PLib::Vector< Point3Df >.

template<class T>
T PLib::BasicArray< T >::operator[] const int  i  )  const [inline]
 

< no range checks are performed

Reimplemented in PLib::CVector< T >.

template<class T>
T& PLib::BasicArray< T >::operator[] const int  i  )  [inline]
 

Parameters:
i  no range checks are performed

template<class T>
ostream & PLib::BasicArray< T >::print ostream &  os  )  const
 

sends a BasicArray to an ostream

Sends a BasicArray to an ostream

Parameters:
os output stream
Returns:
os with arry piped into it.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
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

Parameters:
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.
Returns:
a reference to the element
Author:
Philippe Lavoie
Date:
12 September 1999

template<class T>
void PLib::BasicArray< T >::reset const T  val = 0.0  )  [virtual]
 

reset all values of the vetor to val

Parameters:
val resets the elements of the array to this value
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
void PLib::BasicArray< T >::resize const BasicArray< T > &  A  )  [inline]
 

Parameters:
A  resize the array with the same dimension of the vector A

template<class T>
int PLib::BasicArray< T >::size  )  const [inline]
 

< returns the size of the array

template<class T>
void PLib::BasicArray< T >::trim const int  nsize  ) 
 

shortens the array without destroying the components

Parameters:
nsize the new size of the vector
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
void PLib::BasicArray< T >::width const int  w  )  [inline]
 

Parameters:
w  set output columns


Friends And Related Function Documentation

template<class T>
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.

Parameters:
a the first array to compare
b the second array to compare
Returns:
1 if the arrays are {not} identical, 0 otherwise.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
ostream& operator<< ostream &  os,
const BasicArray< T > &  arry
[friend]
 

sends a BasicArray to the ostream

Parameters:
os output stream
arry the array to send to the stream
Returns:
os with arry piped into it.
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
int operator== const BasicArray< T > &  a,
const BasicArray< T > &  b
[friend]
 

checks if two arrays are identical

Parameters:
a the first array to compare
b the second array to compare
Returns:
1 if the arrays are identical, 0 otherwise
Warning:
Author:
Philippe Lavoie
Date:
24 January 1997

template<class T>
istream& operator>> istream &  is,
BasicArray< T > &  arry
[friend]
 

stores an input string into a vector

Parameters:
is the input stream
arry the array initialized by is
Returns:
is after setting arry
Author:
Philippe Lavoie
Date:
24 January 1997


Member Data Documentation

template<class T>
int PLib::BasicArray< T >::destruct [protected]
 

specifies if the data should be destroyed on exit

template<class T>
int PLib::BasicArray< T >::rsize [protected]
 

the actual size of the array

template<class T>
int PLib::BasicArray< T >::sze [protected]
 

the known size of the array

template<class T>
int PLib::BasicArray< T >::wdth [protected]
 

the number of output columns

template<class T>
T* PLib::BasicArray< T >::x [protected]
 

the data pointer


The documentation for this class was generated from the following files:
Generated on Tue Jun 20 07:10:14 2006 for NURBS++ by  doxygen 1.4.6