sl@0: // Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "UC_STD.H" sl@0: sl@0: EXPORT_C void TPagedSetToken::ExternalizeL(RWriteStream &aStream) const sl@0: { sl@0: __ASSERT_DEBUG(iCount>=0,User::Invariant()); sl@0: TBtreeToken::ExternalizeL(aStream); sl@0: aStream.WriteInt32L(iCount); sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetToken::InternalizeL(RReadStream &aStream) sl@0: { sl@0: TBtreeToken::InternalizeL(aStream); sl@0: iCount=aStream.ReadInt32L(); sl@0: if (iCount<0) sl@0: __LEAVE(KErrCorrupt); sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetToken::Clear() sl@0: { sl@0: TBtreeToken::Clear(); sl@0: iCount=0; sl@0: } sl@0: sl@0: EXPORT_C TPagedSetBase::TPagedSetBase(TInt anEntrySize) sl@0: // sl@0: // Constructor creating a new set. sl@0: // sl@0: : iTree(EBtreeSecure,anEntrySize,anEntrySize),iKey(anEntrySize),iCount(0) sl@0: {} sl@0: sl@0: EXPORT_C TPagedSetBase::TPagedSetBase(const TPagedSetToken &aToken,TInt anEntrySize) sl@0: // sl@0: // Constructor reinstating an existing set. sl@0: // sl@0: : iTree(aToken,EBtreeSecure,anEntrySize,anEntrySize),iKey(anEntrySize),iCount(aToken.iCount) sl@0: {} sl@0: sl@0: EXPORT_C void TPagedSetBase::Connect(MPagePool *aPool) sl@0: // sl@0: // Hook the tree up to its bits. sl@0: // sl@0: { sl@0: iTree.Connect(aPool,&iKey); sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetBase::Set(const TPagedSetToken &aToken) sl@0: // sl@0: // Set to the state described by aToken. sl@0: // sl@0: { sl@0: iTree.Set(aToken,EBtreeSecure); sl@0: iCount=aToken.iCount; sl@0: } sl@0: sl@0: EXPORT_C TPagedSetToken TPagedSetBase::Token() const sl@0: // sl@0: // Build the streaming token for the set. sl@0: // sl@0: { sl@0: return TPagedSetToken(iTree.Token(),iCount); sl@0: } sl@0: sl@0: EXPORT_C TInt TPagedSetBase::RepairL() sl@0: // sl@0: // Repair a broken set. sl@0: // sl@0: { sl@0: TInt count=iTree.RepairL(); sl@0: iCount=count; sl@0: return count; sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetBase::ClearL() sl@0: // sl@0: // Empty the set. sl@0: // sl@0: { sl@0: iTree.ClearL(); sl@0: iCount=0; sl@0: } sl@0: sl@0: EXPORT_C TBool TPagedSetBase::ContainsL(const TAny *aPtr) const sl@0: // sl@0: // Return whether the set contains an entry equal to the one pointed to by aPtr. sl@0: // sl@0: { sl@0: TBtreePos pos; sl@0: return iTree.FindL(pos,aPtr); sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetBase::InsertL(const TAny *aPtr) sl@0: // sl@0: // Insert an entry into the set. sl@0: // sl@0: { sl@0: TBtreePos pos; sl@0: if (!iTree.InsertL(pos,aPtr)) sl@0: __LEAVE(KErrAlreadyExists); // a duplicate sl@0: // sl@0: ++iCount; sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetBase::DeleteL(const TAny *aPtr) sl@0: // sl@0: // Delete an entry from the set. sl@0: // sl@0: { sl@0: if (!iTree.DeleteL(aPtr)) sl@0: __LEAVE(KErrNotFound); sl@0: // sl@0: --iCount; sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetBase::InsertAllowDuplicatesL(const TAny *aPtr) sl@0: // sl@0: // Insert an entry into the set, allow duplicates. sl@0: // sl@0: { sl@0: TBtreePos pos; sl@0: __DEBUG(TBool success=)iTree.InsertL(pos,aPtr,EAllowDuplicates); sl@0: __ASSERT_DEBUG(success,User::Invariant()); sl@0: ++iCount; sl@0: } sl@0: sl@0: EXPORT_C TBool TPagedSetIterBase::ResetL() sl@0: { sl@0: return iTree->ResetL(iMark); sl@0: } sl@0: sl@0: EXPORT_C TBool TPagedSetIterBase::NextL() sl@0: { sl@0: return iTree->NextL(iMark); sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetIterBase::ExtractAtL(TAny* aPtr) const sl@0: { sl@0: iTree->ExtractAtL(iMark,aPtr); sl@0: } sl@0: sl@0: EXPORT_C TBool TPagedSetBiIterBase::FirstL() sl@0: { sl@0: return iTree->FirstL(iPos); sl@0: } sl@0: sl@0: EXPORT_C TBool TPagedSetBiIterBase::LastL() sl@0: { sl@0: return iTree->LastL(iPos); sl@0: } sl@0: sl@0: EXPORT_C TBool TPagedSetBiIterBase::NextL() sl@0: { sl@0: return iTree->NextL(iPos); sl@0: } sl@0: sl@0: EXPORT_C TBool TPagedSetBiIterBase::PreviousL() sl@0: { sl@0: return iTree->PreviousL(iPos); sl@0: } sl@0: sl@0: EXPORT_C void TPagedSetBiIterBase::ExtractAtL(TAny* aPtr) const sl@0: { sl@0: iTree->ExtractAtL(iPos,aPtr); sl@0: } sl@0: