text
stringlengths
0
234
'(' .. '('
| '{' .. '{'
| '[' .. '['
| '<' .. '<';
subtype Close_Chunks is Chunks
with Static_Predicate => Close_Chunks in
')' .. ')'
| '}' .. '}'
| ']' .. ']'
| '>' .. '>';
function ID_Hashed (Id : Open_Chunks) return Ada.Containers.Hash_Type is
(Ada.Containers.Hash_Type (Open_Chunks'Pos (Id)));
package Corresponding_Chunk_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Open_Chunks,
Element_Type => Close_Chunks,
Hash => ID_Hashed,
Equivalent_Keys => "=");
package Chunks_Vectors is new Ada.Containers.Vectors (Natural, Chunks);
package Chunks_Vectors_Vectors is new Ada.Containers.Vectors (Natural, Chunks_Vectors.Vector, Chunks_Vectors."=");
Corresponding_Chunk : Corresponding_Chunk_Maps.Map;
File : File_Type;
Start_Time, End_Time : CPU_Time;
Execution_Duration : Time_Span;
Values : Chunks_Vectors_Vectors.Vector := Chunks_Vectors_Vectors.Empty_Vector;
Result : Natural := Natural'First;
begin
Get_File (File);
-- Get all values
while not End_Of_File (File) loop
declare
use Chunks_Vectors;
Str : constant String := Get_Line (File);
Row : Vector := Empty_Vector;
begin
for Char of Str loop
Row.Append (Char);
end loop;
Values.Append (Row);
Function Definition: procedure Main is
Function Body: use Ada.Execution_Time,
Ada.Real_Time,
Ada.Text_IO;
use Utils;
subtype Chunks is Character
with Static_Predicate => Chunks in
'(' .. '('
| '{' .. '{'
| '[' .. '['
| '<' .. '<'
| ')' .. ')'
| '}' .. '}'
| ']' .. ']'
| '>' .. '>';
subtype Open_Chunks is Chunks
with Static_Predicate => Open_Chunks in
'(' .. '('
| '{' .. '{'
| '[' .. '['
| '<' .. '<';
subtype Close_Chunks is Chunks
with Static_Predicate => Close_Chunks in
')' .. ')'
| '}' .. '}'
| ']' .. ']'
| '>' .. '>';
function ID_Hashed (Id : Open_Chunks) return Ada.Containers.Hash_Type is
(Ada.Containers.Hash_Type (Open_Chunks'Pos (Id)));
package Corresponding_Chunk_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Open_Chunks,
Element_Type => Close_Chunks,
Hash => ID_Hashed,
Equivalent_Keys => "=");
package Chunks_Vectors is new Ada.Containers.Vectors (Natural, Chunks);
subtype Long_Long_Natural is Long_Long_Integer range 0 .. Long_Long_Integer'Last;
package Natural_Vectors is new Ada.Containers.Vectors (Natural, Long_Long_Natural);
package Natural_Vectors_Sorting is new Natural_Vectors.Generic_Sorting;
package Chunks_Vectors_Vectors is new Ada.Containers.Vectors (Natural, Chunks_Vectors.Vector, Chunks_Vectors."=");
Corresponding_Chunk : Corresponding_Chunk_Maps.Map;
File : File_Type;
Start_Time, End_Time : CPU_Time;
Execution_Duration : Time_Span;
Values : Chunks_Vectors_Vectors.Vector := Chunks_Vectors_Vectors.Empty_Vector;
Result : Long_Long_Natural := 0;
begin
Get_File (File);
-- Get all values
while not End_Of_File (File) loop