simple_array Class Template Reference

#include <array.hpp>

Inheritance diagram for simple_array:

Inheritance graph
[legend]
Collaboration diagram for simple_array:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<typename T>
class gsgl::data::simple_array< T >

A simple dynamic array.

This kind of array should only be used to store simple types (integers & pointers), as it copies its memory around and doesn't call copy constructors, etc. Pointers to items in the array will probably swiftly become invalid!

Definition at line 75 of file array.hpp.


Public Member Functions

virtual bool contains_index (const I &) const =0
virtual bool is_empty () const
 Returns true if the collection is empty.
virtual T & item (const I &index)=0
virtual const T & item (const I &index) const =0
simple_arrayoperator= (const simple_array &a)
T & operator[] (const I &index)
const T & operator[] (const I &index) const
 simple_array (const simple_array &a)
 simple_array (const gsgl::index_t &initial_capacity=0)
virtual ~simple_array ()
Other Useful Functions
virtual void append (const iterable< T, IBase > &)
 Append all members of a collection to this one.
virtual iterator find_value (const T &)
virtual const_iterator find_value (const T &) const
 A generic find function that iterates over the collection to find a particular value.
Iterable Implementation
virtual void append (const T &)
 Add an item to the end of the collection.
virtual void insert (const iterator &i, const T &item)
 Insert an item before the one specified by the iterator.
virtual void remove (const iterator &i)
 Remove the item specified by the iterator.
Countable Implementation
virtual void clear ()
 Clears the contents of the collection.
virtual gsgl::index_t size () const
 A generic count function that iterates over the collection.
Indexable Implementation
virtual bool contains_index (const gsgl::index_t &index) const
virtual T & item (const gsgl::index_t &index)
virtual const T & item (const gsgl::index_t &index) const
Array Functionality
void insert (const T &item, const typename index_t &index)
T * ptr ()
const T * ptr () const
void remove (const typename index_t &index)
Iterators
iterator iter ()
const_iterator iter () const

Protected Member Functions

void * allocate (const gsgl::index_t &num_bytes)
void copy (void *dest, void *src, const gsgl::index_t &num_bytes)
void deallocate (void *)
void move (void *dest, void *src, const gsgl::index_t &num_bytes)
void * reallocate (void *, const gsgl::index_t &num_bytes)
void resize (const gsgl::index_t &new_num_elements)
void set (void *dest, const unsigned char &val, const gsgl::index_t &num_bytes)

Private Attributes

gsgl::index_t capacity
 The capacity of the array.
T * data
gsgl::index_t num_elements
 The highest index referenced so far plus one.

Constructor & Destructor Documentation

simple_array ( const gsgl::index_t initial_capacity = 0  )  [inline]

Definition at line 135 of file array.hpp.

References array_base::allocate(), and simple_array::data.

simple_array ( const simple_array< T > &  a  ) 

~simple_array (  )  [inline, virtual]

Definition at line 186 of file array.hpp.

References simple_array::data, and array_base::deallocate().


Member Function Documentation

void * allocate ( const gsgl::index_t num_bytes  )  [protected, inherited]

Definition at line 45 of file array.cpp.

Referenced by simple_array::simple_array().

void append ( const iterable< T, IBase > &  a  )  [inline, virtual, inherited]

Append all members of a collection to this one.

Definition at line 145 of file iterable.hpp.

void append ( const T &   )  [inline, virtual]

virtual void clear (  )  [inline, virtual]

Clears the contents of the collection.

Implements countable.

Definition at line 97 of file array.hpp.

Referenced by string::clear(), pqueue::clear(), config_record::from_stream(), string_impl::get_c_string(), and string_impl::get_p_string().

virtual bool contains_index ( const I &   )  const [pure virtual, inherited]

Implemented in dictionary.

virtual bool contains_index ( const gsgl::index_t index  )  const [inline, virtual]

Definition at line 114 of file array.hpp.

void copy ( void *  dest,
void *  src,
const gsgl::index_t num_bytes 
) [protected, inherited]

