Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set
// doxy/ or-tools/ src/ base/

ITIVector< IntType, T, Alloc > Class Template Reference

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. More...

#include <int-type-indexed-vector.h>

Inheritance diagram for ITIVector< IntType, T, Alloc >:

vector

List of all members.

Public Types

typedef std::vector< T, Alloc > ParentType
typedef ParentType::size_type size_type
typedef ParentType::allocator_type allocator_type
typedef ParentType::value_type value_type
typedef ParentType::reference reference
typedef ParentType::const_reference const_reference
typedef ParentType::pointer pointer
typedef ParentType::const_pointer const_pointer
typedef ParentType::iterator iterator
typedef ParentType::const_iterator const_iterator
typedef
ParentType::reverse_iterator 
reverse_iterator
typedef
ParentType::const_reverse_iterator 
const_reverse_iterator

Public Member Functions

 ITIVector ()
 ITIVector (const allocator_type &a)
 ITIVector (size_type n, const value_type &v=value_type(), const allocator_type &a=allocator_type())
 ITIVector (const ITIVector &x)
template<typename InputIteratorType>
 ITIVector (InputIteratorType first, InputIteratorType last, const allocator_type &a=allocator_type())
 ~ITIVector ()
const ParentTypeget () const
 -- Accessors -------------------------------------------------------------- This const accessor is useful in defining the comparison operators below.
ParentTypemutable_get ()
 The mutable accessor is useful when using auxiliar methods relying on vector parameters such as JoinUsing(), SplitStringUsing(), etc.
reference operator[] (IntType i)
 -- Modified methods -------------------------------------------------------
const_reference operator[] (IntType i) const
reference at (IntType i)
const_reference at (IntType i) const
ITIVectoroperator= (const ITIVector &x)
 -- Pass-through methods to STL vector -------------------------------------
void assign (size_type n, const value_type &val)
template<typename InputIt>
void assign (InputIt f, InputIt l)
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 () const
size_type size () const
size_type max_size () const
void resize (size_type new_size, value_type x=value_type())
size_type capacity () const
bool empty () const
void reserve (size_type n)
void push_back (const value_type &x)
void pop_back ()
void swap (ITIVector &x)
void clear ()
reference front ()
const_reference front () const
reference back ()
const_reference back () const
pointer data ()
const_pointer data () const
iterator erase (iterator pos)
iterator erase (iterator first, iterator last)
iterator insert (iterator pos, const value_type &x)
void insert (iterator pos, size_type n, const value_type &x)
template<typename IIt>
void insert (iterator pos, IIt first, IIt last)


Detailed Description

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
class ITIVector< IntType, T, Alloc >

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This file provides the ITIVector container that wraps around the STL vector. The wrapper restrict indexing to a pre-specified type-safe integer type or IntType (see base/int-type.h). It prevents accidental indexing by different "logical" integer-like types (e.g. another IntType) or native integer types. The wrapper is useful as C++ and the standard template library allows the user to mix "logical" integral indices that might have a different role.

The container can only be indexed by an instance of an IntType class, which can be declared as:

DEFINE_INT_TYPE(IntTypeName, IntTypeValueType);

where IntTypeName is the desired name for the "logical" integer-like type and the ValueType is a supported native integer type such as int or uint64 (see base/int-type.h for details).

The wrapper exposes all public methods of STL vector and behaves mostly as pass-through. The only method modified to ensure type-safety is the operator [] and the at() method.

EXAMPLES --------------------------------------------------------------------

DEFINE_INT_TYPE(PhysicalChildIndex, int32); ITIVector<PhysicalChildIndex, ChildStats*> vec;

PhysicalChildIndex physical_index; vec[physical_index] = ...; <-- index type match: compiles properly. vec.at(physical_index) = ...; <-- index type match: compiles properly.

int32 physical_index; vec[physical_index] = ...; <-- fails to compile. vec.at(physical_index) = ...; <-- fails to compile.

