#include <array.hpp>
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_array & | operator= (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. |
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().
void * allocate | ( | const gsgl::index_t & | num_bytes | ) | [protected, inherited] |
void append | ( | const T & | ) | [inline, virtual] |
Add an item to the end of the collection.
Implements iterable.
Definition at line 193 of file array.hpp.
References simple_array::data, simple_array::num_elements, and simple_array::resize().
Referenced by stellar_db::add_star_name(), string::append(), vehicle::calculate_inertia_tensor(), string::clear(), treebox::clear_tree_nodes(), shader_base::compile(), config_record::from_stream(), string_impl::get_c_string(), string_impl::get_p_string(), mesh_file::load_obj_file(), simple_stack::push(), string::string(), and string_impl::string_impl().
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] |
void copy | ( | void * | dest, | |
void * | src, | |||
const gsgl::index_t & | num_bytes | |||
) | [protected, inherited] |
void deallocate | ( | void * | ptr | ) | [protected, inherited] |
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.
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] |
Returns true if the collection is empty.
Definition at line 59 of file countable.hpp.
Referenced by application::application(), broker_creator::broker_creator(), config_variable< gsgl::platform::color >::config_variable(), file::file(), font_impl::font_impl(), config_record::from_stream(), application::get_config_overrides(), node::get_name(), brokered_object::get_type_name(), event_map::load_keyboard_events(), application::load_scenery(), model_part::model_part(), package::package(), physics_frame::physics_frame(), solar_system::solar_system(), stellar_db::stellar_db(), and vehicle::vehicle().
virtual T& item | ( | const I & | index | ) | [pure virtual, inherited] |
Implemented in dictionary.
virtual const T& item | ( | const I & | index | ) | const [pure virtual, inherited] |
Implemented in dictionary.
Referenced by indexable< gsgl::data::log_target *, unsigned int >::operator[]().
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] |
Definition at line 101 of file iterable.hpp.
const_iterator iter | ( | ) | const [inline, inherited] |
Definition at line 100 of file iterable.hpp.
Referenced by config_variable::assign_from_string(), treebox::clear_tree_nodes(), keplerian_element_propagator::get_array(), config_record::get_child(), satellite_element_propagator::get_elements(), application::load_scenery(), list::operator==(), dictionary::operator==(), config_record::override_with(), vector::parse(), transform::parse(), application::remove_viewpoint_nodes(), config_record::to_stream(), vector::vector(), application::~application(), and cache::~cache().
void move | ( | void * | dest, | |
void * | src, | |||
const gsgl::index_t & | num_bytes | |||
) | [protected, inherited] |
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.
const T* ptr | ( | ) | const [inline] |
Definition at line 120 of file array.hpp.
Referenced by string::append(), shader_base::compile(), config_record::from_stream(), string_impl::get_c_string(), string_impl::get_p_string(), string_impl::get_w_string(), string::make_lower(), string::make_upper(), string::string(), string_impl::string_impl(), string::substring(), and string::to_bool().
void * reallocate | ( | void * | ptr, | |
const gsgl::index_t & | num_bytes | |||
) | [protected, inherited] |
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] |
Definition at line 258 of file array.hpp.
References simple_array::capacity, simple_array::data, simple_array::num_elements, and array_base::reallocate().
Referenced by simple_array::append(), simple_array< gsgl::data::dictionary< T, I >::dict_node * >::clear(), simple_array::item(), and simple_stack::pop().
void set | ( | void * | dest, | |
const unsigned char & | val, | |||
const gsgl::index_t & | num_bytes | |||
) | [protected, inherited] |
virtual gsgl::index_t size | ( | ) | const [inline, virtual] |
A generic count function that iterates over the collection.
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().
gsgl::index_t capacity [private] |
The capacity of the array.
Definition at line 82 of file array.hpp.
Referenced by simple_array::resize().
T* data [private] |
Definition at line 85 of file array.hpp.
Referenced by simple_array::append(), simple_array::item(), simple_array< gsgl::data::dictionary< T, I >::dict_node * >::ptr(), simple_array::resize(), simple_array::simple_array(), and simple_array::~simple_array().
gsgl::index_t num_elements [private] |
The highest index referenced so far plus one.
Definition at line 83 of file array.hpp.
Referenced by simple_array::append(), simple_array< gsgl::data::dictionary< T, I >::dict_node * >::clear(), simple_array< gsgl::data::dictionary< T, I >::dict_node * >::contains_index(), simple_array::item(), simple_array::resize(), and simple_array< gsgl::data::dictionary< T, I >::dict_node * >::size().