Реализация операции селекции с использованием индексов
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
;
{$R *. dfm}insert_data (var D: TData): Integer;(DataFile, DataFileName, SizeOf (TData));: = FileSize (DataFile);(DataFile, Result);(DataFile, D, 1);;declaration: Integer;Node: TBTreeNode;: = FileSize (IndexFile);(IndexFile, Result);(IndexFile, Node, 1);;create_tree;Node: TBTreeNode;. IsLeaf: = True;. N: = 0;(IndexFile, IndexFileName, SizeOf (TBTreeNode));(IndexFile, 0);(IndexFile, Node, 1);(RootFile, RootFileName, SizeOf (Integer));: = 0;(RootFile, 0);(RootFile, Root, 1);;read_tree (N: Integer);i: integer;: TBTreeNode;: TData;(IndexFile, N);(IndexFile, Node, 1);(Node. IsLeaf) then begini: =1 to Node. N do begin(DataFile, Node. Rec [i]. Adr);(DataFile, Data, 1);. Memo1. Lines. Add (IntToStr (Data. Key) +': '+Data. Data);;else begin_tree (Node. Child [1]);i: = 1 to Node. N do begin(DataFile, Node. Rec [i]. Adr);(DataFile, Data, 1);. Memo1. Lines. Add (IntToStr (Data. Key) +': '+Data. Data);_tree (Node. Child [i + 1]);;;;TForm1. FormCreate (Sender: TObject);: =0;: =0;(DataFile, DataFileName, SizeOf (TData));(IndexFile, IndexFileName, SizeOf (TBTreeNode));(RootFile, RootFileName, SizeOf (Integer));(RootFile, 0);(RootFile, Root, 1);;TForm1. FormClose (Sender: TObject; var Action: TCloseAction);;;TForm1. N2Click (Sender: TObject);(DataFile, DataFileName, SizeOf (TData));_tree;;TForm1. N4Click (Sender: TObject);. Terminate;;TForm1. N6Click (Sender: TObject);data: TData;: integer;. Clear;(DataFile,0);: =0;(i X. Rec [i]. Key) then begin: = i + 1;(IndexFile, X. Child [i]);(IndexFile, Node, 1);;;_tree_no (Node, X. Child [i], KA);;;insert_tree (KA: TKeyAdr);r, s: TBTreeNode;(IndexFile, Root);(IndexFile, r, 1);(r. N =2*MD-1) then begin. IsLeaf: =False;. N: = 0;. Child [1]: =Root;: = declaration;(s, Root, 1, r);_tree_no (s, Root, KA);else_tree_no (r, Root, KA);;read_data (Adr: integer);: =ListSize + 1;[ListSize]: =Adr;;selection (const Node: TBTreeNode; Left, Right: Integer);i: Integer;: TBTreeNode;: =1;(i <= Node. N) and (Node. Rec [i]. Key < Left) do: = i + 1;(not Node. IsLeaf) then begin(IndexFile, Node. Child [i]);(IndexFile, N, 1);(N,Left,Right);;(i<=Node. N) and (Node. Rec [i]. Key <= Right) do begin_data (Node. Rec [i]. Adr);: =i+1;(not Node. IsLeaf) then begin(IndexFile, Node. Child [i]);(IndexFile, N, 1);(N,Left,Right);;;;TForm1. FormDestroy (Sender: TObject);(RootFile, 0);(RootFile, Root, 1);;TForm1. Button1Click (Sender: TObject);D: TData;: TKeyAdr;. Key: =StrToInt (Edit1. Text);. Data: =Edit2. Text;. Key: =D. Key;. Adr: =insert_data (D);_tree (KA);;TForm1. Button6Click (Sender: TObject);i, Left, Right: Integer;: TBTreeNode;: TData;: string;. Clear;: = 0;: = StrToInt (Edit3. Text);: = StrToInt (Edit4. Text);(IndexFile, Root);(IndexFile, Node, 1);(Node, Left, Right);i: = 1 to ListSize do begin(DataFile, ListData [i]);(DataFile, Data, 1);: = IntToStr (i) +': '+IntToStr (Data. Key) + ' ';. Lines. Add (s+Data. Data);
end;;.