www.pudn.com > GOOGLE.rar > 2.pas, change:2002-02-05,size:1214b


function TaaBtreePage.IsDeficient : boolean; 
begin 
	Result := (FKeyCount + 1) < (FOrder div 2); 
end; 
 
function TaaBtreePage.IsHalfFull : boolean; 
begin 
	Result := (FKeyCount +1) - (FOrder div 2); 
end; 
 
Procedure TaaBtreePage.Merge(aSibling : TaaBtreePage; const aMidKey : string; aMidRecLink : longint); 
var 
	i : integer; 
begin 
	{both we and our sibling should be exactly half full or less} 
	Assert( IsHalFull or IsDeficient ,  
		'TaaBtreePage.Merge: the sibling page is not half full and should be' ); 
	{copy over the middle key; its pagelink will come from the sibling} 
	FKeys.Add( aMidKey ); 
	FRecLinks[FKeyCount] := aMidRecLink; 
	{new copy over the keys and data from our sibling} 
	for i := pred( aSibling.FKeyCount ) downto 0 do begin 
		FKeys.Add( aSibling.FKeys[i] ); 
		aSibling.FKeys.Delete( i ); 
	end; 
	Move( aSibling.FRecLinks[0] , FRecLinks[FKeyCount + 1], 
		(aSibling.FKeyCount * sizeof(longint))); 
	Move( aSibling.FPageLinks[0] , FPageLinks[FKeyCount + 1], 
		((aSibling.FKeuCount + 1) * sizeof(longint))); 
	{set the key counts} 
	FKeyCount := FKeyCount + 1 + aSibling.FKeyCount; 
	aSiblingCount.FKeyCount := 0; 
	{update the stream with the changed page} 
	bpWrite; 
end;