DEFINE_INT_TYPE(LogicalChildIndex, int32); int32 logical_index; vec[logical_index] = ...; <-- fails to compile. vec.at(logical_index) = ...; <-- fails to compile.

NB: Iterator arithmetic is not allowed as the iterators are not wrapped themselves. Therefore, the following caveat is possible: (vec.begin() + 0) = ...; STL vector ------------------------------------------------------------------

Definition at line 69 of file int-type-indexed-vector.h.


Member Typedef Documentation

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef std::vector<T, Alloc> ITIVector< IntType, T, Alloc >::ParentType

Definition at line 71 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::size_type ITIVector< IntType, T, Alloc >::size_type

Definition at line 72 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::allocator_type ITIVector< IntType, T, Alloc >::allocator_type

Definition at line 73 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::value_type ITIVector< IntType, T, Alloc >::value_type

Definition at line 74 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::reference ITIVector< IntType, T, Alloc >::reference

Definition at line 75 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::const_reference ITIVector< IntType, T, Alloc >::const_reference

Definition at line 76 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::pointer ITIVector< IntType, T, Alloc >::pointer

Definition at line 77 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::const_pointer ITIVector< IntType, T, Alloc >::const_pointer

Definition at line 78 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::iterator ITIVector< IntType, T, Alloc >::iterator

Definition at line 79 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::const_iterator ITIVector< IntType, T, Alloc >::const_iterator

Definition at line 80 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::reverse_iterator ITIVector< IntType, T, Alloc >::reverse_iterator

Definition at line 81 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
typedef ParentType::const_reverse_iterator ITIVector< IntType, T, Alloc >::const_reverse_iterator

Definition at line 83 of file int-type-indexed-vector.h.


Constructor & Destructor Documentation

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
ITIVector< IntType, T, Alloc >::ITIVector (  )  [inline]

Definition at line 86 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
ITIVector< IntType, T, Alloc >::ITIVector ( const allocator_type a  )  [inline, explicit]

Definition at line 87 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
ITIVector< IntType, T, Alloc >::ITIVector ( size_type  n,
const value_type v = value_type(),
const allocator_type a = allocator_type() 
) [inline]

Definition at line 88 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
ITIVector< IntType, T, Alloc >::ITIVector ( const ITIVector< IntType, T, Alloc > &  x  )  [inline]

Definition at line 91 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
template<typename InputIteratorType>
ITIVector< IntType, T, Alloc >::ITIVector ( InputIteratorType  first,
InputIteratorType  last,
const allocator_type a = allocator_type() 
) [inline]

Definition at line 93 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
ITIVector< IntType, T, Alloc >::~ITIVector (  )  [inline]

Definition at line 96 of file int-type-indexed-vector.h.


Member Function Documentation

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const ParentType& ITIVector< IntType, T, Alloc >::get (  )  const [inline]

-- Accessors -------------------------------------------------------------- This const accessor is useful in defining the comparison operators below.

Definition at line 100 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
ParentType* ITIVector< IntType, T, Alloc >::mutable_get (  )  [inline]

The mutable accessor is useful when using auxiliar methods relying on vector parameters such as JoinUsing(), SplitStringUsing(), etc.

Methods relying solely on iterators (e.g. STLDeleteElements) should work just fine without the need for mutable_get(). NB: It should be used only in this case and thus should not be abused to index the underlying vector without the appropriate IntType.

Definition at line 107 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
reference ITIVector< IntType, T, Alloc >::operator[] ( IntType  i  )  [inline]

-- Modified methods -------------------------------------------------------

Definition at line 110 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_reference ITIVector< IntType, T, Alloc >::operator[] ( IntType  i  )  const [inline]

Definition at line 113 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
reference ITIVector< IntType, T, Alloc >::at ( IntType  i  )  [inline]

Definition at line 116 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_reference ITIVector< IntType, T, Alloc >::at ( IntType  i  )  const [inline]

Definition at line 119 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
ITIVector& ITIVector< IntType, T, Alloc >::operator= ( const ITIVector< IntType, T, Alloc > &  x  )  [inline]

