epoc32/include/s32btree.inl
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
// Class TBtreeToken
williamr@2
    17
inline TBtreeToken::TBtreeToken(TEmpty)
williamr@2
    18
/** Constructor that intialises the TBtreeToken for an empty B-tree.
williamr@2
    19
williamr@2
    20
@param Intialises for an empty B-tree */
williamr@2
    21
	{Clear();}
williamr@2
    22
inline void TBtreeToken::Touch()
williamr@2
    23
/** Marks the B-tree as broken. */
williamr@2
    24
	{iHeight=0;}
williamr@2
    25
inline TBool TBtreeToken::IsBroken() const
williamr@2
    26
/** Tests if the broken flag has been set on the B-tree.
williamr@2
    27
williamr@2
    28
@return True if the B-tree is broken, otherwise false. */
williamr@2
    29
	{return iFirst!=KNullPageRef&&iHeight==0;}
williamr@2
    30
inline TBool TBtreeToken::IsIntact() const
williamr@2
    31
/** Tests if the broken flag has not been set on the B-tree .
williamr@2
    32
williamr@2
    33
@return True if the B-tree is not broken, otherwise false. */
williamr@2
    34
	{return iFirst==KNullPageRef||iHeight!=0;}
williamr@2
    35
inline TBool TBtreeToken::IsEmpty() const
williamr@2
    36
/** Tests if the B-tree is empty.
williamr@2
    37
williamr@2
    38
@return True if the B-tree is empty, otherwise false. */
williamr@2
    39
	{return iFirst==KNullPageRef;}
williamr@2
    40
williamr@2
    41
// Class TBtreePath
williamr@2
    42
inline TBtreePath::TBtreePath()
williamr@2
    43
	: iEnd(-1)
williamr@2
    44
	{}
williamr@2
    45
inline TPageRef TBtreePath::Node() const
williamr@2
    46
	{return iNodes[iEnd];}
williamr@2
    47
inline TInt TBtreePath::Entry() const
williamr@2
    48
	{return iEntries[iEnd];}
williamr@2
    49
inline TBool TBtreePath::IsLeaf() const
williamr@2
    50
	{return iEnd==0;}
williamr@2
    51
inline TBtreeHeight TBtreePath::End() const
williamr@2
    52
	{return iEnd;}
williamr@2
    53
inline void TBtreePath::SetEntry(TInt aEntry)
williamr@2
    54
	{iEntries[iEnd]=TUint8(aEntry);}
williamr@2
    55
inline void TBtreePath::Pop()
williamr@2
    56
	{++iEnd;}
williamr@2
    57
williamr@2
    58
// Class TBtree
williamr@2
    59
inline TBool TBtree::IsDirty() const
williamr@2
    60
/** Tests if the dirty flag has been set on the B-tree.
williamr@2
    61
williamr@2
    62
Any updates to the B-tree will set this flag on the TBtree object. Applications 
williamr@2
    63
can use this to determine if they need to flush the page pool and re-save 
williamr@2
    64
the B-tree token, after which they can call MarkCurrent() to indicate that 
williamr@2
    65
the persistent storage is now up-to-date with the TBtree object.
williamr@2
    66
williamr@2
    67
@return True if the dirty flag has been set, otherwise false */
williamr@2
    68
	{return iStatus<0;}
williamr@2
    69
inline void TBtree::MarkCurrent()
williamr@2
    70
/** Clears the dirty flag. */
williamr@2
    71
	{iStatus&=~EDirty;}
williamr@2
    72
inline void TBtree::MarkDirty()
williamr@2
    73
/** Sets the dirty flag. */
williamr@2
    74
	{iStatus|=EDirty;}
williamr@2
    75
inline TBool TBtree::IsBroken() const
williamr@2
    76
/** Tests if the broken flag has been set on the B-tree.
williamr@2
    77
williamr@2
    78
Any updates to the B-tree that fail will leave this flag set on the TBtree 
williamr@2
    79
object. This indicates that the persistent tree data is broken (corrupt) and 
williamr@2
    80
the tree needs to be repaired. In this state, none of the functions which 
williamr@2
    81
use a TBtreePos will work, only those taking a TBtreeMark.
williamr@2
    82
williamr@2
    83
@return True if the B-tree is broken, otherwise false. */
williamr@2
    84
	{return (iStatus&EBroken)!=0;}
williamr@2
    85
inline TBool TBtree::IsIntact() const
williamr@2
    86
/** Tests if the broken flag has not been set on the B-tree .
williamr@2
    87
williamr@2
    88
@return True if the B-tree is not broken, otherwise false. */
williamr@2
    89
	{return (iStatus&EBroken)==0;}
williamr@2
    90
inline void TBtree::MarkBroken()
williamr@2
    91
/** Sets the broken flag. */
williamr@2
    92
	{if (iFirst!=KNullPageRef) iStatus|=EBroken;}
williamr@2
    93
inline TBool TBtree::IsEmpty() const
williamr@2
    94
/** Tests if the B-tree is empty.
williamr@2
    95
williamr@2
    96
@return True if the B-tree is empty, otherwise false */
williamr@2
    97
	{return iFirst==KNullPageRef;}
williamr@2
    98
williamr@2
    99
// Template class TBtreeFix
williamr@2
   100
template <class Entry,class Key>
williamr@2
   101
inline TBtreeFix<Entry,Key>::TBtreeFix(TBtreeMode aMode)
williamr@2
   102
	: TBtreeFixBase(aMode,sizeof(Entry),sizeof(Key))
williamr@2
   103
