📄 rsmbmusicaplibvector.inl
字号:
/* Copyright (C) 2006 Sony Ericsson Mobile Communications Japan, Inc. */
/*--------------------------------------------------------------------*/
// FileName:
// RSmbMusicAPLibVector.inl
//
// Description:
// PTX810 Music傾僾儕 儈儏乕僕僢僋嫟捠儔僀僽儔儕
/*--------------------------------------------------------------------*/
//曄峏棜楌
//擔晅 |曄峏幰 |撪梕
//--------------+---------------+--------------------------------------
//2006/09/23 |SEMC崃绮 |僼傽僀儖僔僗僥儉嫟捠儔僀僽儔儕偐傜愗傝弌偟
/**
* $Revision: 1.3 $ $Date: 2006/05/13 09:47:40 $
*/
#include "SmbMusicAPLibAlgorithm.h" // for MyMin(), MyMax(), Swap(), Equal(), Lexicographical_compare(), etc.
#include <e32base.h> // for class CBufFlat
#include <e32panic.h> // for EArrayIndexOutOfRange
SEMCJ_NAMESPACE_BEGIN
MUSICAPLIB_NAMESPACE_BEGIN
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::RSmbMusicAPLibVector()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline RSmbMusicAPLibVector<T, DP>::RSmbMusicAPLibVector()
: iBuffer( NULL )
{
// nothing to do.
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::RSmbMusicAPLibVector()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline RSmbMusicAPLibVector<T, DP>::RSmbMusicAPLibVector( size_type aNum, const value_type& aVal/*=T()*/ )
: iBuffer( NULL )
{
TRAPD( err, ReserveL(aNum); AssignL(aNum, aVal) );
if (err)
{
// 僆僽僕僃僋僩抋惗枹枮側偺偱丄棙梡幰懁偱偺leave TRAP 偼晄壜擻丅儕乕僋懳嶔屻偵嵞throw丅
Release();
// :leavescan off:
User::Leave( err );
// :leavescan on:
}
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::RSmbMusicAPLibVector()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline RSmbMusicAPLibVector<T, DP>::RSmbMusicAPLibVector( const RSmbMusicAPLibVector& aRhs )
: iBuffer( NULL )
{
TRAPD( err, ReserveL(aRhs.Size()); AssignL(aRhs.Begin(), aRhs.End()) );
if (err)
{
// 僆僽僕僃僋僩抋惗枹枮側偺偱丄棙梡幰懁偱偺leave TRAP 偼晄壜擻丅儕乕僋懳嶔屻偵嵞throw丅
Release();
// :leavescan off:
User::Leave( err );
// :leavescan on:
}
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::RSmbMusicAPLibVector()
// ----------------------------------------------------------------------------
template<typename T, class DP>
template<typename InputIterator>
inline RSmbMusicAPLibVector<T, DP>::RSmbMusicAPLibVector( InputIterator aFirst, InputIterator aLast )
: iBuffer( NULL )
{
TRAPD( err, AssignL(aFirst, aLast) );
if (err)
{
// 僆僽僕僃僋僩抋惗枹枮側偺偱丄棙梡幰懁偱偺leave TRAP 偼晄壜擻丅儕乕僋懳嶔屻偵嵞throw丅
Release();
// :leavescan off:
User::Leave( err );
// :leavescan on:
}
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::~RSmbMusicAPLibVector()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline RSmbMusicAPLibVector<T, DP>::~RSmbMusicAPLibVector()
{
Release();
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::AssignL()
// ----------------------------------------------------------------------------
template<typename T, class DP>
template<typename InputIterator>
inline void RSmbMusicAPLibVector<T, DP>::AssignL( InputIterator aFirst, InputIterator aLast )
{
Clear();
InsertL( Begin(), aFirst, aLast );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::AssignL()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline void RSmbMusicAPLibVector<T, DP>::AssignL( size_type aNum, const value_type& aVal )
{
Clear();
InsertFillL( Begin(), aNum, aVal );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::operator=()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline RSmbMusicAPLibVector<T, DP>& RSmbMusicAPLibVector<T, DP>::operator=( const RSmbMusicAPLibVector& aRhs )
{
RSmbMusicAPLibVector( aRhs ).Swap( *this );
return *this;
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::Begin()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::iterator RSmbMusicAPLibVector<T, DP>::Begin()
{
return iterator( iBuffer ? (pointer)(iBuffer->Ptr(0).Ptr()) : NULL );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::Begin()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::const_iterator RSmbMusicAPLibVector<T, DP>::Begin() const
{
return const_iterator( iBuffer ? (pointer)(iBuffer->Ptr(0).Ptr()) : NULL );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::End()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::iterator RSmbMusicAPLibVector<T, DP>::End()
{
return iBuffer ? Begin() + Size() : iterator();
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::End()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::const_iterator RSmbMusicAPLibVector<T, DP>::End() const
{
return iBuffer ? Begin() + Size() : const_iterator();
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::RBegin()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::reverse_iterator RSmbMusicAPLibVector<T, DP>::RBegin()
{
return reverse_iterator( End() );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::RBegin()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::const_reverse_iterator RSmbMusicAPLibVector<T, DP>::RBegin() const
{
return const_reverse_iterator( End() );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::REnd()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::reverse_iterator RSmbMusicAPLibVector<T, DP>::REnd()
{
return reverse_iterator( Begin() );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::REnd()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::const_reverse_iterator RSmbMusicAPLibVector<T, DP>::REnd() const
{
return const_reverse_iterator( Begin() );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::Size()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::size_type RSmbMusicAPLibVector<T, DP>::Size() const
{
return iBuffer ? iBuffer->Size() / sizeof(value_type) : 0;
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::Max_size()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::size_type RSmbMusicAPLibVector<T, DP>::Max_size() const
{
return KMaxTInt / sizeof(value_type);
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::ResizeL()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline void RSmbMusicAPLibVector<T, DP>::ResizeL( size_type aNum, const value_type& aVal/*=T()*/ )
{
if (aNum < Size())
Erase( Begin() + aNum, End() );
else
InsertFillL( End(), aNum - Size(), aVal );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::Capacity()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::size_type RSmbMusicAPLibVector<T, DP>::Capacity() const
{
return iBuffer ? iBuffer->Capacity() / sizeof(value_type) : 0;
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::Empty()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline TBool RSmbMusicAPLibVector<T, DP>::Empty() const
{
return Size() <= 0;
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::ReserveL()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline void RSmbMusicAPLibVector<T, DP>::ReserveL( size_type aNum )
{
const size_type alloc_unit_size = 8;
const size_type c = MyMin( ((aNum + alloc_unit_size - 1) / alloc_unit_size) * alloc_unit_size, Max_size() );
if (c <= Capacity())
return;
if (!iBuffer)
iBuffer = CBufFlat::NewL( alloc_unit_size * sizeof(value_type) );
iBuffer->SetReserveL( c * sizeof(value_type) );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::At()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::reference RSmbMusicAPLibVector<T, DP>::At( size_type aIdx )
{
APLIB_FALSE_DEBUG_PANIC_MA( aIdx < Size() );
return *( Begin() + aIdx );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::At()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::const_reference RSmbMusicAPLibVector<T, DP>::At( size_type aIdx ) const
{
APLIB_FALSE_DEBUG_PANIC_MA( aIdx < Size() );
return *( Begin() + aIdx );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::operator[]()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::reference RSmbMusicAPLibVector<T, DP>::operator[]( size_type aIdx )
{
return At( aIdx );
}
// ----------------------------------------------------------------------------
// RSmbMusicAPLibVector::operator[]()
// ----------------------------------------------------------------------------
template<typename T, class DP>
inline typename RSmbMusicAPLibVector<T, DP>::const_reference RSmbMusicAPLibVector<T, DP>::operator[]( size_type aIdx ) const
{
return At( aIdx );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -