mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append > Class Template Reference

dynamic array More...

#include <TDynamicArray.h>

Collaboration diagram for mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >:

Collaboration graph
{mbo::allocator\< __ValueType, __ReferenceType \>\n||+ address()\l+ address()\l+ allocate()\l+ deallocate()\l+ construct()\l+ max_size()\l}
[legend]

List of all members.

Public Types

typedef TDynamicArray
< __ValueType, __Allocator,
__MinSize, __Append > 
_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

 TDynamicArray (size_type nMinSize=__MinSize, size_type nAppend=__Append, size_type nMaxSize=0) throw ( bad_alloc )
 TDynamicArray (const TDynamicArray &oth) throw ( bad_alloc )
TDynamicArrayoperator= (const TDynamicArray &oth) throw ( bad_alloc )
virtual ~TDynamicArray () throw ( logic_error )
size_type size () const
bool empty () const
size_type capacity () const
size_type max_size () const
size_type append () const
const_reference operator[] (size_type index) const throw ( out_of_range )
reference operator[] (size_type index) throw ( out_of_range )
const_reference at (size_type index) const throw ( out_of_range )
reference at (size_type index) throw ( out_of_range )
const_reference back () const throw ( out_of_range )
reference back () throw ( out_of_range )
const_reference front () const throw ( out_of_range )
reference front () throw ( out_of_range )
void push_front (const_reference value) throw ( bad_alloc , overflow_error )
void pop_front () throw ( out_of_range )
void push_back (const_reference value) throw ( bad_alloc , overflow_error )
void pop_back () throw ( out_of_range )
const_iterator begin () const
iterator begin ()
const_iterator end () const
iterator end ()
const_reverse_iterator rbegin () const
reverse_iterator rbegin ()
const_reverse_iterator rend () const
reverse_iterator rend ()
void assign (size_type count, const_reference val)
template<class InputIterator>
void assign (InputIterator first, InputIterator end)
void erase (size_t where)
iterator erase (iterator where)
iterator erase (iterator first, iterator end)
void clear ()
 reserve (size_type nNewCapacity) throw ( bad_alloc , overflow_error )
void resize (size_type nNewSize) throw ( bad_alloc , overflow_error )
void resize (size_type nNewSize, value_type value) throw ( bad_alloc , overflow_error )
void limit_size (size_type nNewSize)

Protected Member Functions

void check_resize () throw ( bad_alloc , overflow_error )
void delete_at (size_type nPos) throw ( out_of_range )
void insert_at (size_type nPos, const_reference value) throw ( out_of_range )

Protected Attributes

allocator m_alloc
size_type m_nSize
size_type m_nCapacity
size_type m_nAppend
size_type m_nMaxSize
pointer m_acValues

Classes

class  const_iterator
 constant bidirectional iterator More...
class  iterator
 bidirectional iterator (non const) More...


Detailed Description

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
class mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >

dynamic array

Template base for dynamic arrays.

The type __ValueType has no restriction whatsoever. The allocator must be derived from reallocator.

Complexity:

Here + denotes some memory copy operation. Value n is the current number of elements and m is the number of elements to insert or remove.

See also:
MBO_THROWS_EXCEPTIONS

MBO_TDA_VERIFY

MBO_TDA_STL_ITERATOR

Definition at line 133 of file TDynamicArray.h.


Member Typedef Documentation

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef TDynamicArray<__ValueType, __Allocator, __MinSize, __Append> mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::_MyType

type itself

Definition at line 137 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef __Allocator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::allocator

allocator type

Definition at line 138 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef __Allocator::size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::size_type

type used for size and indexing

Definition at line 139 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef __Allocator::value_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::value_type

value type

Definition at line 140 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef __Allocator::reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::reference

reference to value type

Definition at line 141 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef __Allocator::const_reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::const_reference

const reference to value type

Definition at line 142 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef __Allocator::pointer mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::pointer

pointer to value type

Definition at line 143 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef __Allocator::const_pointer mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::const_pointer

const pointer to value type

Definition at line 144 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef __Allocator::difference_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::difference_type

type used to calculate element position distances

Definition at line 145 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef std::reverse_iterator<iterator> mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::reverse_iterator

reverse iterator

See also:
MBO_TDA_STL_ITERATOR

Definition at line 689 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
typedef std::reverse_iterator<const_iterator> mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::const_reverse_iterator

const reverse iterator

See also:
MBO_TDA_STL_ITERATOR

Definition at line 698 of file TDynamicArray.h.


Constructor & Destructor Documentation

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::TDynamicArray ( size_type  nMinSize = __MinSize,
size_type  nAppend = __Append,
size_type  nMaxSize = 0 
) throw ( bad_alloc ) [inline, explicit]

Default constructor

If nAppend is set to 0 then nSize specifies the maximum size of the array.

