Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Bucket_Search_Elementary_Tree_Package;
- with Ada.Strings.Unbounded;
- with Ada.Strings.Unbounded.Text_IO;
- with Ada.Text_IO;
- use Bucket_Search_Elementary_Tree_Package;
- use Ada.Strings.Unbounded;
- use Ada.Strings.Unbounded.Text_IO;
- use Ada.Text_IO;
- procedure Test_The_Bucket is
- Tree : BSE_Tree;
- procedure BSE_Insert
- (T : in out BSE_Tree) is
- Source : File_Type;
- Read : Unbounded_String;
- To_Insert : Unbounded_String;
- Current_Char : Character;
- begin
- Open (Source, In_File, "BSE_Insert.txt");
- while not End_Of_File (Source) loop
- Read := Get_Line (Source);
- for I in 1 .. Length (Read) loop
- Current_Char := Element (Read, I);
- if Current_Char = ' '
- or Character'Pos (Current_Char) = 10
- or Character'Pos (Current_Char) = 13 then
- Insert (T, To_Insert);
- To_Insert := To_Unbounded_String ("");
- else
- Append (To_Insert, Current_Char);
- end if;
- end loop;
- Insert (T, To_Insert);
- To_Insert := To_Unbounded_String ("");
- end loop;
- Close (Source);
- Put_Line ("BSE_Insert executed successfully.");
- end BSE_Insert;
- procedure BSE_Delete
- (T : in out BSE_Tree) is
- Source : File_Type;
- Read : Unbounded_String;
- To_Delete : Unbounded_String;
- Current_Char : Character;
- begin
- Open (Source, In_File, "BSE_Delete.txt");
- while not End_Of_File (Source) loop
- Read := Get_Line (Source);
- for I in 1 .. Length (Read) loop
- Current_Char := Element (Read, I);
- if Current_Char = ' '
- or Character'Pos (Current_Char) = 10
- or Character'Pos (Current_Char) = 13 then
- Delete (T, To_Delete);
- To_Delete := To_Unbounded_String ("");
- else
- Append (To_Delete, Current_Char);
- end if;
- end loop;
- Delete (T, To_Delete);
- To_Delete := To_Unbounded_String ("");
- end loop;
- Close (Source);
- Put_Line ("BSE_Delete successfully executed.");
- end BSE_Delete;
- procedure BSE_Find
- (T : in BSE_Tree) is
- Source : File_Type;
- Read : Unbounded_String;
- To_Find : Unbounded_String;
- Current_Char : Character;
- begin
- Open (Source, In_File, "BSE_Find.txt");
- while not End_Of_File (Source) loop
- Read := Get_Line (Source);
- for I in 1 .. Length (Read) loop
- Current_Char := Element (Read, I);
- if Current_Char = ' '
- or Character'Pos (Current_Char) = 10
- or Character'Pos (Current_Char) = 13 then
- if Find (T, To_Find) then
- Put_Line (To_Find);
- end if;
- To_Find := To_Unbounded_String ("");
- else
- Append (To_Find, Current_Char);
- end if;
- end loop;
- if Find (T, To_Find) then
- Put_Line (To_Find);
- end if;
- To_Find := To_Unbounded_String ("");
- end loop;
- Close (Source);
- end BSE_Find;
- A, B : Unbounded_String;
- begin
- Tree := new BSE_Element;
- BSE_Insert (Tree);
- -- Put_Line ("The Tree now looks as following:");
- -- Put (Tree);
- Put_Line ("The tree contains" & Size (Tree)'Img & " different elements.");
- BSE_Delete (Tree);
- -- Put_Line ("The Tree now looks as following:");
- -- Put (Tree);
- Put_Line ("The tree contains" & Size (Tree)'Img & " different elements.");
- -- Put_Line ("The tree still contains thw following words from the ");
- -- Put ("BSE_Find File:");
- -- New_Line;
- -- BSE_Find (Tree);
- Clear (Tree);
- BSE_Insert (Tree);
- -- Put (Tree);
- end Test_The_Bucket;
Add Comment
Please, Sign In to add comment