Main Page   Class Hierarchy   Compound List   File List   Compound Members  

PLib::BasicArray Class Template Reference

A basic templated array class. More...

#include <barray.h>

Inheritance diagram for PLib::BasicArray:

PLib::Vector PLib::CVector List of all members.

Public Types

typedef const T * const_iterator

Public Methods

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 & elem (const int i)
elem (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

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

Definition at line 134 of file barray.h.


Constructor & Destructor Documentation

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

default constructor.

Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 46 of file barray.cpp.

References destruct, and x.

Referenced by PLib::Vector< Point3Df >::Vector.

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

Definition at line 61 of file barray.cpp.

References destruct, resize, rsize, sze, wdth, and x.

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

Definition at line 97 of file barray.cpp.

References destruct, resize, rsize, sze, and x.

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 {\bf 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

Definition at line 83 of file barray.cpp.

References destruct, and x.

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

Definition at line 119 of file barray.cpp.

References BasicNode::data, destruct, BasicList::goToFirst, BasicList::goToNext, resize, rsize, BasicList::size, sze, and x.

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

destructor.

Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 139 of file barray.cpp.

References clear.


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

Definition at line 153 of file barray.cpp.

References rsize, sze, and x.

Referenced by ~BasicArray.

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

Parameters:
i  no range checks are performed

Definition at line 177 of file barray.h.

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.

Definition at line 164 of file barray.h.

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.

Definition at line 172 of file barray.cpp.

References resize, sze, and x.

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

Definition at line 339 of file barray.cpp.

References size, wdth, and x.

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

Definition at line 486 of file barray.cpp.

References n, resize, rsize, sze, and x.

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

Definition at line 216 of file barray.cpp.

References sze, and x.

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

Definition at line 152 of file barray.h.

Referenced by BasicArray, PLib::Vector::operator=, operator=, and push_back.

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

Definition at line 200 of file barray.cpp.

References rsize, and sze.

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

Parameters:
w  set output columns

Definition at line 185 of file barray.h.


Friends And Related Function Documentation

template<class T>
int operator!= const BasicArray< T > &   ,
const BasicArray< T > &   
[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

Definition at line 395 of file barray.cpp.

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

Definition at line 370 of file barray.cpp.

template<class T>
int operator== const BasicArray< T > &   ,
const BasicArray< T > &   
[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

Definition at line 424 of file barray.cpp.

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

Definition at line 301 of file barray.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 24 13:26:59 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002