1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- ADA.CONTAINERS.INDEFINITE_HASHED_MAPS --
9 -- Copyright (C) 2004 Free Software Foundation, Inc. --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the contents of the part following the private keyword. --
15 -- GNAT is free software; you can redistribute it and/or modify it under --
16 -- terms of the GNU General Public License as published by the Free Soft- --
17 -- ware Foundation; either version 2, or (at your option) any later ver- --
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
24 -- MA 02111-1307, USA. --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
33 -- This unit was originally developed by Matthew J Heaney. --
34 ------------------------------------------------------------------------------
36 with Ada
.Containers
.Hash_Tables
;
40 type Key_Type
(<>) is private;
41 type Element_Type
(<>) is private;
43 with function Hash
(Key
: Key_Type
) return Hash_Type
;
44 with function Equivalent_Keys
(Left
, Right
: Key_Type
) return Boolean;
45 with function "=" (Left
, Right
: Element_Type
) return Boolean is <>;
47 package Ada
.Containers
.Indefinite_Hashed_Maps
is
48 pragma Preelaborate
(Indefinite_Hashed_Maps
);
50 type Map
is tagged private;
51 type Cursor
is private;
53 Empty_Map
: constant Map
;
54 No_Element
: constant Cursor
;
56 function "=" (Left
, Right
: Map
) return Boolean;
58 function Length
(Container
: Map
) return Count_Type
;
60 function Is_Empty
(Container
: Map
) return Boolean;
62 procedure Clear
(Container
: in out Map
);
64 function Element
(Position
: Cursor
) return Element_Type
;
66 procedure Query_Element
68 Process
: not null access procedure (Key
: Key_Type
;
69 Element
: Element_Type
));
71 procedure Update_Element
73 Process
: not null access procedure (Key
: Key_Type
;
74 Element
: in out Element_Type
));
76 procedure Replace_Element
80 procedure Move
(Target
: in out Map
; Source
: in out Map
);
83 (Container
: in out Map
;
85 New_Item
: Element_Type
;
86 Position
: out Cursor
;
87 Inserted
: out Boolean);
90 (Container
: in out Map
;
92 New_Item
: Element_Type
);
95 (Container
: in out Map
;
97 New_Item
: Element_Type
);
100 (Container
: in out Map
;
102 New_Item
: Element_Type
);
105 (Container
: in out Map
;
109 (Container
: in out Map
;
113 (Container
: in out Map
;
114 Position
: in out Cursor
);
118 Key
: Key_Type
) return Boolean;
122 Key
: Key_Type
) return Cursor
;
126 Key
: Key_Type
) return Element_Type
;
128 function Capacity
(Container
: Map
) return Count_Type
;
130 procedure Reserve_Capacity
131 (Container
: in out Map
;
132 Capacity
: Count_Type
);
134 function First
(Container
: Map
) return Cursor
;
136 function Next
(Position
: Cursor
) return Cursor
;
138 procedure Next
(Position
: in out Cursor
);
140 function Has_Element
(Position
: Cursor
) return Boolean;
142 function Key
(Position
: Cursor
) return Key_Type
;
144 function Equivalent_Keys
(Left
, Right
: Cursor
)
147 function Equivalent_Keys
149 Right
: Key_Type
) return Boolean;
151 function Equivalent_Keys
153 Right
: Cursor
) return Boolean;
157 Process
: not null access procedure (Position
: Cursor
));
161 type Node_Access
is access Node_Type
;
164 new Hash_Tables
.Generic_Hash_Table_Types
(Node_Access
);
168 type Map
is new Hash_Table_Type
with null record;
170 procedure Adjust
(Container
: in out Map
);
172 procedure Finalize
(Container
: in out Map
);
174 type Map_Access
is access constant Map
;
175 for Map_Access
'Storage_Size use 0;
179 Container
: Map_Access
;
183 No_Element
: constant Cursor
:=
190 (Stream
: access Root_Stream_Type
'Class;
193 for Map
'Write use Write
;
196 (Stream
: access Root_Stream_Type
'Class;
197 Container
: out Map
);
199 for Map
'Read use Read
;
201 Empty_Map
: constant Map
:= (Hash_Table_Type
with null record);
203 end Ada
.Containers
.Indefinite_Hashed_Maps
;