Tizen Native API
Dali::Vector< T, IsTrivialType > Class Template Reference

Vector class with minimum space allocation when its empty. More...

Inheritance diagram for Dali::Vector< T, IsTrivialType >:
Dali::VectorAlgorithms< IsTrivialType > Dali::VectorBase

Public Types

typedef VectorBase::SizeType SizeType
 Type definitions.
typedef T * Iterator
 Most simple Iterator is a pointer.
typedef const T * ConstIterator
 Const iterator.
typedef T ItemType
 Item type.

Public Member Functions

 Vector ()
 Default constructor. Does not allocate any space.
 ~Vector ()
 Destructor. Releases the allocated space.
 Vector (const Vector &vector)
 Copy constructor.
Vectoroperator= (const Vector &vector)
 Assignment operator.
Iterator Begin () const
 Iterator to the beginning of the data.
Iterator End () const
 Iterator to the end of the data (one past last element).
ItemTypeoperator[] (SizeType index)
 Subscript operator.
const ItemTypeoperator[] (SizeType index) const
 Subscript operator.
void PushBack (const ItemType &element)
 Push back an element to the vector.
void Insert (Iterator at, const ItemType &element)
 Insert an element to the vector.
void Insert (Iterator at, Iterator from, Iterator to)
 Inserts the given elements into the vector.
void Reserve (SizeType count)
 Reserve space in the vector.
void Resize (SizeType count, ItemType item=ItemType())
 Resize the vector. Does not change capacity.
Iterator Erase (Iterator iterator)
 Erase an element.
Iterator Erase (Iterator first, Iterator last)
 Erase a range of elements.
void Remove (Iterator iterator)
 Removes an element.
void Swap (Vector &vector)
 Swap the contents of two vectors.
void Clear ()
 Clear the contents of the vector. Keeps its capacity.
void Release ()
 Release the memory that the vector holds.

Detailed Description

template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
class Dali::Vector< T, IsTrivialType >

Vector class with minimum space allocation when its empty.

Since :
2.4
Parameters:
[in]typeof the data that the vector holds.

Member Typedef Documentation

template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
typedef const T* Dali::Vector< T, IsTrivialType >::ConstIterator

Const iterator.

Since :
2.4
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
typedef T Dali::Vector< T, IsTrivialType >::ItemType

Item type.

Since :
2.4
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
typedef T* Dali::Vector< T, IsTrivialType >::Iterator

Most simple Iterator is a pointer.

Since :
2.4
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
typedef VectorBase::SizeType Dali::Vector< T, IsTrivialType >::SizeType

Type definitions.

Since :
2.4 Size type
Since :
2.4

Reimplemented from Dali::VectorAlgorithms< IsTrivialType >.


Constructor & Destructor Documentation

template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
Dali::Vector< T, IsTrivialType >::Vector ( )

Default constructor. Does not allocate any space.

Since :
2.4
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
Dali::Vector< T, IsTrivialType >::~Vector ( )

Destructor. Releases the allocated space.

Since :
2.4
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
Dali::Vector< T, IsTrivialType >::Vector ( const Vector< T, IsTrivialType > &  vector)

Copy constructor.

Since :
2.4
Parameters:
[in]vectorVector to copy from.

Member Function Documentation

template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
Iterator Dali::Vector< T, IsTrivialType >::Begin ( ) const

Iterator to the beginning of the data.

Since :
2.4
Returns:
Iterator to the beginning of the data.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::Clear ( )

Clear the contents of the vector. Keeps its capacity.

Since :
2.4

Reimplemented from Dali::VectorAlgorithms< IsTrivialType >.

template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
Iterator Dali::Vector< T, IsTrivialType >::End ( ) const

Iterator to the end of the data (one past last element).

Since :
2.4
Returns:
Iterator to the end of the data (one past last element).
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
Iterator Dali::Vector< T, IsTrivialType >::Erase ( Iterator  iterator)

Erase an element.

Does not change capacity. Other elements get moved.

