Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Б-деревья заготовка для лабы / BTNode
.pas unit BTNode;
interface
uses BTDefs;
type TBTNode = class(TObject)
private
m_Key: array[1..KEYS_PER_NODE] of string;
m_Child: array[0..KEYS_PER_NODE] of TBTNode;
function getKey(Index: integer): string;
procedure setKey(Index: integer; k: string);
function getChild(Index: integer): TBTNode;
procedure setChild(Index: integer; c: TBTNode);
public
NumKeys: integer;
constructor Create;
property Key[Index: integer]: string read getKey write setKey;
property Child[Index: integer]: TBTNode read getChild write setChild;
end;
implementation
constructor TBTNode.Create;
var
i: Integer;
begin
for i := 1 to KEYS_PER_NODE do m_Key[i] := '';
for i := 0 to KEYS_PER_NODE do m_Child[i] := nil;
NumKeys := 0;
end;
function TBTNode.getKey(Index: integer): string;
begin
result := m_Key[Index];
end;
function TBTNode.getChild(Index: integer): TBTNode;
begin
result := m_Child[Index];
end;
procedure TBTNode.setKey(Index: integer; k: string);
begin
m_Key[Index] := k;
end;
procedure TBTNode.setChild(Index: integer; c: TBTNode);
begin
m_Child[Index] := c;
end;
end.
interface
uses BTDefs;
type TBTNode = class(TObject)
private
m_Key: array[1..KEYS_PER_NODE] of string;
m_Child: array[0..KEYS_PER_NODE] of TBTNode;
function getKey(Index: integer): string;
procedure setKey(Index: integer; k: string);
function getChild(Index: integer): TBTNode;
procedure setChild(Index: integer; c: TBTNode);
public
NumKeys: integer;
constructor Create;
property Key[Index: integer]: string read getKey write setKey;
property Child[Index: integer]: TBTNode read getChild write setChild;
end;
implementation
constructor TBTNode.Create;
var
i: Integer;
begin
for i := 1 to KEYS_PER_NODE do m_Key[i] := '';
for i := 0 to KEYS_PER_NODE do m_Child[i] := nil;
NumKeys := 0;
end;
function TBTNode.getKey(Index: integer): string;
begin
result := m_Key[Index];
end;
function TBTNode.getChild(Index: integer): TBTNode;
begin
result := m_Child[Index];
end;
procedure TBTNode.setKey(Index: integer; k: string);
begin
m_Key[Index] := k;
end;
procedure TBTNode.setChild(Index: integer; c: TBTNode);
begin
m_Child[Index] := c;
end;
end.
Соседние файлы в папке Б-деревья заготовка для лабы