annotate gcc/ada/libgnat/a-chtgke.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT LIBRARY COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- ADA.CONTAINERS.HASH_TABLES.GENERIC_KEYS --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2004-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- This unit was originally developed by Matthew J Heaney. --
kono
parents:
diff changeset
28 ------------------------------------------------------------------------------
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 -- Hash_Table_Type is used to implement hashed containers. This package
kono
parents:
diff changeset
31 -- declares hash-table operations that depend on keys.
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 generic
kono
parents:
diff changeset
34 with package HT_Types is
kono
parents:
diff changeset
35 new Generic_Hash_Table_Types (<>);
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 use HT_Types, HT_Types.Implementation;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 with function Next (Node : Node_Access) return Node_Access;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 with procedure Set_Next
kono
parents:
diff changeset
42 (Node : Node_Access;
kono
parents:
diff changeset
43 Next : Node_Access);
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 type Key_Type (<>) is limited private;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 with function Hash (Key : Key_Type) return Hash_Type;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 with function Equivalent_Keys
kono
parents:
diff changeset
50 (Key : Key_Type;
kono
parents:
diff changeset
51 Node : Node_Access) return Boolean;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 package Ada.Containers.Hash_Tables.Generic_Keys is
kono
parents:
diff changeset
54 pragma Preelaborate;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 function Index
kono
parents:
diff changeset
57 (HT : Hash_Table_Type;
kono
parents:
diff changeset
58 Key : Key_Type) return Hash_Type;
kono
parents:
diff changeset
59 pragma Inline (Index);
kono
parents:
diff changeset
60 -- Returns the bucket number (array index value) for the given key
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 function Checked_Index
kono
parents:
diff changeset
63 (HT : aliased in out Hash_Table_Type;
kono
parents:
diff changeset
64 Key : Key_Type) return Hash_Type;
kono
parents:
diff changeset
65 pragma Inline (Checked_Index);
kono
parents:
diff changeset
66 -- Calls Index, but also locks and unlocks the container, per AI05-0022, in
kono
parents:
diff changeset
67 -- order to detect element tampering by the generic actual Hash function.
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 function Checked_Equivalent_Keys
kono
parents:
diff changeset
70 (HT : aliased in out Hash_Table_Type;
kono
parents:
diff changeset
71 Key : Key_Type;
kono
parents:
diff changeset
72 Node : Node_Access) return Boolean;
kono
parents:
diff changeset
73 -- Calls Equivalent_Keys, but locks and unlocks the container, per
kono
parents:
diff changeset
74 -- AI05-0022, in order to detect element tampering by that generic actual.
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 procedure Delete_Key_Sans_Free
kono
parents:
diff changeset
77 (HT : in out Hash_Table_Type;
kono
parents:
diff changeset
78 Key : Key_Type;
kono
parents:
diff changeset
79 X : out Node_Access);
kono
parents:
diff changeset
80 -- Removes the node (if any) with the given key from the hash table,
kono
parents:
diff changeset
81 -- without deallocating it. Program_Error is raised if the hash
kono
parents:
diff changeset
82 -- table is busy.
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 function Find
kono
parents:
diff changeset
85 (HT : aliased in out Hash_Table_Type;
kono
parents:
diff changeset
86 Key : Key_Type) return Node_Access;
kono
parents:
diff changeset
87 -- Returns the node (if any) corresponding to the given key
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 generic
kono
parents:
diff changeset
90 with function New_Node (Next : Node_Access) return Node_Access;
kono
parents:
diff changeset
91 procedure Generic_Conditional_Insert
kono
parents:
diff changeset
92 (HT : in out Hash_Table_Type;
kono
parents:
diff changeset
93 Key : Key_Type;
kono
parents:
diff changeset
94 Node : out Node_Access;
kono
parents:
diff changeset
95 Inserted : out Boolean);
kono
parents:
diff changeset
96 -- Attempts to insert a new node with the given key into the hash table.
kono
parents:
diff changeset
97 -- If a node with that key already exists in the table, then that node
kono
parents:
diff changeset
98 -- is returned and Inserted returns False. Otherwise New_Node is called
kono
parents:
diff changeset
99 -- to allocate a new node, and Inserted returns True. Program_Error is
kono
parents:
diff changeset
100 -- raised if the hash table is busy.
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 generic
kono
parents:
diff changeset
103 with function Hash (Node : Node_Access) return Hash_Type;
kono
parents:
diff changeset
104 with procedure Assign (Node : Node_Access; Key : Key_Type);
kono
parents:
diff changeset
105 procedure Generic_Replace_Element
kono
parents:
diff changeset
106 (HT : in out Hash_Table_Type;
kono
parents:
diff changeset
107 Node : Node_Access;
kono
parents:
diff changeset
108 Key : Key_Type);
kono
parents:
diff changeset
109 -- Assigns Key to Node, possibly changing its equivalence class. If Node
kono
parents:
diff changeset
110 -- is in the same equivalence class as Key (that is, it's already in the
kono
parents:
diff changeset
111 -- bucket implied by Key), then if the hash table is locked then
kono
parents:
diff changeset
112 -- Program_Error is raised; otherwise Assign is called to assign Key to
kono
parents:
diff changeset
113 -- Node. If Node is in a different bucket from Key, then Program_Error is
kono
parents:
diff changeset
114 -- raised if the hash table is busy. Otherwise it Assigns Key to Node and
kono
parents:
diff changeset
115 -- moves the Node from its current bucket to the bucket implied by Key.
kono
parents:
diff changeset
116 -- Note that it is never proper to assign to Node a key value already
kono
parents:
diff changeset
117 -- in the map, and so if Key is equivalent to some other node then
kono
parents:
diff changeset
118 -- Program_Error is raised.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 end Ada.Containers.Hash_Tables.Generic_Keys;