annotate gcc/ada/libgnat/a-chtgbo.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_BOUNDED_OPERATIONS --
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 do not depend on keys.
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 with Ada.Streams;
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 generic
kono
parents:
diff changeset
36 with package HT_Types is
kono
parents:
diff changeset
37 new Generic_Bounded_Hash_Table_Types (<>);
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 use HT_Types, HT_Types.Implementation;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 with function Hash_Node (Node : Node_Type) return Hash_Type;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 with function Next (Node : Node_Type) return Count_Type;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 with procedure Set_Next
kono
parents:
diff changeset
46 (Node : in out Node_Type;
kono
parents:
diff changeset
47 Next : Count_Type);
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 package Ada.Containers.Hash_Tables.Generic_Bounded_Operations is
kono
parents:
diff changeset
50 pragma Pure;
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 function Index
kono
parents:
diff changeset
53 (Buckets : Buckets_Type;
kono
parents:
diff changeset
54 Node : Node_Type) return Hash_Type;
kono
parents:
diff changeset
55 pragma Inline (Index);
kono
parents:
diff changeset
56 -- Uses the hash value of Node to compute its Buckets array index
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 function Index
kono
parents:
diff changeset
59 (HT : Hash_Table_Type'Class;
kono
parents:
diff changeset
60 Node : Node_Type) return Hash_Type;
kono
parents:
diff changeset
61 pragma Inline (Index);
kono
parents:
diff changeset
62 -- Uses the hash value of Node to compute its Hash_Table buckets array
kono
parents:
diff changeset
63 -- index.
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 function Checked_Index
kono
parents:
diff changeset
66 (Hash_Table : aliased in out Hash_Table_Type'Class;
kono
parents:
diff changeset
67 Node : Count_Type) return Hash_Type;
kono
parents:
diff changeset
68 -- Calls Index, but also locks and unlocks the container, per AI05-0022, in
kono
parents:
diff changeset
69 -- order to detect element tampering by the generic actual Hash function.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 generic
kono
parents:
diff changeset
72 with function Find
kono
parents:
diff changeset
73 (HT : Hash_Table_Type'Class;
kono
parents:
diff changeset
74 Key : Node_Type) return Boolean;
kono
parents:
diff changeset
75 function Generic_Equal (L, R : Hash_Table_Type'Class) return Boolean;
kono
parents:
diff changeset
76 -- Used to implement hashed container equality. For each node in hash table
kono
parents:
diff changeset
77 -- L, it calls Find to search for an equivalent item in hash table R. If
kono
parents:
diff changeset
78 -- Find returns False for any node then Generic_Equal terminates
kono
parents:
diff changeset
79 -- immediately and returns False. Otherwise if Find returns True for every
kono
parents:
diff changeset
80 -- node then Generic_Equal returns True.
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 procedure Clear (HT : in out Hash_Table_Type'Class);
kono
parents:
diff changeset
83 -- Deallocates each node in hash table HT. (Note that it only deallocates
kono
parents:
diff changeset
84 -- the nodes, not the buckets array.) Program_Error is raised if the hash
kono
parents:
diff changeset
85 -- table is busy.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure Delete_Node_At_Index
kono
parents:
diff changeset
88 (HT : in out Hash_Table_Type'Class;
kono
parents:
diff changeset
89 Indx : Hash_Type;
kono
parents:
diff changeset
90 X : Count_Type);
kono
parents:
diff changeset
91 -- Delete a node whose bucket position is known. extracted from following
kono
parents:
diff changeset
92 -- subprogram, but also used directly to remove a node whose element has
kono
parents:
diff changeset
93 -- been modified through a key_preserving reference: in that case we cannot
kono
parents:
diff changeset
94 -- use the value of the element precisely because the current value does
kono
parents:
diff changeset
95 -- not correspond to the hash code that determines its bucket.
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 procedure Delete_Node_Sans_Free
kono
parents:
diff changeset
98 (HT : in out Hash_Table_Type'Class;
kono
parents:
diff changeset
99 X : Count_Type);
kono
parents:
diff changeset
100 -- Removes node X from the hash table without deallocating the node
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 generic
kono
parents:
diff changeset
103 with procedure Set_Element (Node : in out Node_Type);
kono
parents:
diff changeset
104 procedure Generic_Allocate
kono
parents:
diff changeset
105 (HT : in out Hash_Table_Type'Class;
kono
parents:
diff changeset
106 Node : out Count_Type);
kono
parents:
diff changeset
107 -- Claim a node from the free store. Generic_Allocate first
kono
parents:
diff changeset
108 -- calls Set_Element on the potential node, and then returns
kono
parents:
diff changeset
109 -- the node's index as the value of the Node parameter.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Free
kono
parents:
diff changeset
112 (HT : in out Hash_Table_Type'Class;
kono
parents:
diff changeset
113 X : Count_Type);
kono
parents:
diff changeset
114 -- Return a node back to the free store, from where it had
kono
parents:
diff changeset
115 -- been previously claimed via Generic_Allocate.
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 function First (HT : Hash_Table_Type'Class) return Count_Type;
kono
parents:
diff changeset
118 -- Returns the head of the list in the first (lowest-index) non-empty
kono
parents:
diff changeset
119 -- bucket.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 function Next
kono
parents:
diff changeset
122 (HT : Hash_Table_Type'Class;
kono
parents:
diff changeset
123 Node : Count_Type) return Count_Type;
kono
parents:
diff changeset
124 -- Returns the node that immediately follows Node. This corresponds to
kono
parents:
diff changeset
125 -- either the next node in the same bucket, or (if Node is the last node in
kono
parents:
diff changeset
126 -- its bucket) the head of the list in the first non-empty bucket that
kono
parents:
diff changeset
127 -- follows.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 generic
kono
parents:
diff changeset
130 with procedure Process (Node : Count_Type);
kono
parents:
diff changeset
131 procedure Generic_Iteration (HT : Hash_Table_Type'Class);
kono
parents:
diff changeset
132 -- Calls Process for each node in hash table HT
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 generic
kono
parents:
diff changeset
135 use Ada.Streams;
kono
parents:
diff changeset
136 with procedure Write
kono
parents:
diff changeset
137 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
138 Node : Node_Type);
kono
parents:
diff changeset
139 procedure Generic_Write
kono
parents:
diff changeset
140 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
141 HT : Hash_Table_Type'Class);
kono
parents:
diff changeset
142 -- Used to implement the streaming attribute for hashed containers. It
kono
parents:
diff changeset
143 -- calls Write for each node to write its value into Stream.
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 generic
kono
parents:
diff changeset
146 use Ada.Streams;
kono
parents:
diff changeset
147 with function New_Node (Stream : not null access Root_Stream_Type'Class)
kono
parents:
diff changeset
148 return Count_Type;
kono
parents:
diff changeset
149 procedure Generic_Read
kono
parents:
diff changeset
150 (Stream : not null access Root_Stream_Type'Class;
kono
parents:
diff changeset
151 HT : out Hash_Table_Type'Class);
kono
parents:
diff changeset
152 -- Used to implement the streaming attribute for hashed containers. It
kono
parents:
diff changeset
153 -- first clears hash table HT, then populates the hash table by calling
kono
parents:
diff changeset
154 -- New_Node for each item in Stream.
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 end Ada.Containers.Hash_Tables.Generic_Bounded_Operations;