19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vectorbuffer.cpp 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall yet another circle buffer 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Markus Mertama 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef __VECTORBUFFER_H__ 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define __VECTORBUFFER_H__ 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include<e32std.h> 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define VLOG(x) 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define VECPANIC(x) VectorPanic(x, __LINE__) 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid VectorPanic(TInt, TInt); 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//int DEBUG_INT; 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallNONSHARABLE_CLASS(TNodeBuffer) 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall public: 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall protected: 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NONSHARABLE_CLASS(TNode) 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall public: 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static TNode* Empty(TUint8* iBuffer); 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static TNode* New(TNode* aPrev, const TDesC8& aData); 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TUint8* Ptr() const; 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt Size() const; 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall inline TNode* Succ(); 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static void SetSucc(TNode*& aNode); 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void Terminator(TNode* aNode); 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall private: 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TNode* iSucc; 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallinline TNodeBuffer::TNode* TNodeBuffer::TNode::Succ() 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return iSucc; 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <TInt C> 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallNONSHARABLE_CLASS(TVectorBuffer) : public TNodeBuffer 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall public: 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TVectorBuffer(); 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt Append(const TDesC8& aData); 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // TInt AppendOverwrite(const TDesC8& aData); 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TPtrC8 Shift(); 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TPtrC8 operator[](TInt aIndex) const; 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt Size() const; 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall private: 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt GetRoom(TInt aSize) const; 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt Unreserved() const; 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall private: 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TNode* iTop; 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TNode* iBottom; 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt iSize; 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8 iBuffer[C]; 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <TInt C> 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTVectorBuffer<C>::TVectorBuffer() : iSize(0) 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mem::FillZ(iBuffer, C); 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall iTop = TNode::Empty(iBuffer); //these points to buffer 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall iBottom = TNode::Empty(iBuffer); 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate<TInt C > 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTInt TVectorBuffer<C>::Unreserved() const 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(iBottom < iBottom->Succ(), VECPANIC(KErrCorrupt)); 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt bytesbetween = 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall reinterpret_cast<const TUint8*>(iBottom->Succ()) - 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall reinterpret_cast<const TUint8*>(iTop); 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt topsize = sizeof(TNode); 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(bytesbetween > 0) //bytesbetween is room between bottom and top 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { //therefore free room is subracted from free space 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt room = C - bytesbetween - topsize; 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return room; 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(bytesbetween == 0) 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(Size() > 0) 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return C - topsize; 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt room = -bytesbetween - topsize; //free is space between pointers 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return room; 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <TInt C> 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTInt TVectorBuffer<C>::GetRoom(TInt aSize) const 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt bytesnew = sizeof(TNode) + aSize; 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt room = Unreserved() - bytesnew; 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return room; 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <TInt C> 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTInt TVectorBuffer<C>::Append(const TDesC8& aData) //ei ole ok! 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt len = aData.Length(); 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(GetRoom(len) < 0) 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return KErrOverflow; 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(iBottom->Succ()->Ptr() - iBuffer > (C - (len + TInt(sizeof(TNode))))) 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall VLOG("rc"); 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // RDebug::Print(_L("vector: append")); 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TNode* p = TNode::Empty(iBuffer); 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall iBottom->Terminator(p); 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall iBottom = p; 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return Append(aData); 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Append(); 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // iBottom = TNode::New(p, aData); //just append something into end 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //DEBUG_INT++; 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall iBottom = TNode::New(iBottom, aData); 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall iSize += len; 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return KErrNone; 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <TInt C> 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTInt TVectorBuffer<C>::AppendOverwrite(const TDesC8& aData) //ei ole ok! 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while(Append(aData) == KErrOverflow) 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(iTop->Succ() == NULL) 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return KErrUnderflow; 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //Shift(); //data is lost 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return KErrNone; 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <TInt C> 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTPtrC8 TVectorBuffer<C>::Shift() 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_ALWAYS(iTop->Succ() != NULL, VECPANIC(KErrUnderflow)); //can never pass-by bottom 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TNode* node = iTop; 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall iTop = iTop->Succ(); 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(iTop > node) 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // DEBUG_INT--; 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall iSize -= node->Size(); 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return TPtrC8(node->Ptr(), node->Size()); 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // RDebug::Print(_L("vector: shift")); 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return Shift(); //this happens when buffer is terminated, and data lies in next 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <TInt C> 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTInt TVectorBuffer<C>::Size() const 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return iSize; 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <TInt C> 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTPtrC8 TVectorBuffer<C>::operator[](TInt aIndex) const 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt index = 0; 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TNode* t = iTop->Size() > 0 ? iTop : iTop->Succ(); //eliminate terminator 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while(index < aIndex) 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TNode* nt = t->Succ(); 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(nt < t) 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall nt = nt->Succ(); 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall t = nt; 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(t->Size() > 0) 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall index++; 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_ALWAYS(t->Succ() != NULL, VECPANIC(KErrUnderflow)); //can never pass-by bottom 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return t->Ptr(); 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <class T, TInt C> 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallNONSHARABLE_CLASS(TVector) : public TVectorBuffer<C * sizeof(T)> 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall public: 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TVector(); 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt Append(const T& aData); 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const T& Shift(); 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt Size() const; 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const T& operator[](TInt aIndex) const; 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <class T, TInt C> 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTVector<T, C>::TVector() : TVectorBuffer<C * sizeof(T)>() 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <class T, TInt C> 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTInt TVector<T, C>::Append(const T& aData) 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TPckgC<T> data(aData); 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return TVectorBuffer<C * sizeof(T)>::Append(data); 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <class T, TInt C> 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallconst T& TVector<T, C>::Shift() 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TPtrC8 ptr = TVectorBuffer<C * sizeof(T)>::Shift(); 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return *(reinterpret_cast<const T*>(ptr.Ptr())); 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <class T, TInt C> 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallTInt TVector<T, C>::Size() const 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return TVectorBuffer<C * sizeof(T)>::Size() / sizeof(T); 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltemplate <class T, TInt C> 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallconst T& TVector<T, C>::operator[](TInt aIndex) const 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TPtrC8 ptr = TVectorBuffer<C * sizeof(T)>::operator[](aIndex); 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return *(reinterpret_cast<const T*>(ptr.Ptr())); 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 241