1.1 --- a/epoc32/include/s32btree.inl Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/s32btree.inl Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,179 @@
1.4 -s32btree.inl
1.5 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +// Class TBtreeToken
1.21 +inline TBtreeToken::TBtreeToken(TEmpty)
1.22 +/** Constructor that intialises the TBtreeToken for an empty B-tree.
1.23 +
1.24 +@param Intialises for an empty B-tree */
1.25 + {Clear();}
1.26 +inline void TBtreeToken::Touch()
1.27 +/** Marks the B-tree as broken. */
1.28 + {iHeight=0;}
1.29 +inline TBool TBtreeToken::IsBroken() const
1.30 +/** Tests if the broken flag has been set on the B-tree.
1.31 +
1.32 +@return True if the B-tree is broken, otherwise false. */
1.33 + {return iFirst!=KNullPageRef&&iHeight==0;}
1.34 +inline TBool TBtreeToken::IsIntact() const
1.35 +/** Tests if the broken flag has not been set on the B-tree .
1.36 +
1.37 +@return True if the B-tree is not broken, otherwise false. */
1.38 + {return iFirst==KNullPageRef||iHeight!=0;}
1.39 +inline TBool TBtreeToken::IsEmpty() const
1.40 +/** Tests if the B-tree is empty.
1.41 +
1.42 +@return True if the B-tree is empty, otherwise false. */
1.43 + {return iFirst==KNullPageRef;}
1.44 +
1.45 +// Class TBtreePath
1.46 +inline TBtreePath::TBtreePath()
1.47 + : iEnd(-1)
1.48 + {}
1.49 +inline TPageRef TBtreePath::Node() const
1.50 + {return iNodes[iEnd];}
1.51 +inline TInt TBtreePath::Entry() const
1.52 + {return iEntries[iEnd];}
1.53 +inline TBool TBtreePath::IsLeaf() const
1.54 + {return iEnd==0;}
1.55 +inline TBtreeHeight TBtreePath::End() const
1.56 + {return iEnd;}
1.57 +inline void TBtreePath::SetEntry(TInt aEntry)
1.58 + {iEntries[iEnd]=TUint8(aEntry);}
1.59 +inline void TBtreePath::Pop()
1.60 + {++iEnd;}
1.61 +
1.62 +// Class TBtree
1.63 +inline TBool TBtree::IsDirty() const
1.64 +/** Tests if the dirty flag has been set on the B-tree.
1.65 +
1.66 +Any updates to the B-tree will set this flag on the TBtree object. Applications
1.67 +can use this to determine if they need to flush the page pool and re-save
1.68 +the B-tree token, after which they can call MarkCurrent() to indicate that
1.69 +the persistent storage is now up-to-date with the TBtree object.
1.70 +
1.71 +@return True if the dirty flag has been set, otherwise false */
1.72 + {return iStatus<0;}
1.73 +inline void TBtree::MarkCurrent()
1.74 +/** Clears the dirty flag. */
1.75 + {iStatus&=~EDirty;}
1.76 +inline void TBtree::MarkDirty()
1.77 +/** Sets the dirty flag. */
1.78 + {iStatus|=EDirty;}
1.79 +inline TBool TBtree::IsBroken() const
1.80 +/** Tests if the broken flag has been set on the B-tree.
1.81 +
1.82 +Any updates to the B-tree that fail will leave this flag set on the TBtree
1.83 +object. This indicates that the persistent tree data is broken (corrupt) and
1.84 +the tree needs to be repaired. In this state, none of the functions which
1.85 +use a TBtreePos will work, only those taking a TBtreeMark.
1.86 +
1.87 +@return True if the B-tree is broken, otherwise false. */
1.88 + {return (iStatus&EBroken)!=0;}
1.89 +inline TBool TBtree::IsIntact() const
1.90 +/** Tests if the broken flag has not been set on the B-tree .
1.91 +
1.92 +@return True if the B-tree is not broken, otherwise false. */
1.93 + {return (iStatus&EBroken)==0;}
1.94 +inline void TBtree::MarkBroken()
1.95 +/** Sets the broken flag. */
1.96 + {if (iFirst!=KNullPageRef) iStatus|=EBroken;}
1.97 +inline TBool TBtree::IsEmpty() const
1.98 +/** Tests if the B-tree is empty.
1.99 +
1.100 +@return True if the B-tree is empty, otherwise false */
1.101 + {return iFirst==KNullPageRef;}
1.102 +
1.103 +// Template class TBtreeFix
1.104 +template <class Entry,class Key>
1.105 +inline TBtreeFix<Entry,Key>::TBtreeFix(TBtreeMode aMode)
1.106 + : TBtreeFixBase(aMode,sizeof(Entry),sizeof(Key))
1.107 +/** Constructor that sets the B-tree mode.
1.108 +
1.109 +@param aMode B-tree operating mode */
1.110 + {}
1.111 +template <class Entry,class Key>
1.112 +inline TBtreeFix<Entry,Key>::TBtreeFix(const TBtreeToken& aToken,TBtreeMode aMode)
1.113 + : TBtreeFixBase(aToken,aMode,sizeof(Entry),sizeof(Key))
1.114 +/** Constructor that sets the B-tree mode and initialisation parameters.
1.115 +
1.116 +@param aToken Parameters with which to initialise the B-tree
1.117 +@param aMode B-tree operating mode */
1.118 + {}
1.119 +template <class Entry,class Key>
1.120 +inline TBool TBtreeFix<Entry,Key>::FindL(TBtreePos& aPos,const Key& aKey,TBtree::TFind aMode) const
1.121 + {return TBtreeFixBase::FindL(aPos,&aKey,aMode);}
1.122 +template <class Entry,class Key>
1.123 +inline TBool TBtreeFix<Entry,Key>::InsertL(TBtreePos& aPos,const Entry& anEntry,TAllowDuplicates aDup)
1.124 +/** Inserts an entry into the tree.
1.125 +
1.126 +@param aPos On return, the position of the entry inserted
1.127 +@param anEntry Entry to insert
1.128 +@param aDup Flag to indicate whether duplicate entries are allowed in the tree
1.129 +@return True if successful, false if the entry was a duplicate and aDup was
1.130 +set to ENoDuplicates */
1.131 + {return TBtreeFixBase::InsertL(aPos,&anEntry,aDup);}
1.132 +template <class Entry,class Key>
1.133 +inline TBool TBtreeFix<Entry,Key>::DeleteL(const Key& aKey)
1.134 +/** Delete an entry.
1.135 +
1.136 +@param aKey Key of the entry to delete
1.137 +@return True if successful, false if the entry was not found */
1.138 + {return TBtreeFixBase::DeleteL(&aKey);}
1.139 +template <class Entry,class Key>
1.140 +inline Entry TBtreeFix<Entry,Key>::AtL(const TBtreePos& aPos) const
1.141 +/** Gets the entry at the specified position.
1.142 +
1.143 +@param aPos Position of the entry to get
1.144 +@return Entry at position aPos */
1.145 + {Entry e;TBtreeFixBase::ExtractAtL(aPos,&e);return e;}
1.146 +template <class Entry,class Key>
1.147 +inline Entry TBtreeFix<Entry,Key>::AtL(const TBtreeMark& aMark) const
1.148 +/** Gets the entry at the specified iterator position.
1.149 +
1.150 +@param aMark Iterator to use to get the entry
1.151 +@return Entry at current iterator position */
1.152 + {Entry e;TBtreeFixBase::ExtractAtL(aMark,&e);return e;}
1.153 +template <class Entry,class Key>
1.154 +inline void TBtreeFix<Entry,Key>::ExtractAtL(const TBtreePos& aPos,Entry& anEntry) const
1.155 +/** Gets the entry at the specified position.
1.156 +
1.157 +@param aPos Position of the entry to get
1.158 +@param anEntry On return, the specified entry */
1.159 + {TBtreeFixBase::ExtractAtL(aPos,&anEntry);}
1.160 +template <class Entry,class Key>
1.161 +inline void TBtreeFix<Entry,Key>::ExtractAtL(const TBtreeMark& aMark,Entry& anEntry) const
1.162 +/** Gets the entry at the specified iterator position.
1.163 +
1.164 +@param aMark Iterator to use to get the entry
1.165 +@param anEntry On return, the specified entry */
1.166 + {TBtreeFixBase::ExtractAtL(aMark,&anEntry);}
1.167 +inline TBtreeFix<TAny,TAny>::TBtreeFix(TBtreeMode aMode,TInt anEntrySize,TInt aKeySize)
1.168 + : TBtreeFixBase(aMode,anEntrySize,aKeySize)
1.169 +/** Constructor that sets the B-tree mode.
1.170 +
1.171 +@param aMode B-tree operating mode
1.172 +@param anEntrySize Entry size
1.173 +@param aKeySize Key size for entries */
1.174 + {}
1.175 +inline TBtreeFix<TAny,TAny>::TBtreeFix(const TBtreeToken& aToken,TBtreeMode aMode,TInt anEntrySize,TInt aKeySize)
1.176 + : TBtreeFixBase(aToken,aMode,anEntrySize,aKeySize)
1.177 +/** Constructor that sets the B-tree mode and initialisation parameters.
1.178 +
1.179 +@param aToken Parameters with which to initialise the B-tree
1.180 +@param aMode B-tree operating mode
1.181 +@param anEntrySize Entry size
1.182 +@param aKeySize Key size for entries */
1.183 + {}