CArray_adaptor_base Class Template Reference
[Collections Library]

#include <mfcstl/collections/carray_adaptors.hpp>

Inheritance diagram for CArray_adaptor_base:

stl_collection_tag collection_tag CArray_cadaptor CArray_iadaptor

List of all members.


Detailed Description

template<typename A, typename I, typename T>
class mfcstl::CArray_adaptor_base< A, I, T >

Adaptor class, providing implementation for CArray_cadaptor and CArray_iadaptor classes.

Parameters:
A The array class, e.g. CObArray, CArray<long>, etc.
I The interface specialisation, e.g. CArray_cadaptor<CObArray>, CArray_iadaptor<CArray<long> >, etc.
T The traits class, e.g. CArray_traits<CObArray>
Note:
The elements in an adapted array are moved, during insertion / erasure, rather than copied. This means that if the elements in the container maintain pointers to their elements, or their peers, then they are not suitable for use.

Member Constants

enum  { growthGranularity = 16 }
static size_type calc_increment_ (size_type n)

Member Types

typedef A array_type
 The type of the underlying MFC array.
typedef
array_traits_type::value_type 
value_type
 The value type.
typedef afx_allocator< value_typeallocator_type
 The allocator type.
typedef allocator_type::reference reference
 The mutating (non-const) reference type.
typedef
allocator_type::const_reference 
const_reference
 The non-mutating (const) reference type.
typedef allocator_type::pointer pointer
 The mutating (non-const) pointer type.
typedef
allocator_type::const_pointer 
const_pointer
 The non-mutating (const) pointer type.
typedef pointer_iterator
< value_type, pointer,
reference >::type 
iterator
 The mutating (non-const) iterator type.
typedef pointer_iterator
< value_type const
, const_pointer,
const_reference >::type 
const_iterator
 The non-mutating (const) iterator type.
typedef size_t size_type
 The size type.
typedef ms_ptrdiff_t difference_type
 The difference type.
typedef CArray_adaptor_base< A,
I, T > 
class_type
 The instantiation of the current type.

Implementation

template<typename I2>
static bool is_valid_source_range_ (I2 first, I2 last, std::input_iterator_tag)
template<typename I2, typename T2>
static bool is_valid_source_range_ (I2 first, I2 last, T2)
template<typename I2>
static bool is_valid_source_range_ (I2 first, I2 last, std::random_access_iterator_tag)
template<typename I2>
static bool is_valid_source_range_ (I2 first, I2 last)

Construction

allocator_type get_allocator () const
 Returns a copy of the allocator used by the container.
 CArray_adaptor_base ()
 Default constructor.
 ~CArray_adaptor_base () throw ()
 Destructor.
size_type grow_increment () const
size_type capacity () const

Public Member Functions

Underlying Container Access
array_typeget_CArray ()
 Returns a mutating (non-const) reference to the underlying array.
array_type const & get_CArray () const
 Returns a non-mutating (const) reference to the underlying array.
Assignment
void assign (size_type n, value_type const &value)
 Assigns a number of copies of the given value to the array, erasing all prior content.
template<typename I2>
void assign (I2 first, I2 last)
 Assigns each element in the range [first, last) to the array, erasing all prior content.
Size and Capacity
size_type size () const
 The number of items in the array.
size_type max_size () const
 The maximum number of items that can be stored in the array.
bool empty () const
 Indicates whether the array is empty.
void resize (size_type n)
 Adjusts the number of elements in the array.
void resize (size_type n, value_type value)
 Adjusts the number of elements in the array.
Element access
reference operator[] (size_type n)
 Returns a mutable (non-const) reference to the element at the given index.
const_reference operator[] (size_type n) const
 Returns a non-mutable (const) reference to the element at the given index.
reference at (size_type n)
 Returns a mutable (non-const) reference to the element at the given index.
const_reference at (size_type n) const
 Returns a non-mutable (const) reference to the element at the given index.
reference front ()
 Returns a mutable (non-const) reference to the first element in the array.
reference back ()
 Returns a mutable (non-const) reference to the last element in the array.
const_reference front () const
 Returns a non-mutable (const) reference to the first element in the array.
const_reference back () const
 Returns a non-mutable (const) reference to the last element in the array.
Iteration
iterator begin ()
 Returns a mutable (non-const) iterator representing the start of the array.
iterator end ()
 Returns a mutable (non-const) iterator representing the end of the array.
const_iterator begin () const
 Returns a non-mutable (const) iterator representing the start of the array.
const_iterator end () const
 Returns a non-mutable (const) iterator representing the end of the array.