Parameters:
nMinSize initial element capacity
nAppend number of elements to append if size exceeds
nMaxSize maximum capacity (zero results in the theoretical limit specified by the allocator).
Exceptions:
bad_alloc if no memory could be allocated

Definition at line 713 of file TDynamicArray.h.

00723         : m_alloc()
00724         , m_nSize(0)
00725         , m_nCapacity(nMinSize)
00726         , m_nAppend(  nAppend)
00727         , m_nMaxSize( nMaxSize ? nMaxSize : m_alloc.max_size())
00728         , m_acValues(0L)
00729     {
00730         if (m_nCapacity)

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::TDynamicArray ( const TDynamicArray< __ValueType, __Allocator, __MinSize, __Append > &  oth  )  throw ( bad_alloc ) [inline]

copy constructor

Parameters:
oth array to copy from
Exceptions:
bad_alloc if no memory could be allocated

Definition at line 737 of file TDynamicArray.h.

00743         : m_alloc(oth.m_alloc)
00744         , m_nSize(0)
00745         , m_nCapacity(0)
00746         , m_nAppend(  oth.append())

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
virtual mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::~TDynamicArray (  )  throw ( logic_error ) [inline, virtual]

Free all allocated elements

Exceptions:
logic_error if the element space was not cleared and freed.

Definition at line 763 of file TDynamicArray.h.

References mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::clear().

00769     {

Here is the call graph for this function:

mbo::TDynamicArray::clear


Member Function Documentation

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
TDynamicArray& mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::operator= ( const TDynamicArray< __ValueType, __Allocator, __MinSize, __Append > &  oth  )  throw ( bad_alloc ) [inline]

assignment operator

Parameters:
oth array to copy from
Exceptions:
bad_alloc if no memory could be allocated

Definition at line 753 of file TDynamicArray.h.

00759     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::size (  )  const [inline]

Returns:
the number of currently used or valid elements

Definition at line 771 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::limit_size().

00777     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
bool mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::empty (  )  const [inline]

Returns:
whether the array is empty (e.g. size() == 0).

Definition at line 778 of file TDynamicArray.h.

00784     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::capacity (  )  const [inline]

Returns:
the current maximum number of elements

Definition at line 785 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::assign().

00791     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::max_size (  )  const [inline]

Returns:
the theoretical maximum capacity

Definition at line 792 of file TDynamicArray.h.

00798     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::append (  )  const [inline]

Returns:
number of element places appended if resizing is necessary

Definition at line 799 of file TDynamicArray.h.

00805     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
const_reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::operator[] ( size_type  index  )  const throw ( out_of_range ) [inline]

Parameters:
index of element to access (read only)
Returns:
const reference to value at specified index
Exceptions:
out_of_range if index is invalid

Definition at line 808 of file TDynamicArray.h.

References mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_acValues, mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_nSize, and mbo_tda_throw_if_not.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::at().

00814     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::operator[] ( size_type  index  )  throw ( out_of_range ) [inline]

Parameters:
index of element to access (read/write)
Returns:
reference to value at specified index
Exceptions:
out_of_range if index is invalid

Definition at line 818 of file TDynamicArray.h.

References mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_acValues, mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_nSize, and mbo_tda_throw_if_not.

00824     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
const_reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::at ( size_type  index  )  const throw ( out_of_range ) [inline]

Parameters:
index of element to access (read only)
Returns:
const reference to value at specified index
Exceptions:
out_of_range if index is invalid

Definition at line 828 of file TDynamicArray.h.

References mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::operator[]().

00834     {

Here is the call graph for this function:

mbo::TDynamicArray::operator[]

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::at ( size_type  index  )  throw ( out_of_range ) [inline]

Parameters:
index of element to access (read/write)
Returns:
reference to value at specified index
Exceptions:
out_of_range if index is invalid

Definition at line 837 of file TDynamicArray.h.

References mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::operator[]().

00843     {

Here is the call graph for this function:

mbo::TDynamicArray::operator[]

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
const_reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::back (  )  const throw ( out_of_range ) [inline]

Returns:
const reference to first element
Exceptions:
out_of_range if size() == 0

Definition at line 845 of file TDynamicArray.h.

00851     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::back (  )  throw ( out_of_range ) [inline]

Returns:
reference to first element
Exceptions:
out_of_range if size() == 0

Definition at line 854 of file TDynamicArray.h.

00860     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
const_reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::front (  )  const throw ( out_of_range ) [inline]

Returns:
const reference to last element
Exceptions:
out_of_range if size() == 0

Definition at line 863 of file TDynamicArray.h.

00869     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
reference mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::front (  )  throw ( out_of_range ) [inline]

Returns:
reference to last element
Exceptions:
out_of_range if size() == 0

Definition at line 872 of file TDynamicArray.h.

00878     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::push_front ( const_reference  value  )  throw ( bad_alloc , overflow_error ) [inline]

Append new data at beginning of array.

Parameters:
value new data to append
Exceptions:
bad_alloc if no memory could be allocated
overflow_error if no elements can be appended

Definition at line 884 of file TDynamicArray.h.

00890     {
00891         check_resize();
00892         
00893         if (m_nSize)
00894         {
00895             m_alloc.move(m_alloc.address(m_acValues[1]), m_alloc.address(m_acValues[0]), m_nSize);

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::pop_front (  )  throw ( out_of_range ) [inline]

Drops the first element

Exceptions:
out_of_range if size() == 0

Definition at line 900 of file TDynamicArray.h.

00906     {
00907         mbo_tda_throw_if_not(out_of_range, m_nSize > 0);
00908 
00909         delete_at(0);
00910 

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::push_back ( const_reference  value  )  throw ( bad_alloc , overflow_error ) [inline]

Append new data at end of array.

Parameters:
value new data to append
Exceptions:
bad_alloc if no memory could be allocated
overflow_error if no elements can be appended

Definition at line 918 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::assign().

00924     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::pop_back (  )  throw ( out_of_range ) [inline]

Drops the last element

Exceptions:
out_of_range if size() == 0

Definition at line 928 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::limit_size().

00934     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
const_iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::begin (  )  const [inline]

Returns:
const iterator initialized to first element

Definition at line 937 of file TDynamicArray.h.

00943     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::begin (  )  [inline]

Returns:
iterator initialized to first element

Definition at line 944 of file TDynamicArray.h.

00950     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
const_iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::end (  )  const [inline]

Returns:
const iterator that points beyond the end of the used elements

Definition at line 951 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::rbegin().

00957     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::end (  )  [inline]

Returns:
iterator that points beyond the end of the used elements

Definition at line 958 of file TDynamicArray.h.

00964     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
const_reverse_iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::rbegin (  )  const [inline]

Returns:
const reverse iterator initialized to first (last in array) element
See also:
MBO_TDA_STL_ITERATOR

Definition at line 968 of file TDynamicArray.h.

References mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::end().

00974     {

Here is the call graph for this function:

mbo::TDynamicArray::end

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
reverse_iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::rbegin (  )  [inline]

Returns:
reverse iterator initialized to first (last in array) element
See also:
MBO_TDA_STL_ITERATOR

Definition at line 976 of file TDynamicArray.h.

00982     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
const_reverse_iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::rend (  )  const [inline]

Returns:
const reverse iterator that points beyond the end of the used elements
See also:
MBO_TDA_STL_ITERATOR

Definition at line 984 of file TDynamicArray.h.

00990     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
reverse_iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::rend (  )  [inline]

Returns:
reverse iterator that points beyond the end of the used elements
See also:
MBO_TDA_STL_ITERATOR

Definition at line 992 of file TDynamicArray.h.

00998     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::assign ( size_type  count,
const_reference  val 
) [inline]

Clear and assign a number of elements

Parameters:
count number of elements to assign
val value of new elements

Definition at line 1002 of file TDynamicArray.h.

References mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::capacity(), mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::clear(), mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::push_back(), and mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::reserve().

01008     {
01009         clear();
01010         if (count > capacity())
01011         {
01012             reserve(count);
01013         }

Here is the call graph for this function:

mbo::TDynamicArray::capacitymbo::TDynamicArray::clearmbo::TDynamicArray::push_backmbo::TDynamicArray::reserve

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
template<class InputIterator>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::assign ( InputIterator  first,
InputIterator  end 
) [inline]

Clear and assign from iterators

Parameters:
first start of sequence to assign to array
end element beyond seqence (first element not to assign or end)

Definition at line 1020 of file TDynamicArray.h.

01026     {
01027         clear();
01028         if (static_cast<size_type>(end - first) > capacity())
01029         {
01030             reserve(end - first);
01031         }
01032         while(first != end)

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::erase ( size_t  where  )  [inline]

Delete a single element from the array

Parameters:
where index of element to delete
Returns:
iterator pointing to element beyond the removed element or to the end of the array

Definition at line 1039 of file TDynamicArray.h.

01045     {
01046         mbo_tda_throw_if_not(logic_error, where < m_nSize);
01047         if (where == 0)
01048         {
01049             pop_front();
01050         }
01051         else if (where + 1 == m_nSize)
01052         {
01053             pop_back();
01054         }
01055         else
01056         {
01057             delete_at(where);
01058 
01059             if (--m_nSize)

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::erase ( iterator  where  )  [inline]

Delete a single element from the array

Parameters:
where iterator designating the element to delete
Returns:
iterator pointing to element beyond the removed element or to the end of the array

Definition at line 1066 of file TDynamicArray.h.

01072     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
iterator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::erase ( iterator  first,
iterator  end 
) [inline]

Parameters:
first start of element range to remove
end element beyond range to delete
Returns:
iterator pointing to element beyond the removed element or to the end of the array

Definition at line 1077 of file TDynamicArray.h.

01083     {
01084         size_type nLength = end - first;
01085 
01086         if (nLength == 1)
01087         {
01088             return erase(first);
01089         }
01090         else if (nLength)
01091         {
01092             size_type nStart = first - begin();
01093             size_type nPos   = nStart + nLength;
01094 
01095             while(nPos > nStart)
01096             {
01097                 delete_at(--nPos);
01098             }
01099 
01100             m_nSize -= nLength;
01101 
01102             if (m_nSize)
01103             {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::clear (  )  [inline]

Destruct all elements and free the element space and set m_nCapacity to zero.

Note:
calls clear for unused elements too.

Definition at line 1110 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::assign(), and mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::~TDynamicArray().

01116     {
01117         while(m_nSize)
01118         {
01119             m_alloc.destroy(m_alloc.address(m_acValues[--m_nSize]));
01120         }
01121         if (m_acValues)
01122         {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::reserve ( size_type  nNewCapacity  )  throw ( bad_alloc , overflow_error ) [inline]

Set new capacity. Value must be greater than or equal size().

Parameters:
nNewCapacity new maximum number of elements
Exceptions:
bad_alloc if no memory could be allocated
overflow_error if no elements can be appended

Definition at line 1131 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::assign().

01137     {
01138         mbo_tda_throw_if_not(overflow_error, nNewCapacity >= m_nSize && nNewCapacity <= max_size());
01139 
01140         pointer pNewValues = m_alloc.reallocate(m_acValues, m_nCapacity, nNewCapacity);
01141 

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::resize ( size_type  nNewSize  )  throw ( bad_alloc , 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.

Parameters:
nNewSize new size of the array
Exceptions:
bad_alloc if no memory could be allocated
overflow_error if no elements can be appended

Definition at line 1152 of file TDynamicArray.h.

01158     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::resize ( size_type  nNewSize,
value_type  value 
) throw ( bad_alloc , overflow_error ) [inline]

Fill the array with a given 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.

Parameters:
nNewSize new size of the array
value new value to append if necessary
Exceptions:
bad_alloc if no memory could be allocated
overflow_error if no elements can be appended

Definition at line 1167 of file TDynamicArray.h.

01173     {
01174         while(size() < nNewSize)
01175         {
01176             push_back(value);
01177         }

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::limit_size ( size_type  nNewSize  )  [inline]

Ensure current size is equal or below a given limit

Parameters:
nNewSize maximum size after call

Definition at line 1183 of file TDynamicArray.h.

References mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::pop_back(), and mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::size().

01189     {

Here is the call graph for this function:

mbo::TDynamicArray::pop_backmbo::TDynamicArray::size

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::check_resize (  )  throw ( bad_alloc , overflow_error ) [inline, protected]

Check whether adding a new element requires array reallocation. If necessary do so.

Exceptions:
bad_alloc if no memory could be allocated
overflow_error if no elements can be appended

Definition at line 1199 of file TDynamicArray.h.

01205     {   
01206         if (m_nSize == m_nCapacity)
01207         {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::delete_at ( size_type  nPos  )  throw ( out_of_range ) [inline, protected]

Delete an element at a given position (no destruction)

Parameters:
nPos position to delete
Exceptions:
out_of_range if nPos is invalid
Warning:
No further checks or move operations are done.

Definition at line 1216 of file TDynamicArray.h.

01222     {

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
void mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::insert_at ( size_type  nPos,
const_reference  value 
) throw ( out_of_range ) [inline, protected]

Insert an element to a given position (use assignment)

Parameters:
nPos position to insert at
value element to insert
Exceptions:
out_of_range if nPos is invalid
Warning:
No further checks or move operations are done.

Definition at line 1230 of file TDynamicArray.h.

01236     {


Member Data Documentation

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
allocator mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_alloc [protected]

element allocator

Definition at line 1236 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_nSize [protected]

current size (number of used or valid elements)

Definition at line 1237 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::operator[]().

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_nCapacity [protected]

current max size (m_nCapacity >= m_nSize)

Definition at line 1238 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_nAppend [protected]

number of elements added out of element space

Definition at line 1239 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
size_type mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_nMaxSize [protected]

maximum allowed capacity

Definition at line 1240 of file TDynamicArray.h.

template<class __ValueType, class __Allocator = mem_reallocator<__ValueType>, typename __Allocator::size_type __MinSize = 8, typename __Allocator::size_type __Append = 8>
pointer mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::m_acValues [protected]

element storage (array)

Definition at line 1241 of file TDynamicArray.h.

Referenced by mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::operator[]().


The documentation for this class was generated from the following file:
  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:14 2008 for MBO-lib by doxygen 1.5.4