1. with Ada.Strings.Unbounded;             use Ada.Strings.Unbounded; 
  2.  
  3. private with Ada.Containers; 
  4.  
  5. package Hashed_Strings is 
  6.  
  7.     pragma Preelaborate; 
  8.  
  9.     -- A Hashed_String is built from a fixed string using a case-sensitive hash 
  10.     -- function so that it can quickly be compared to other hashed strings. Note 
  11.     -- that the comparison isn't 100% accurate because hash collisions for 
  12.     -- differing strings are possible. Use a Hashed_String if you have a 
  13.     -- constant, case-sensitive string that needs to be compared with other 
  14.     -- constant strings frequently. 
  15.     type Hashed_String is private; 
  16.  
  17.     -- Returns True if the Hashed_Strings match based on hash comparison. This 
  18.     -- isn't 100% accurate. See the comments for the Hashed_String type. 
  19.     function "="( l, r : Hashed_String ) return Boolean; 
  20.  
  21.     -- Like the '=' operator, this function is based on hash comparison. 
  22.     function "<"( l, r : Hashed_String ) return Boolean; 
  23.  
  24.     -- Returns a string from the concatenation of a Hashed_String with a fixed string. 
  25.     function "&"( l : Hashed_String; r : String ) return String; 
  26.  
  27.     -- Returns a string from the concatenation of a fixed string with a Hashed_String. 
  28.     function "&"( l : String; r : Hashed_String ) return String; 
  29.  
  30.     -- Returns a string from the concatenation of two Hashed_Strings. 
  31.     function "&"( l, r : Hashed_String ) return String; 
  32.  
  33.     -- Returns True if the Hashed_Strings match exactly. This is slower than the 
  34.     -- '=' operator because the string contents will be compared if the hash 
  35.     -- values match. 
  36.     function Equivalent( l, r : Hashed_String ) return Boolean; 
  37.  
  38.     -- Makes a Hashed_String from a fixed string. 
  39.     function To_Hashed_String( str : String ) return Hashed_String; 
  40.  
  41.     -- Returns the Hashed_String's internal string. 
  42.     function To_String( hs : Hashed_String ) return String; 
  43.  
  44. private 
  45.  
  46.     use Ada.Containers; 
  47.  
  48.     type Hashed_String is 
  49.         record 
  50.             ht  : Hash_Type; 
  51.             str : Unbounded_String; 
  52.         end record; 
  53.  
  54. end Hashed_Strings;