Comparison
template<typename A2, typename I2, typename T2>
bool equal (CArray_adaptor_base< A2, I2, T2 > const &rhs) const
bool equal (array_type const &rhs) const
template<typename A2, typename I2, typename T2>
bool less_than (CArray_adaptor_base< A2, I2, T2 > const &rhs) const
bool less_than (array_type const &rhs) const
template<typename A2, typename I2, typename T2>
bool greater_than (CArray_adaptor_base< A2, I2, T2 > const &rhs) const
bool greater_than (array_type const &rhs) const
Modifiers
void push_back (value_type const &value)
 Adds the given element to the end of the array.
void pop_back () throw ()
 Removes the last element from the non-empty array.
iterator insert (iterator pos, value_type const &value)
 Inserts the given value at the given position.
void insert (iterator pos, size_type n, value_type const &value)
 Inserts a number of copies of the given value at the given position.
template<typename I2>
void insert (iterator pos, I2 first, I2 last)
 Inserts the elements in the range [first, last) at the given position.
iterator erase (iterator pos) throw ()
 Erases the element at the given position.
iterator erase (iterator first, iterator last) throw ()
 Erases a range of elements from the array.
void clear () throw ()
 Removes all the elements from the array.
void swap_by_copy (class_type &rhs)
 Exchanges the contents with those of another array by copying each of the constituents, using a temporary array instance.

Member Typedef Documentation

typedef A array_type

The type of the underlying MFC array.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

typedef array_traits_type::value_type value_type

The value type.

Note:
If the compiler report "use of undefined type" when you're using the adaptor class(es) with CArray<>, ensure that you've included afxtempl before you include this file.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

The allocator type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

The mutating (non-const) reference type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

The non-mutating (const) reference type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

The mutating (non-const) pointer type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

The non-mutating (const) pointer type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

typedef pointer_iterator< value_type , pointer , reference >::type iterator

The mutating (non-const) iterator type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

typedef pointer_iterator< value_type const , const_pointer , const_reference >::type const_iterator

The non-mutating (const) iterator type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

typedef size_t size_type

The size type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

typedef ms_ptrdiff_t difference_type

The difference type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.

typedef CArray_adaptor_base<A, I, T> class_type

The instantiation of the current type.

Reimplemented in CArray_cadaptor, and CArray_iadaptor.


Constructor & Destructor Documentation

CArray_adaptor_base (  )  [inline, protected]

Default constructor.

This is protected, because CArray_adaptor_base serves as an abstract base for CArray_cadaptor and CArray_iadaptor

~CArray_adaptor_base (  )  throw () [inline, protected]

Destructor.


Member Function Documentation

array_type& get_CArray (  )  [inline]

Returns a mutating (non-const) reference to the underlying array.

array_type const& get_CArray (  )  const [inline]

Returns a non-mutating (const) reference to the underlying array.

allocator_type get_allocator (  )  const [inline]

Returns a copy of the allocator used by the container.

void assign ( size_type  n,
value_type const &  value 
) [inline]

Assigns a number of copies of the given value to the array, erasing all prior content.

Parameters:
n The number of values to assign
value The value of which n copies are to be assigned
Note:
Exception-safety is strong if MFCSTL_CARRAY_SWAP_MEMBERS_SUPPORT is defined, otherwise weak.

The elements are default constructed, and then copy-assigned

void assign ( I2  first,
I2  last 
) [inline]

Assigns each element in the range [first, last) to the array, erasing all prior content.

Parameters:
first The first element in the range
last The (one past the) last element in the range
Note:
Exception-safety is strong if MFCSTL_CARRAY_SWAP_MEMBERS_SUPPORT is defined, otherwise weak.

The elements are default constructed, and then copy-assigned

size_type size (  )  const [inline]

The number of items in the array.

size_type max_size (  )  const [inline]

The maximum number of items that can be stored in the array.

bool empty (  )  const [inline]

Indicates whether the array is empty.

void resize ( size_type  n  )  [inline]

Adjusts the number of elements in the array.

Parameters:
n The number of elements that the array will contain after resizing
Note:
Exception-safety is strong if the default constructor of the value type cannot throw exceptions, otherwise it is weak

void resize ( size_type  n,
value_type  value 
) [inline]

Adjusts the number of elements in the array.

Parameters:
n The number of elements that the array will contain after resizing
value The value of any additional elements created during resizing
Note:
Due to the limitations of the underlying CArray-family containers, the additional elements are default constructed and then subjected to copy-assignment.

Exception-safety is weak, but the size is maintained in the case where an exception is thrown by the copy assignment of any new elements.

reference operator[] ( size_type  n  )  [inline]

Returns a mutable (non-const) reference to the element at the given index.

Parameters:
n The requested index. Must be less than size()
Note:
The implementation will assert in debug mode if the index is out of range

const_reference operator[] ( size_type  n  )  const [inline]

Returns a non-mutable (const) reference to the element at the given index.

