Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

array_c Class Template Reference

Array class. More...

#include <array.h>


Public Methods

 array_c ()
 c'tor

virtual ~array_c ()
 d'tor

long get_free ()
 Get first free slot.

long add (T *ptr)
 Add an entry to the array.

void remove (long i)
 Remove an entry from the array.

void remove_ptr (T *ptr, bool all=true)
 Remove an entry from the array.

void set (long i, T *ptr)
 Set array entry.

T * get (long i)
 Get array entry.

long find (T *ptr)
 Find array entry.

long get_count ()
 Get entry count.

void clear ()
 Remove all elements.


Protected Attributes

T ** data
 the array itself

long count
 number of entries in array


Detailed Description

template<class T>
class array_c< T >

This is a self resizing array. It keeps pointers to instances of T and indicates an empty entry with NULL.

Definition at line 53 of file array.h.


Member Function Documentation

long add T *    ptr [inline]
 

Finds a free slot using get_free() and sets the entry at that index to ptr. The insertion index is returned.

Definition at line 99 of file array.h.

Referenced by octree_c::add_complete_node_to_array(), and octree_c::add_node_to_array().

void clear   [inline]
 

Removes all entries from the array.

Definition at line 236 of file array.h.

Referenced by octree_c::get_visible().

long find T *    ptr [inline]
 

Returns the index of the first found entry ptr. If no entry is found INVALID_INDEX is returned.

Definition at line 206 of file array.h.

T* get long    i [inline]
 

Returns the entry with the index i. If i is larger than the number of entries or negative NULL is returned.

Definition at line 190 of file array.h.

Referenced by brush_c::get_brush_face().

long get_count   [inline]
 

Returns the number of entries (including empty ones).

Definition at line 225 of file array.h.

long get_free   [inline]
 

Returns the first unused index in this array. If the array is full the entry count is returned.

Definition at line 80 of file array.h.

Referenced by array_c< brushface_c >::add().

void remove long    i [inline]
 

Sets the entry with index i to NULL. Thereby removing it from the array. The object is just removed from the array. It is not deleted.

Definition at line 119 of file array.h.

void remove_ptr T *    ptr,
bool    all = true
[inline]
 

If all is true all occurences of ptr in the array are removed. Otherwise the first found will be removed and other entries are left untouched.

Definition at line 135 of file array.h.

void set long    i,
T *    ptr
[inline]
 

Sets the array entry with index i to ptr. If i is larger than the number of entries, the array will be expanded to fit. Previous contents of the array stays untouched. All newly created entries are set to NULL. i may not be negative.

Definition at line 157 of file array.h.

Referenced by array_c< brushface_c >::add().


The documentation for this class was generated from the following file:
Generated on Wed Dec 18 15:48:49 2002 for omicron engine by doxygen1.2.18