1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __CSTACK_INL__
17 #define __CSTACK_INL__
20 const TInt KStackGranularity=32;
24 ECStackErrStackIsEmpty,
25 ECStackDeleteWhenNotOwner,
29 _LIT(KCStackPanicName, "CStack");
31 inline void Panic(TCStackPanic aPanic)
33 User::Panic(KCStackPanicName, aPanic);
40 template <class T, TBool StackOwnsEntry>
41 inline CStack<T, StackOwnsEntry>::CStack()
42 : CArrayPtrSeg<T>(KStackGranularity)
47 template <class T, TBool StackOwnsEntry>
48 inline CStack<T, StackOwnsEntry>::~CStack()
53 template <class T, TBool StackOwnsEntry>
54 inline void CStack<T, StackOwnsEntry>::Clear()
57 this->ResetAndDestroy();
62 template <class T, TBool StackOwnsEntry>
63 inline TBool CStack<T, StackOwnsEntry>::IsEmpty() const
65 return this->Count()==0;
68 template <class T, TBool StackOwnsEntry>
69 inline void CStack<T, StackOwnsEntry>::PushL(T* aItem)
72 CleanupStack::PushL(aItem);
78 template <class T, TBool StackOwnsEntry>
79 inline T* CStack<T, StackOwnsEntry>::Pop()
81 __ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
83 this->Delete(this->Count()-1);
87 template <class T, TBool StackOwnsEntry>
88 inline T* CStack<T, StackOwnsEntry>::Head() const
90 __ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
91 return this->At(this->Count()-1);
94 template <class T, TBool StackOwnsEntry>
95 inline T* CStack<T, StackOwnsEntry>::Last() const
97 __ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
102 #endif // __CSTACK_INL__