Parameters:
n The requested index. Must be less than size()
Note:
The implementation will assert in debug mode if the index is out of range

reference at ( size_type  n  )  [inline]

Returns a mutable (non-const) reference to the element at the given index.

Parameters:
n The requested index. If the index is not less than size() an instance of std::out_of_range will be thrown

const_reference at ( size_type  n  )  const [inline]

Returns a non-mutable (const) reference to the element at the given index.

Parameters:
n The requested index. If the index is not less than size() an instance of std::out_of_range will be thrown

reference front (  )  [inline]

Returns a mutable (non-const) reference to the first element in the array.

reference back (  )  [inline]

Returns a mutable (non-const) reference to the last element in the array.

const_reference front (  )  const [inline]

Returns a non-mutable (const) reference to the first element in the array.

const_reference back (  )  const [inline]

Returns a non-mutable (const) reference to the last element in the array.

iterator begin (  )  [inline]

Returns a mutable (non-const) iterator representing the start of the array.

Referenced by CArray_cadaptor::CArray_cadaptor().

iterator end (  )  [inline]

Returns a mutable (non-const) iterator representing the end of the array.

Referenced by CArray_cadaptor::CArray_cadaptor().

const_iterator begin (  )  const [inline]

Returns a non-mutable (const) iterator representing the start of the array.

const_iterator end (  )  const [inline]

Returns a non-mutable (const) iterator representing the end of the array.

void push_back ( value_type const &  value  )  [inline]

Adds the given element to the end of the array.

Parameters:
value The value to add to the end of the array
Note:
All iterators, pointers and references are invalidated

void pop_back (  )  throw () [inline]

Removes the last element from the non-empty array.

Note:
The behaviour is undefined if the array is empty

iterator insert ( iterator  pos,
value_type const &  value 
) [inline]

Inserts the given value at the given position.

Parameters:
pos The position at which to insert. The value will be inserted before the element referred to by pos, or at the end if pos == end()
value The value to be inserted
Return values:
The position of the inserted value
Note:
All iterators, pointers and references are invalidated

Any elements after the insertion position are moved using memmove, rather than by copy construction. If the element type maintains pointers to its internal members, or to its peer elements, then these relationships will be broken, and the subsequent behaviour of the program will be undefined

void insert ( iterator  pos,
size_type  n,
value_type const &  value 
) [inline]

Inserts a number of copies of the given value at the given position.

Parameters:
pos The position at which to insert. The value(s) will be inserted before the element referred to by pos, or at the end if pos == end()
n The number of values to insert
value The value to be inserted
Note:
All iterators, pointers and references are invalidated

Any elements after the insertion position are moved using memmove, rather than by copy construction. If the element type maintains pointers to its internal members, or to its peer elements, then these relationships will be broked, and the subsequent behaviour of the program will be undefined

void insert ( iterator  pos,
I2  first,
I2  last 
) [inline]

Inserts the elements in the range [first, last) at the given position.

Parameters:
pos The position at which to insert. The value(s) will be inserted before the element referred to by pos, or at the end if pos == end()
first The start of the range of values to insert
last The (one past the) end of the range of values to insert
Note:
All iterators, pointers and references are invalidated

Any elements after the insertion position are moved using memmove, rather than by copy construction. If the element type maintains pointers to its internal members, or to its peer elements, then these relationships will be broked, and the subsequent behaviour of the program will be undefined

iterator erase ( iterator  pos  )  throw () [inline]

Erases the element at the given position.

Parameters:
pos The position of the element to be removed
Return values:
The position of the value immediately following the element erased
Note:
Any iterators, pointers or references to elements at or after pos will be invalidated. Those before pos remain valid

Any elements after the erasure position are moved using memmove, rather than by copy construction. If the element type maintains pointers to its internal members, or to its peer elements, then these relationships will be broked, and the subsequent behaviour of the program will be undefined

iterator erase ( iterator  first,
iterator  last 
) throw () [inline]

Erases a range of elements from the array.

Parameters:
first The first element in the range to be removed
last The (one past the) end element in the range to be removed
Return values:
The position of the value immediately following the elements erased
Note:
Any iterators, pointers or references to elements at or after first will be invalidated. Those before first remain valid

Any elements after the erasure position are moved using memmove, rather than by copy construction. If the element type maintains pointers to its internal members, or to its peer elements, then these relationships will be broked, and the subsequent behaviour of the program will be undefined

void clear (  )  throw () [inline]

Removes all the elements from the array.

void swap_by_copy ( class_type rhs  )  [inline]

Exchanges the contents with those of another array by copying each of the constituents, using a temporary array instance.

Parameters:
rhs The instance whose contents will be exchanged with the callee


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

Generated on Thu Jun 10 08:58:30 2010 for STLSoft by  doxygen 1.5.6