Since :
2.4
Parameters:
[in]iteratorIterator pointing to item to remove.
Returns:
Iterator pointing to next element.
Precondition:
Iterator iterator must be within the vector's range ( Vector::Begin(), Vector::End() - 1 ).
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
Iterator Dali::Vector< T, IsTrivialType >::Erase ( Iterator  first,
Iterator  last 
)

Erase a range of elements.

Does not change capacity. Other elements get moved.

Since :
2.4
Parameters:
[in]firstIterator to the first element to be erased.
[in]lastIterator to the last element to be erased.
Returns:
Iterator pointing to the next element of the last one.
Precondition:
Iterator first must be in the vector's range ( Vector::Begin(), Vector::End() ).
Iterator last must be in the vector's range ( Vector::Begin(), Vector::End() ).
Iterator first must not be grater than Iterator last.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::Insert ( Iterator  at,
const ItemType element 
)

Insert an element to the vector.

Elements after at are moved one position to the right.

The underlying storage may be reallocated to provide space. If this occurs, all pre-existing pointers into the vector will become invalid.

Precondition:
Iterator at must be in the vector's range ( Vector::Begin(), Vector::End() ).
Parameters:
[in]atIterator where to insert the elements into the vector.
[in]elementAn element to be added.
Since :
2.4
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::Insert ( Iterator  at,
Iterator  from,
Iterator  to 
)

Inserts the given elements into the vector.

Elements after at are moved the number of given elements positions to the right.

The underlying storage may be reallocated to provide space. If this occurs, all pre-existing pointers into the vector will become invalid.

Since :
2.4
Parameters:
[in]atIterator where to insert the elements into the vector.
[in]fromIterator to the first element to be inserted.
[in]toIterator to the last element to be inserted.
Precondition:
Iterator at must be in the vector's range ( Vector::Begin(), Vector::End() ).
Iterators from and to must be valid iterators.
Iterator from must not be grater than Iterator to.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
Vector& Dali::Vector< T, IsTrivialType >::operator= ( const Vector< T, IsTrivialType > &  vector)

Assignment operator.

Since :
2.4
Parameters:
[in]vectorVector to assign from.
Returns:
Reference to self for chaining.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
ItemType& Dali::Vector< T, IsTrivialType >::operator[] ( SizeType  index)

Subscript operator.

Since :
2.4
Parameters:
[in]indexIndex of the element.
Returns:
Reference to the element for given index.
Precondition:
Index must be in the vector's range.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
const ItemType& Dali::Vector< T, IsTrivialType >::operator[] ( SizeType  index) const

Subscript operator.

Since :
2.4
Parameters:
[in]indexof the element.
Returns:
reference to the element for given index.
Precondition:
index must be in the vector's range.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::PushBack ( const ItemType element)

Push back an element to the vector.

The underlying storage may be reallocated to provide space. If this occurs, all pre-existing pointers into the vector will become invalid.

Since :
2.4
Parameters:
[in]elementElement to be added.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::Release ( )

Release the memory that the vector holds.

Since :
2.4

Reimplemented from Dali::VectorAlgorithms< IsTrivialType >.

template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::Remove ( Iterator  iterator)

Removes an element.

Does not maintain order. Swaps the element with end and decreases size by one. This is much faster than Erase so use this in case order does not matter. Does not change capacity.

Since :
2.4
Parameters:
[in]iteratorIterator pointing to item to remove.
Precondition:
Iterator iterator must be in the vector's range ( Vector::Begin(), Vector::End() - 1 ).
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::Reserve ( SizeType  count)

Reserve space in the vector.

Reserving less than current Capacity is a no-op.

Since :
2.4
Parameters:
[in]countCount of elements to reserve.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::Resize ( SizeType  count,
ItemType  item = ItemType() 
)

Resize the vector. Does not change capacity.

Since :
2.4
Parameters:
[in]countCount to resize to.
[in]itemAn item to insert to the new indices.
template<class T, bool IsTrivialType = TypeTraits<T>::IS_TRIVIAL_TYPE == true>
void Dali::Vector< T, IsTrivialType >::Swap ( Vector< T, IsTrivialType > &  vector)

Swap the contents of two vectors.

Since :
2.4
Parameters:
[in]vectorVector to swap with.