text stringlengths 0 234 |
|---|
procedure Dispose is new |
Ada.Unchecked_Deallocation (UnZip_Stream_Type, |
Zipped_File_Type); |
-------------------------------------------------- |
-- *The* internal 1 - file unzipping procedure. -- |
-- Input must be _open_ and won't be _closed_ ! -- |
-------------------------------------------------- |
procedure UnZipFile (zip_file : Zip_Streams.Zipstream_Class; |
header_index : in out Ada.Streams.Stream_IO.Positive_Count; |
mem_ptr : out p_Stream_Element_Array; |
password : in out Ada.Strings.Unbounded.Unbounded_String; |
hint_comp_size : File_size_type; -- Added 2007 for .ODS files |
cat_uncomp_size : File_size_type) is |
work_index : Ada.Streams.Stream_IO.Positive_Count := header_index; |
local_header : Zip.Headers.Local_File_Header; |
data_descriptor_present : Boolean; |
encrypted : Boolean; |
method : PKZip_method; |
use Ada.Streams.Stream_IO, Zip, Zip_Streams; |
begin |
begin |
Zip_Streams.Set_Index (zip_file, Positive (header_index)); |
declare |
TempStream : constant Zipstream_Class := zip_file; |
begin |
Zip.Headers.Read_and_check (TempStream, local_header); |
Function Definition: procedure Dispose is new Ada.Unchecked_Deallocation (Dir_node, p_Dir_node); |
Function Body: procedure Dispose is new Ada.Unchecked_Deallocation (String, p_String); |
package Binary_tree_rebalancing is |
procedure Rebalance (root : in out p_Dir_node); |
end Binary_tree_rebalancing; |
package body Binary_tree_rebalancing is |
------------------------------------------------------------------- |
-- Tree Rebalancing in Optimal Time and Space -- |
-- QUENTIN F. STOUT and BETTE L. WARREN -- |
-- Communications of the ACM September 1986 Volume 29 Number 9 -- |
------------------------------------------------------------------- |
-- http://www.eecs.umich.edu/~qstout/pap/CACM86.pdf |
-- |
-- Translated by (New) P2Ada v. 15 - Nov - 2006 |
procedure Tree_to_vine (root : p_Dir_node; size : out Integer) is |
-- transform the tree with pseudo - root |
-- "root^" into a vine with pseudo - root |
-- node "root^", and store the number of |
-- nodes in "size" |
vine_tail, remainder, temp : p_Dir_node; |
begin |
vine_tail := root; |
remainder := vine_tail.all.right; |
size := 0; |
while remainder /= null loop |
if remainder.all.left = null then |
-- move vine - tail down one: |
vine_tail := remainder; |
remainder := remainder.all.right; |
size := size + 1; |
else |
-- rotate: |
temp := remainder.all.left; |
remainder.all.left := temp.all.right; |
temp.all.right := remainder; |
remainder := temp; |
vine_tail.all.right := temp; |
end if; |
end loop; |
end Tree_to_vine; |
procedure Vine_to_tree (root : p_Dir_node; size_given : Integer) is |
-- convert the vine with "size" nodes and pseudo - root |
-- node "root^" into a balanced tree |
leaf_count : Integer; |
size : Integer := size_given; |
procedure Compression (Dir_Root : p_Dir_node; count : Integer) is |
-- compress "count" spine nodes in the tree with pseudo - root "root^" |
scanner, child : p_Dir_node; |
begin |
scanner := Dir_Root; |
for i in 1 .. count loop |
child := scanner.all.right; |
scanner.all.right := child.all.right; |
scanner := scanner.all.right; |
child.all.right := scanner.all.left; |
scanner.all.left := child; |
end loop; |
end Compression; |
-- Returns n - 2 ** Integer (Float'Floor (log (Float (n)) / log (2.0))) |
-- without Float - Point calculation and rounding errors with too short floats |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.