VCF::OrderedEnumerator< ItemType, CollectionType > Class Template Reference
The
OrderedEnumerator is a utility class that makes it easy to use a specific stl collection class (like a vector) and have support for the
Enumerator interface.
More...
#include <vcf/FoundationKit/Enumerator.h>
Inheritance diagram for VCF::OrderedEnumerator< ItemType, CollectionType >:
List of all members.
|
Public Types |
| typedef CollectionType | CollectionT |
| typedef ItemType | ItemT |
typedef EnumeratorContainer<
CollectionT, ItemT > | BaseT |
| typedef Enumerator< ItemT > | EnumeratorT |
| typedef _typename_ CollectionT::iterator | iterator |
| typedef _typename_ CollectionT::const_iterator | const_iterator |
| typedef _typename_ CollectionT::size_type | size_type |
| typedef _typename_ CollectionT::difference_type | difference_type |
| typedef _typename_ CollectionT::reference | reference |
| typedef _typename_ CollectionT::const_reference | const_reference |
| typedef _typename_ CollectionT::value_type | value_type |
| typedef _typename_ CollectionT::reverse_iterator | reverse_iterator |
| typedef _typename_ CollectionT::const_reverse_iterator | const_reverse_iterator |
Public Member Functions |
| | OrderedEnumerator () |
| | OrderedEnumerator (const OrderedEnumerator &rhs) |
| | operator CollectionT & () |
| | operator const CollectionT & () const |
| CollectionT & | get () |
| const CollectionT & | get () const |
| void | clear () |
| size_t | size () const |
| bool | empty () const |
| iterator | begin () |
| const_iterator | begin () const |
| void | reserve (size_type n) |
| size_type | capacity () const |
| iterator | end () |
| const_iterator | end () const |
| reverse_iterator | rbegin () |
| const_reverse_iterator | rbegin () const |
| reverse_iterator | rend () |
| const_reverse_iterator | rend () const |
| void | resize (size_type n, ItemType x=ItemType()) |
| size_type | max_size () const |
| reference | at (size_type pos) |
| const_reference | at (size_type pos) const |
| reference | operator[] (size_type pos) |
| const_reference | operator[] (size_type pos) const |
| reference | front () |
| const_reference | front () const |
| reference | back () |
| const_reference | back () const |
| void | push_back (const ItemType &x) |
| void | pop_back () |
| void | assign (const_iterator first, const_iterator last) |
| void | assign (size_type n, const ItemType &x=ItemType()) |
| iterator | insert (iterator it, const ItemType &x=ItemType()) |
| void | insert (iterator it, size_type n, const ItemType &x) |
| void | insert (iterator it, const_iterator first, const_iterator last) |
| iterator | erase (iterator it) |
| iterator | erase (iterator first, iterator last) |
| void | swap (OrderedEnumerator x) |
Protected Attributes |
| CollectionT | collection_ |
Detailed Description
template<typename ItemType, typename CollectionType>
class VCF::OrderedEnumerator< ItemType, CollectionType >
The
OrderedEnumerator is a utility class that makes it easy to use a specific stl collection class (like a vector) and have support for the
Enumerator interface.
These classes do not represent some home grown implementation of STL collections! Instead they are used as a simple wrapper around some existing collection class that conforms to STL standards. All the extra functions here do is to directly call the wrapped collection, making it's usage identical to using the wrapped STL collection. For example, in most cases, using an Array class is exactly the same as using a std::vector class. That's because the Array is simply a specific OrderedEnumerator instantiation that uses std::vector as it's collection type. For further documentation about the various collection methods like push_back(), size(), empty(), insert() and so forth, please see your compiler's STL documentation, or, if that's not available, try http://www.sgi.com/tech/stl/table_of_contents.html. This is explains most of the standard STL collection classes.
If you need direct access for a series of functions you can do something like this:
Array<int> a;
a.resize(10);
a[0] = 1;
std::vector<int>& va = a;
va[2] = 2;
for ( size_t i=0;i<va.size();i++ ) {
va.push_back(i);
}
In general the slight overhead of one extra function call for these common methods (like
push_back(),
size(),
empty(),
insert(), etc) shouldn't make much, if any difference, and they are all marked as inline.
The implementation for the Enumerator interface is handled by the EnumeratorContainer<> class, and the only call in this class that we need is to call the initContainer() function in our constructors. This makes it possible for the EnumeratorContainer to iterate through the collection. If you create you own sub classes, please remember to call the base class for the default and copy constructors. If you add additional constructors of your own, please make sure you call the base constructor ( OrderedEnumerator<>() ), or the collection will not be properly set up and when used as an Enumerator, the Enumerator interface calls will fail.
- See also:
- Array
List
Map
Member Typedef Documentation
|
template<typename ItemType, typename CollectionType> |
| typedef _typename_ CollectionT::iterator VCF::OrderedEnumerator< ItemType, CollectionType >::iterator |
|
|
template<typename ItemType, typename CollectionType> |
| typedef _typename_ CollectionT::reference VCF::OrderedEnumerator< ItemType, CollectionType >::reference |
|
|
template<typename ItemType, typename CollectionType> |
| typedef _typename_ CollectionT::size_type VCF::OrderedEnumerator< ItemType, CollectionType >::size_type |
|
Constructor & Destructor Documentation
Member Function Documentation
|
template<typename ItemType, typename CollectionType> |
| void VCF::OrderedEnumerator< ItemType, CollectionType >::assign |
( |
size_type |
n, |
|
|
const ItemType & |
x = ItemType() |
|
) |
[inline] |
|
|
template<typename ItemType, typename CollectionType> |
| void VCF::OrderedEnumerator< ItemType, CollectionType >::clear |
( |
|
) |
[inline] |
|
|
template<typename ItemType, typename CollectionType> |
| bool VCF::OrderedEnumerator< ItemType, CollectionType >::empty |
( |
|
) |
const [inline] |
|
|
template<typename ItemType, typename CollectionType> |
| void VCF::OrderedEnumerator< ItemType, CollectionType >::pop_back |
( |
|
) |
[inline] |
|
|
template<typename ItemType, typename CollectionType> |
| void VCF::OrderedEnumerator< ItemType, CollectionType >::push_back |
( |
const ItemType & |
x |
) |
[inline] |
|
|
template<typename ItemType, typename CollectionType> |
| void VCF::OrderedEnumerator< ItemType, CollectionType >::resize |
( |
size_type |
n, |
|
|
ItemType |
x = ItemType() |
|
) |
[inline] |
|
|
template<typename ItemType, typename CollectionType> |
| size_t VCF::OrderedEnumerator< ItemType, CollectionType >::size |
( |
|
) |
const [inline] |
|
Member Data Documentation
The documentation for this class was generated from the following file: