#include <TStaticArray.h>
Public Types | |
enum | { max_size = __MaxSize } |
typedef TStaticArray < __ValueType, __MaxSize > | _MyType |
typedef __Allocator | allocator |
typedef __Allocator::size_type | size_type |
typedef __Allocator::value_type | value_type |
typedef __Allocator::reference | reference |
typedef __Allocator::const_reference | const_reference |
typedef __Allocator::pointer | pointer |
typedef __Allocator::const_pointer | const_pointer |
typedef __Allocator::difference_type | difference_type |
typedef std::reverse_iterator < iterator > | reverse_iterator |
typedef std::reverse_iterator < const_iterator > | const_reverse_iterator |
Public Member Functions | |
TStaticArray () | |
TStaticArray (size_type initial_count) | |
TStaticArray (size_type initial_count, const value_type &val) | |
~TStaticArray () | |
size_type | capacity () const |
| |
size_type | size () const |
resize (size_type nNewSize) throw (overflow_error) | |
void | resize (size_type nNewSize, value_type value) throw (overflow_error) |
void | limit_size (size_type nNewSize) |
void | reserve (size_type nNewSize) throw (overflow_error) |
bool | empty () const |
bool | full () const |
const_reference | at (size_type index) const throw (out_of_range) |
reference | at (size_type index) throw (out_of_range) |
const_reference | operator[] (size_type index) const throw (out_of_range) |
reference | operator[] (size_type index) throw (out_of_range) |
const_reference | front () const throw (out_of_range) |
reference | front () throw (out_of_range) |
const_reference | back () const throw (out_of_range) |
reference | back () throw (out_of_range) |
void | push_back (const_reference value) throw (out_of_range) |
void | pop_back () throw (out_of_range) |
Delete last element. | |
bool | append (const_reference value) |
reference | append_element () throw (out_of_range) |
void | clear () |
const_iterator | begin () const |
iterator | begin () |
const_iterator | end () const |
iterator | end () |
const_iterator | final () const |
iterator | final () |
Protected Types | |
typedef value_type | value_array [__MaxSize] |
Type necessary to have the element array m_acValues as a reference to uninitialized raw memory m_data. | |
typedef value_array & | value_array_ref |
Protected Attributes | |
allocator | m_alloc |
size_type | m_nSize |
value_array_ref | m_acValues |
Classes | |
class | const_iterator |
constant bidirectional iterator More... | |
class | iterator |
bidirectional iterator (non const) More... | |
struct | value_memory |
Type that holds ram memory for one element. |
Template base for static arrays.
The template can hold up to __MaxSize data containers. This value can later be checked by enum max_size. The actual amount of valid or used data can be determined by using size().
For debugging purpose under Microsoft Visual Studio you might want to edit the debug helper file 'autoexp.dat' and add the following lines:
This class is distributed under the following license GNU Lesser General Public License, version 2.1.
Definition at line 121 of file TStaticArray.h.
typedef TStaticArray<__ValueType, __MaxSize> mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::_MyType |
type itself
Definition at line 124 of file TStaticArray.h.
typedef __Allocator mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::allocator |
allocator type
Definition at line 125 of file TStaticArray.h.
typedef __Allocator::size_type mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::size_type |
type used for size and indexing
Definition at line 126 of file TStaticArray.h.
typedef __Allocator::value_type mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::value_type |
value type
Definition at line 127 of file TStaticArray.h.
typedef __Allocator::reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::reference |
reference to value type
Definition at line 128 of file TStaticArray.h.
typedef __Allocator::const_reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::const_reference |
const
reference to value type
Definition at line 129 of file TStaticArray.h.
typedef __Allocator::pointer mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::pointer |
pointer to value type
Definition at line 130 of file TStaticArray.h.
typedef __Allocator::const_pointer mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::const_pointer |
const
pointer to value type
Definition at line 131 of file TStaticArray.h.
typedef __Allocator::difference_type mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::difference_type |
type used to calculate element position distances
Definition at line 132 of file TStaticArray.h.
typedef std::reverse_iterator<iterator> mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::reverse_iterator |
typedef std::reverse_iterator<const_iterator> mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::const_reverse_iterator |
typedef value_type mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::value_array[__MaxSize] [protected] |
Type necessary to have the element array m_acValues as a reference to uninitialized raw memory m_data.
Definition at line 1031 of file TStaticArray.h.
typedef value_array& mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::value_array_ref [protected] |
Definition at line 1033 of file TStaticArray.h.
anonymous enum |
mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::TStaticArray | ( | ) | [inline] |
default constructor sets size to zero
Definition at line 714 of file TStaticArray.h.
00720 : m_nSize(0)
mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::TStaticArray | ( | size_type | initial_count | ) | [inline, explicit] |
construct with initial amount of default elements
Definition at line 723 of file TStaticArray.h.
00723 { 00724 } 00725 00728 explicit TStaticArray(_IN size_type initial_count) 00729 : m_nSize(0) 00730 , m_acValues(reinterpret_cast<value_array_ref>(m_acData)) 00731 , m_alloc() 00732 { 00733 mbo_tsa_throw_if_not(out_of_range, initial_count <= __MaxSize);
mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::TStaticArray | ( | size_type | initial_count, | |
const value_type & | val | |||
) | [inline] |
construct with initial amount of specified elements
Definition at line 737 of file TStaticArray.h.
00743 : m_nSize(0) 00744 , m_acValues(reinterpret_cast<value_array_ref>(m_acData)) 00745 , m_alloc() 00746 { 00747 mbo_tsa_throw_if_not(out_of_range, initial_count <= __MaxSize);
mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::~TStaticArray | ( | ) | [inline] |
Definition at line 749 of file TStaticArray.h.
References mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::append().
00749 { 00750 append(val); 00751 } 00752 }
size_type mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::capacity | ( | ) | const [inline] |
Definition at line 758 of file TStaticArray.h.
References mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::max_size.
00759 { max_size = __MaxSize }; 00760
size_type mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::size | ( | ) | const [inline] |
Definition at line 765 of file TStaticArray.h.
Referenced by mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::limit_size().
mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::resize | ( | size_type | nNewSize | ) | throw (overflow_error) [inline] |
Fill the array with default values until its size is greater than or equal to a new size. If the new size is less than the current size then the back elements are deleted until the size equals the new size.
nNewSize | new size of the array |
bad_alloc | if no memory could be allocated | |
overflow_error | if no elements can be appended |
Definition at line 779 of file TStaticArray.h.
void mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::resize | ( | size_type | nNewSize, | |
value_type | value | |||
) | throw (overflow_error) [inline] |
Fill the array with a given value until its size is greater than or equal to a new size. If the new size is less than the current size then the back elements are deleted until the size equals the new size.
nNewSize | new size of the array | |
value | new value to append if necessary |
bad_alloc | if no memory could be allocated | |
overflow_error | if no elements can be appended |
Definition at line 794 of file TStaticArray.h.
00800 { 00801 if (nNewSize > max_size) 00802 { 00803 nNewSize = max_size; 00804 throw str::overflow_error("New size exceeds maximum size"); 00805 } 00806 while(size() < nNewSize) 00807 { 00808 push_back(value); 00809 }
void mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::limit_size | ( | size_type | nNewSize | ) | [inline] |
Ensure current size is equal or below a given limit
nNewSize | maximum size after call |
Definition at line 815 of file TStaticArray.h.
References mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::pop_back(), and mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::size().
void mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::reserve | ( | size_type | nNewSize | ) | throw (overflow_error) [inline] |
nNewSize | new reserved size. Actually this is only present for compatibility. |
overflow_error | if nNewSize > max_size |
Definition at line 828 of file TStaticArray.h.
bool mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::empty | ( | ) | const [inline] |
Definition at line 835 of file TStaticArray.h.
bool mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::full | ( | ) | const [inline] |
const_reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::at | ( | size_type | index | ) | const throw (out_of_range) [inline] |
index | of element to access |
const
reference to value at specified index out_of_range | if size() == 0 |
Definition at line 851 of file TStaticArray.h.
References mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_acValues, mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_nSize, and mbo_tsa_throw_if_not.
reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::at | ( | size_type | index | ) | throw (out_of_range) [inline] |
index | of element to access |
out_of_range | if index is invalid |
Definition at line 861 of file TStaticArray.h.
References mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_acValues, mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_nSize, and mbo_tsa_throw_if_not.
const_reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::operator[] | ( | size_type | index | ) | const throw (out_of_range) [inline] |
index | of element to access |
const
reference to value at specified index out_of_range | if size() == 0 |
Definition at line 871 of file TStaticArray.h.
References mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_acValues, mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_nSize, and mbo_tsa_throw_if_not.
reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::operator[] | ( | size_type | index | ) | throw (out_of_range) [inline] |
index | of element to access |
out_of_range | if index is invalid |
Definition at line 881 of file TStaticArray.h.
References mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_acValues, mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_nSize, and mbo_tsa_throw_if_not.
const_reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::front | ( | ) | const throw (out_of_range) [inline] |
const
reference to first element out_of_range | if size() == 0 |
Definition at line 890 of file TStaticArray.h.
reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::front | ( | ) | throw (out_of_range) [inline] |
out_of_range | if size() == 0 |
Definition at line 899 of file TStaticArray.h.
const_reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::back | ( | ) | const throw (out_of_range) [inline] |
const
reference to last element out_of_range | if size() == 0 |
Definition at line 908 of file TStaticArray.h.
reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::back | ( | ) | throw (out_of_range) [inline] |
out_of_range | if size() == 0 |
Definition at line 917 of file TStaticArray.h.
void mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::push_back | ( | const_reference | value | ) | throw (out_of_range) [inline] |
Append new data to end of array.
value | new data to append |
out_of_range | if size() >= __MaxSize |
Definition at line 928 of file TStaticArray.h.
void mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::pop_back | ( | ) | throw (out_of_range) [inline] |
Delete last element.
out_of_range | if size() == 0 |
Definition at line 937 of file TStaticArray.h.
Referenced by mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::limit_size().
bool mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::append | ( | const_reference | value | ) | [inline] |
Append new data set if possible.
value | new data to append |
Definition at line 948 of file TStaticArray.h.
Referenced by mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::~TStaticArray().
00954 { 00955 if (m_nSize < max_size) 00956 { 00957 m_alloc.construct(m_alloc.address(m_acValues[m_nSize++]), value); 00958 return true; 00959 }
reference mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::append_element | ( | ) | throw (out_of_range) [inline] |
out_of_range | if size() >= maxSize() |
Definition at line 964 of file TStaticArray.h.
Referenced by mbo::TStaticArrayEx< __ValueType, __MaxSize, __Allocator >::operator[]().
void mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::clear | ( | ) | [inline] |
const_iterator mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::begin | ( | ) | const [inline] |
iterator mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::begin | ( | ) | [inline] |
const_iterator mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::end | ( | ) | const [inline] |
Definition at line 997 of file TStaticArray.h.
iterator mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::end | ( | ) | [inline] |
Definition at line 1004 of file TStaticArray.h.
const_iterator mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::final | ( | ) | const [inline] |
Definition at line 1012 of file TStaticArray.h.
iterator mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::final | ( | ) | [inline] |
Definition at line 1020 of file TStaticArray.h.
allocator mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_alloc [protected] |
element allocator
Definition at line 1037 of file TStaticArray.h.
size_type mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_nSize [protected] |
current size (number of used or valid elements)
Definition at line 1038 of file TStaticArray.h.
Referenced by mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::at(), mbo::TStaticArrayEx< __ValueType, __MaxSize, __Allocator >::operator[](), and mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::operator[]().
value_array_ref mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::m_acValues [protected] |
element storage
Definition at line 1039 of file TStaticArray.h.
Referenced by mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::at(), mbo::TStaticArrayEx< __ValueType, __MaxSize, __Allocator >::operator[](), and mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::operator[]().
Hosted on code.google.com | © Marcus Börger | Generated on Fri Jan 18 21:21:14 2008 for MBO-lib by ![]() |