-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
--- Note: source of this algorithm: GNAT.HTable.Hash (g-htable.adb)
+with System.String_Hash;
function Ada.Strings.Wide_Unbounded.Wide_Hash
(Key : Unbounded_Wide_String) return Containers.Hash_Type
is
use Ada.Containers;
-
- function Rotate_Left
- (Value : Hash_Type;
- Amount : Natural) return Hash_Type;
- pragma Import (Intrinsic, Rotate_Left);
-
- Tmp : Hash_Type;
-
+ function Hash is new System.String_Hash.Hash
+ (Wide_Character, Wide_String, Hash_Type);
begin
- Tmp := 0;
- for J in 1 .. Key.Last loop
- Tmp := Rotate_Left (Tmp, 3) + Wide_Character'Pos (Key.Reference (J));
- end loop;
-
- return Tmp;
+ return Hash (To_Wide_String (Key));
end Ada.Strings.Wide_Unbounded.Wide_Hash;