/** Constructor that sets the B-tree mode.
williamr@2
   104
williamr@2
   105
@param aMode B-tree operating mode */
williamr@2
   106
	{}
williamr@2
   107
template <class Entry,class Key>
williamr@2
   108
inline TBtreeFix<Entry,Key>::TBtreeFix(const TBtreeToken& aToken,TBtreeMode aMode)
williamr@2
   109
	: TBtreeFixBase(aToken,aMode,sizeof(Entry),sizeof(Key))
williamr@2
   110
/** Constructor that sets the B-tree mode and initialisation parameters.
williamr@2
   111
williamr@2
   112
@param aToken Parameters with which to initialise the B-tree
williamr@2
   113
@param aMode B-tree operating mode */
williamr@2
   114
	{}
williamr@2
   115
template <class Entry,class Key>
williamr@2
   116
inline TBool TBtreeFix<Entry,Key>::FindL(TBtreePos& aPos,const Key& aKey,TBtree::TFind aMode) const
williamr@2
   117
	{return TBtreeFixBase::FindL(aPos,&aKey,aMode);}
williamr@2
   118
template <class Entry,class Key>
williamr@2
   119
inline TBool TBtreeFix<Entry,Key>::InsertL(TBtreePos& aPos,const Entry& anEntry,TAllowDuplicates aDup)
williamr@2
   120
/** Inserts an entry into the tree.
williamr@2
   121
williamr@2
   122
@param aPos On return, the position of the entry inserted
williamr@2
   123
@param anEntry Entry to insert
williamr@2
   124
@param aDup Flag to indicate whether duplicate entries are allowed in the tree
williamr@2
   125
@return True if successful, false if the entry was a duplicate and aDup was 
williamr@2
   126
set to ENoDuplicates */
williamr@2
   127
	{return TBtreeFixBase::InsertL(aPos,&anEntry,aDup);}
williamr@2
   128
template <class Entry,class Key>
williamr@2
   129
inline TBool TBtreeFix<Entry,Key>::DeleteL(const Key& aKey)
williamr@2
   130
/** Delete an entry.
williamr@2
   131
williamr@2
   132
@param aKey Key of the entry to delete
williamr@2
   133
@return True if successful, false if the entry was not found */
williamr@2
   134
	{return TBtreeFixBase::DeleteL(&aKey);}
williamr@2
   135
template <class Entry,class Key>
williamr@2
   136
inline Entry TBtreeFix<Entry,Key>::AtL(const TBtreePos& aPos) const
williamr@2
   137
/** Gets the entry at the specified position.
williamr@2
   138
williamr@2
   139
@param aPos Position of the entry to get
williamr@2
   140
@return Entry at position aPos */
williamr@2
   141
	{Entry e;TBtreeFixBase::ExtractAtL(aPos,&e);return e;}
williamr@2
   142
template <class Entry,class Key>
williamr@2
   143
inline Entry TBtreeFix<Entry,Key>::AtL(const TBtreeMark& aMark) const
williamr@2
   144
/** Gets the entry at the specified iterator position.
williamr@2
   145
williamr@2
   146
@param aMark Iterator to use to get the entry
williamr@2
   147
@return Entry at current iterator position */
williamr@2
   148
	{Entry e;TBtreeFixBase::ExtractAtL(aMark,&e);return e;}
williamr@2
   149
template <class Entry,class Key>
williamr@2
   150
inline void TBtreeFix<Entry,Key>::ExtractAtL(const TBtreePos& aPos,Entry& anEntry) const
williamr@2
   151
/** Gets the entry at the specified position.
williamr@2
   152
williamr@2
   153
@param aPos Position of the entry to get
williamr@2
   154
@param anEntry On return, the specified entry */
williamr@2
   155
	{TBtreeFixBase::ExtractAtL(aPos,&anEntry);}
williamr@2
   156
template <class Entry,class Key>
williamr@2
   157
inline void TBtreeFix<Entry,Key>::ExtractAtL(const TBtreeMark& aMark,Entry& anEntry) const
williamr@2
   158
/** Gets the entry at the specified iterator position.
williamr@2
   159
williamr@2
   160
@param aMark Iterator to use to get the entry
williamr@2
   161
@param anEntry On return, the specified entry */
williamr@2
   162
	{TBtreeFixBase::ExtractAtL(aMark,&anEntry);}
williamr@2
   163
inline TBtreeFix<TAny,TAny>::TBtreeFix(TBtreeMode aMode,TInt anEntrySize,TInt aKeySize)
williamr@2
   164
	: TBtreeFixBase(aMode,anEntrySize,aKeySize)
williamr@2
   165
/** Constructor that sets the B-tree mode.
williamr@2
   166
	
williamr@2
   167
@param aMode B-tree operating mode
williamr@2
   168
@param anEntrySize Entry size
williamr@2
   169
@param aKeySize Key size for entries */
williamr@2
   170
	{}
williamr@2
   171
inline TBtreeFix<TAny,TAny>::TBtreeFix(const TBtreeToken& aToken,TBtreeMode aMode,TInt anEntrySize,TInt aKeySize)
williamr@2
   172
	: TBtreeFixBase(aToken,aMode,anEntrySize,aKeySize)
williamr@2
   173
/** Constructor that sets the B-tree mode and initialisation parameters.
williamr@2
   174
	
williamr@2
   175
@param aToken Parameters with which to initialise the B-tree
williamr@2
   176
@param aMode B-tree operating mode
williamr@2
   177
@param anEntrySize Entry size
williamr@2
   178
@param aKeySize Key size for entries */
williamr@2
   179
	{}
williamr@4
   180