-- Pass-through methods to STL vector -------------------------------------

Definition at line 124 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
void ITIVector< IntType, T, Alloc >::assign ( size_type  n,
const value_type val 
) [inline]

Definition at line 129 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
template<typename InputIt>
void ITIVector< IntType, T, Alloc >::assign ( InputIt  f,
InputIt  l 
) [inline]

Definition at line 133 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
iterator ITIVector< IntType, T, Alloc >::begin (  )  [inline]

Definition at line 135 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_iterator ITIVector< IntType, T, Alloc >::begin (  )  const [inline]

Definition at line 136 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
iterator ITIVector< IntType, T, Alloc >::end (  )  [inline]

Definition at line 137 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_iterator ITIVector< IntType, T, Alloc >::end (  )  const [inline]

Definition at line 138 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
reverse_iterator ITIVector< IntType, T, Alloc >::rbegin (  )  [inline]

Definition at line 139 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_reverse_iterator ITIVector< IntType, T, Alloc >::rbegin (  )  const [inline]

Definition at line 140 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
reverse_iterator ITIVector< IntType, T, Alloc >::rend (  )  [inline]

Definition at line 141 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_reverse_iterator ITIVector< IntType, T, Alloc >::rend (  )  const [inline]

Definition at line 142 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
size_type ITIVector< IntType, T, Alloc >::size (  )  const [inline]

Definition at line 144 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
size_type ITIVector< IntType, T, Alloc >::max_size (  )  const [inline]

Definition at line 145 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
void ITIVector< IntType, T, Alloc >::resize ( size_type  new_size,
value_type  x = value_type() 
) [inline]

Definition at line 147 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
size_type ITIVector< IntType, T, Alloc >::capacity (  )  const [inline]

Definition at line 151 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
bool ITIVector< IntType, T, Alloc >::empty (  )  const [inline]

Definition at line 152 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
void ITIVector< IntType, T, Alloc >::reserve ( size_type  n  )  [inline]

Definition at line 153 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
void ITIVector< IntType, T, Alloc >::push_back ( const value_type x  )  [inline]

Definition at line 154 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
void ITIVector< IntType, T, Alloc >::pop_back (  )  [inline]

Definition at line 155 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
void ITIVector< IntType, T, Alloc >::swap ( ITIVector< IntType, T, Alloc > &  x  )  [inline]

Definition at line 156 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
void ITIVector< IntType, T, Alloc >::clear (  )  [inline]

Definition at line 157 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
reference ITIVector< IntType, T, Alloc >::front (  )  [inline]

Definition at line 159 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_reference ITIVector< IntType, T, Alloc >::front (  )  const [inline]

Definition at line 160 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
reference ITIVector< IntType, T, Alloc >::back (  )  [inline]

Definition at line 161 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_reference ITIVector< IntType, T, Alloc >::back (  )  const [inline]

Definition at line 162 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
pointer ITIVector< IntType, T, Alloc >::data (  )  [inline]

Definition at line 163 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
const_pointer ITIVector< IntType, T, Alloc >::data (  )  const [inline]

Definition at line 164 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
iterator ITIVector< IntType, T, Alloc >::erase ( iterator  pos  )  [inline]

Definition at line 166 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
iterator ITIVector< IntType, T, Alloc >::erase ( iterator  first,
iterator  last 
) [inline]

Definition at line 169 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
iterator ITIVector< IntType, T, Alloc >::insert ( iterator  pos,
const value_type x 
) [inline]

Definition at line 172 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
void ITIVector< IntType, T, Alloc >::insert ( iterator  pos,
size_type  n,
const value_type x 
) [inline]

Definition at line 175 of file int-type-indexed-vector.h.

template<typename IntType, typename T, typename Alloc = std::allocator<T>>
template<typename IIt>
void ITIVector< IntType, T, Alloc >::insert ( iterator  pos,
IIt  first,
IIt  last 
) [inline]

Definition at line 179 of file int-type-indexed-vector.h.


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