DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ B T ┃
Length: 4457 (0x1169) Types: TextFile Names: »B«
└─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16 └─ ⟦6f12a12be⟧ »DATA« └─⟦this⟧
with Text_Io; package body Constant_String_Bak is Number_Of_Conflict : Natural := 0; Table_Width : constant Integer := 1027; type Table_Of_Strings is array (Integer range 1 .. Table_Width) of Object; Table : Table_Of_Strings; ------------------------------------------------------------ procedure Initialize is begin for I in Table'Range loop Table (I) := Null_Object; end loop; end Initialize; ------------------------------------------------------------ function Hash_String2 (Str : String) return Integer is S : Integer := 0; Part : Integer; Target : Integer; begin Part := Str'Length / 3; Target := Part; if Part = 0 then for I in Str'Range loop S := (S + Character'Pos (Str (I))); end loop; else S := (S + Character'Pos (Str (1))); for I in 1 .. 3 loop S := (S + Character'Pos (Str (Target))); Target := Target + Part; end loop; end if; return S mod Table_Width + 1; end Hash_String2; ------------------------------------------------------------ function Hash_String3 (Str : String) return Integer is S : Integer := 0; Part : Integer; Target : Integer; begin Part := Str'Length / 3; Target := Part; if Part = 0 then for I in Str'Range loop S := (S + Character'Pos (Str (I))); end loop; else S := Character'Pos (Str (1)); for I in 1 .. 3 loop S := (S + Character'Pos (Str (Target))); Target := Target + Part; end loop; end if; return S + 1; end Hash_String3; ------------------------------------------------------------ function Hash_String (Str : String) return Integer is S : Integer := 0; Part : Integer; Target : Integer; begin for I in Str'Range loop S := (S + Character'Pos (Str (I))) + 1; end loop; return (S mod Table_Width) + 1; end Hash_String; ------------------------------------------------------------ procedure Insert (Ch : String; Place : Integer) is A_Access_String : Object; begin A_Access_String := new String_Access'(Value => new String'(Ch), Next => Table (Place)); Table (Place) := A_Access_String; end Insert; ------------------------------------------------------------ function Is_Equal (Ch : String; O : Constant_String.Object) return Boolean is begin return Ch = O.Value.all; end Is_Equal; ------------------------------------------------------------ function Value (S : String) return Constant_String.Object is Place : Integer; Finded : Boolean := False; Object_Pointer : Object; begin Text_Io.Put_Line (" "); Place := Hash_String (S); -- Text_Io.Put_Line ("chaine : " & S & " ...place= " & -- Integer'Image (Place)); Object_Pointer := Table (Place); while not Finded and then Object_Pointer /= Null_Object loop if Is_Equal (S, Object_Pointer) then -- Text_Io.Put_Line ("chaine existe deja dans la table "); Finded := True; else Object_Pointer := Object_Pointer.Next; end if; end loop; if not Finded then if Table (Place) /= Null_Object then -- Text_Io.Put_Line (" il y a un conflit"); Number_Of_Conflict := Number_Of_Conflict + 1; end if; Insert (S, Place); -- Text_Io.Put_Line ("la chaine est ajouitee dans la table"); end if; return Table (Place); end Value; ------------------------------------------------------------ function Conflicts_Number return Natural is begin return Number_Of_Conflict; end Conflicts_Number; ------------------------------------------------------------ function Image (C : Constant_String.Object) return String is begin return C.Value.all; end Image; ------------------------------------------------------------ begin Initialize; end Constant_String_Bak;