Definition at line 69 of file array.cpp.

void deallocate ( void *  ptr  )  [protected, inherited]

Definition at line 57 of file array.cpp.

Referenced by simple_array::~simple_array().

iterable< T, IBase >::iterator find_value ( const T &  item  )  [inline, virtual, inherited]

Definition at line 168 of file iterable.hpp.

References iterable::iterator::is_valid().

iterable< T, IBase >::const_iterator find_value ( const T &  item  )  const [inline, virtual, inherited]

A generic find function that iterates over the collection to find a particular value.

Note:
Not efficient; should be overridden if possible.

Definition at line 153 of file iterable.hpp.

References iterable::const_iterator::is_valid().

Referenced by gsgl::data::global_unregister_resource_aux().

void insert ( const T &  item,
const typename index_t index 
)

void insert ( const iterator ,
const T &   
) [inline, virtual]

Insert an item before the one specified by the iterator.

Implements iterable.

Definition at line 201 of file array.hpp.

Referenced by string::insert(), and pqueue::push().

virtual bool is_empty (  )  const [inline, virtual, inherited]

virtual T& item ( const I &  index  )  [pure virtual, inherited]

Implemented in dictionary.

virtual const T& item ( const I &  index  )  const [pure virtual, inherited]

T & item ( const gsgl::index_t index  )  [inline, virtual]

Definition at line 225 of file array.hpp.

References simple_array::data, simple_array::num_elements, and simple_array::resize().

const T & item ( const gsgl::index_t index  )  const [inline, virtual]

Definition at line 215 of file array.hpp.

References simple_array::data, and simple_array::num_elements.

Referenced by string::item(), and simple_stack::top().

iterator iter (  )  [inline, inherited]

Returns:
An iterator pointing to the first item in the collection.

Definition at line 101 of file iterable.hpp.

const_iterator iter (  )  const [inline, inherited]

void move ( void *  dest,
void *  src,
const gsgl::index_t num_bytes 
) [protected, inherited]

Definition at line 63 of file array.cpp.

simple_array& operator= ( const simple_array< T > &  a  ) 

T& operator[] ( const I &  index  )  [inline, inherited]

Definition at line 58 of file indexable.hpp.

const T& operator[] ( const I &  index  )  const [inline, inherited]

Definition at line 57 of file indexable.hpp.

T* ptr (  )  [inline]

Definition at line 121 of file array.hpp.

const T* ptr (  )  const [inline]

void * reallocate ( void *  ptr,
const gsgl::index_t num_bytes 
) [protected, inherited]

Definition at line 51 of file array.cpp.

Referenced by simple_array::resize().

void remove ( const typename index_t index  ) 

void remove ( const iterator  )  [inline, virtual]

Remove the item specified by the iterator.

Implements iterable.

Definition at line 208 of file array.hpp.

Referenced by pqueue::pop(), string::remove(), and pqueue::remove().

void resize ( const gsgl::index_t new_num_elements  )  [inline, protected]

void set ( void *  dest,
const unsigned char &  val,
const gsgl::index_t num_bytes 
) [protected, inherited]

Definition at line 75 of file array.cpp.

virtual gsgl::index_t size (  )  const [inline, virtual]

A generic count function that iterates over the collection.

Note:
Not very efficient; should be overridden if possible.

Reimplemented from iterable.

Definition at line 96 of file array.hpp.

Referenced by string::append(), vehicle::calculate_inertia_tensor(), shader_base::compile(), stellar_db::draw(), spherical_quadtree::get_new_vertex_index(), node_relative_path::initialize(), simple_stack::pop(), string::size(), pqueue::size(), simple_stack::top(), and stellar_db::~stellar_db().


Member Data Documentation

The capacity of the array.

Definition at line 82 of file array.hpp.

Referenced by simple_array::resize().

T* data [private]


The documentation for this class was generated from the following file:

Generated on Sat Mar 1 13:50:06 2008 for Periapsis Project by  doxygen 1.5.5