persistentstorage/store/UBTREE/UB_NODE.CPP
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "UB_STD.H"
       
    17 
       
    18 EXPORT_C void MBtreeNodeOrg::Init(TAny* aNode) const
       
    19 //
       
    20 // Default node initialisation just zero filling.
       
    21 //
       
    22 	{
       
    23 	Mem::FillZ(aNode,KPoolPageSize);
       
    24 	}
       
    25 
       
    26 EXPORT_C TBool MBtreeLeafOrg::Search(const TAny* aNode,const TAny* aKey,const MBtreeKey& aComp,TBool aLast,TInt& aPos) const
       
    27 //
       
    28 // Default to using a binary search through the node, using KeyAt and the key's comparison.
       
    29 // if aLast is 1, aEntry is the first > the key, return true if previous entry is a match
       
    30 // if aLast is 0, aEntry is the first entry >= the key, return true is current entry is a match
       
    31 //
       
    32 	{
       
    33 	TInt match=EFalse;
       
    34 	TInt rr=LastEntry(aNode)-1;
       
    35 	TInt ll=0;
       
    36 	__ASSERT_DEBUG(rr>=-1,Panic(EBadEntryCount));
       
    37 	while (ll<=rr)
       
    38 		{
       
    39 		TInt mm=(rr+ll)>>1;
       
    40 		TInt res=aComp.Compare(aKey,aComp.Key(EntryPtr(aNode,mm)));
       
    41 		if (res==0)
       
    42 			match=ETrue;
       
    43 		if (res+aLast<=0)
       
    44 			rr=mm-1;		// compare < 0 or match and aLast=0
       
    45 		else
       
    46 			ll=mm+1;		// compare > 0 or match and aLast=1
       
    47 		}
       
    48 	aPos=ll;
       
    49 	return match;
       
    50 	}
       
    51 
       
    52 EXPORT_C TBool MBtreeLeafOrg::InsertOverflow(TAny*,TAny*,TInt,TBool,const TDesC8&) const
       
    53 //
       
    54 // For simple implementations allow this to be unimplemented. Report failure
       
    55 //
       
    56 	{
       
    57 	return EFalse;
       
    58 	}
       
    59 
       
    60 EXPORT_C TBool MBtreeIndexOrg::Search(const TAny* aNode,const TAny* aKey,const MBtreeKey& aComp,TBool aLast,TInt& aPos) const
       
    61 //
       
    62 // Default to using a binary search through the node, using KeyAt and the key's comparison.
       
    63 // if aLast is 1, aEntry is the first > the key
       
    64 // if aLast is 0, aEntry is the first entry >= the key
       
    65 //
       
    66 	{
       
    67 	TInt rr=LastEntry(aNode);
       
    68 	TInt ll=-1;
       
    69 	__ASSERT_DEBUG(rr>0,Panic(EBadEntryCount));
       
    70 	while (rr>ll+1)
       
    71 		{
       
    72 		TInt mm=(rr+ll)>>1;
       
    73 		if (aComp.Compare(aKey,EntryPtr(aNode,mm))+aLast<=0)
       
    74 			rr=mm;		// compare < 0 or match and aLast=0
       
    75 		else
       
    76 			ll=mm;		// compare > 0 or match and aLast=1
       
    77 		}
       
    78 	aPos=rr;
       
    79 	return EFalse;		// return not used
       
    80 	}
       
    81 
       
    82 EXPORT_C TBool MBtreeIndexOrg::InsertOverflow(TAny*,TAny*,TInt,TBool,const TDesC8&,TPageRef,const TDesC8&,TBtreePivot&) const
       
    83 //
       
    84 // For simple implementations allow this to be unimplemented. Report failure.
       
    85 //
       
    86 	{
       
    87 	return EFalse;
       
    88 	}
       
    89 
       
    90 EXPORT_C TBool MBtreeIndexOrg::Update(TAny*,TInt,const TDesC8&) const
       
    91 //
       
    92 // Allow to be unimplemented. Return failure.
       
    93 //
       
    94 	{
       
    95 	return EFalse;
       
    96 	}
       
    97