os/persistentdata/persistentstorage/store/UBTREE/UB_NODE.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/store/UBTREE/UB_NODE.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,97 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "UB_STD.H"
    1.20 +
    1.21 +EXPORT_C void MBtreeNodeOrg::Init(TAny* aNode) const
    1.22 +//
    1.23 +// Default node initialisation just zero filling.
    1.24 +//
    1.25 +	{
    1.26 +	Mem::FillZ(aNode,KPoolPageSize);
    1.27 +	}
    1.28 +
    1.29 +EXPORT_C TBool MBtreeLeafOrg::Search(const TAny* aNode,const TAny* aKey,const MBtreeKey& aComp,TBool aLast,TInt& aPos) const
    1.30 +//
    1.31 +// Default to using a binary search through the node, using KeyAt and the key's comparison.
    1.32 +// if aLast is 1, aEntry is the first > the key, return true if previous entry is a match
    1.33 +// if aLast is 0, aEntry is the first entry >= the key, return true is current entry is a match
    1.34 +//
    1.35 +	{
    1.36 +	TInt match=EFalse;
    1.37 +	TInt rr=LastEntry(aNode)-1;
    1.38 +	TInt ll=0;
    1.39 +	__ASSERT_DEBUG(rr>=-1,Panic(EBadEntryCount));
    1.40 +	while (ll<=rr)
    1.41 +		{
    1.42 +		TInt mm=(rr+ll)>>1;
    1.43 +		TInt res=aComp.Compare(aKey,aComp.Key(EntryPtr(aNode,mm)));
    1.44 +		if (res==0)
    1.45 +			match=ETrue;
    1.46 +		if (res+aLast<=0)
    1.47 +			rr=mm-1;		// compare < 0 or match and aLast=0
    1.48 +		else
    1.49 +			ll=mm+1;		// compare > 0 or match and aLast=1
    1.50 +		}
    1.51 +	aPos=ll;
    1.52 +	return match;
    1.53 +	}
    1.54 +
    1.55 +EXPORT_C TBool MBtreeLeafOrg::InsertOverflow(TAny*,TAny*,TInt,TBool,const TDesC8&) const
    1.56 +//
    1.57 +// For simple implementations allow this to be unimplemented. Report failure
    1.58 +//
    1.59 +	{
    1.60 +	return EFalse;
    1.61 +	}
    1.62 +
    1.63 +EXPORT_C TBool MBtreeIndexOrg::Search(const TAny* aNode,const TAny* aKey,const MBtreeKey& aComp,TBool aLast,TInt& aPos) const
    1.64 +//
    1.65 +// Default to using a binary search through the node, using KeyAt and the key's comparison.
    1.66 +// if aLast is 1, aEntry is the first > the key
    1.67 +// if aLast is 0, aEntry is the first entry >= the key
    1.68 +//
    1.69 +	{
    1.70 +	TInt rr=LastEntry(aNode);
    1.71 +	TInt ll=-1;
    1.72 +	__ASSERT_DEBUG(rr>0,Panic(EBadEntryCount));
    1.73 +	while (rr>ll+1)
    1.74 +		{
    1.75 +		TInt mm=(rr+ll)>>1;
    1.76 +		if (aComp.Compare(aKey,EntryPtr(aNode,mm))+aLast<=0)
    1.77 +			rr=mm;		// compare < 0 or match and aLast=0
    1.78 +		else
    1.79 +			ll=mm;		// compare > 0 or match and aLast=1
    1.80 +		}
    1.81 +	aPos=rr;
    1.82 +	return EFalse;		// return not used
    1.83 +	}
    1.84 +
    1.85 +EXPORT_C TBool MBtreeIndexOrg::InsertOverflow(TAny*,TAny*,TInt,TBool,const TDesC8&,TPageRef,const TDesC8&,TBtreePivot&) const
    1.86 +//
    1.87 +// For simple implementations allow this to be unimplemented. Report failure.
    1.88 +//
    1.89 +	{
    1.90 +	return EFalse;
    1.91 +	}
    1.92 +
    1.93 +EXPORT_C TBool MBtreeIndexOrg::Update(TAny*,TInt,const TDesC8&) const
    1.94 +//
    1.95 +// Allow to be unimplemented. Return failure.
    1.96 +//
    1.97 +	{
    1.98 +	return EFalse;
    1.99 +	}
   1.100 +