OSDN Git Service

* gcc-interface/trans.c (Call_to_gnu): Robustify test for function case
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-chtgbo.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT LIBRARY COMPONENTS                          --
4 --                                                                          --
5 --           ADA.CONTAINERS.HASH_TABLES.GENERIC_BOUNDED_OPERATIONS          --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2004-2010, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17 --                                                                          --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception,   --
20 -- version 3.1, as published by the Free Software Foundation.               --
21 --                                                                          --
22 -- You should have received a copy of the GNU General Public License and    --
23 -- a copy of the GCC Runtime Library Exception along with this program;     --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25 -- <http://www.gnu.org/licenses/>.                                          --
26 --                                                                          --
27 -- This unit was originally developed by Matthew J Heaney.                  --
28 ------------------------------------------------------------------------------
29
30 --  Hash_Table_Type is used to implement hashed containers. This package
31 --  declares hash-table operations that do not depend on keys.
32
33 with Ada.Streams;
34
35 generic
36    with package HT_Types is
37      new Generic_Bounded_Hash_Table_Types (<>);
38
39    use HT_Types;
40
41    with function Hash_Node (Node : Node_Type) return Hash_Type;
42
43    with function Next (Node : Node_Type) return Count_Type;
44
45    with procedure Set_Next
46      (Node : in out Node_Type;
47       Next : Count_Type);
48
49 package Ada.Containers.Hash_Tables.Generic_Bounded_Operations is
50    pragma Pure;
51
52    function Index
53      (Buckets : Buckets_Type;
54       Node    : Node_Type) return Hash_Type;
55    pragma Inline (Index);
56    --  Uses the hash value of Node to compute its Buckets array index
57
58    function Index
59      (HT   : Hash_Table_Type'Class;
60       Node : Node_Type) return Hash_Type;
61    pragma Inline (Index);
62    --  Uses the hash value of Node to compute its Hash_Table buckets array
63    --  index.
64
65    generic
66       with function Find
67         (HT  : Hash_Table_Type'Class;
68          Key : Node_Type) return Boolean;
69    function Generic_Equal (L, R : Hash_Table_Type'Class) return Boolean;
70    --  Used to implement hashed container equality. For each node in hash table
71    --  L, it calls Find to search for an equivalent item in hash table R. If
72    --  Find returns False for any node then Generic_Equal terminates
73    --  immediately and returns False. Otherwise if Find returns True for every
74    --  node then Generic_Equal returns True.
75
76    procedure Clear (HT : in out Hash_Table_Type'Class);
77    --  Deallocates each node in hash table HT. (Note that it only deallocates
78    --  the nodes, not the buckets array.)  Program_Error is raised if the hash
79    --  table is busy.
80
81    procedure Delete_Node_Sans_Free
82      (HT : in out Hash_Table_Type'Class;
83       X  : Count_Type);
84    --  Removes node X from the hash table without deallocating the node
85
86    generic
87       with procedure Set_Element (Node : in out Node_Type);
88    procedure Generic_Allocate
89      (HT   : in out Hash_Table_Type'Class;
90       Node : out Count_Type);
91    --  Claim a node from the free store. Generic_Allocate first
92    --  calls Set_Element on the potential node, and then returns
93    --  the node's index as the value of the Node parameter.
94
95    procedure Free
96      (HT : in out Hash_Table_Type'Class;
97       X  : Count_Type);
98    --  Return a node back to the free store, from where it had
99    --  been previously claimed via Generic_Allocate.
100
101    function First (HT : Hash_Table_Type'Class) return Count_Type;
102    --  Returns the head of the list in the first (lowest-index) non-empty
103    --  bucket.
104
105    function Next
106      (HT   : Hash_Table_Type'Class;
107       Node : Count_Type) return Count_Type;
108    --  Returns the node that immediately follows Node. This corresponds to
109    --  either the next node in the same bucket, or (if Node is the last node in
110    --  its bucket) the head of the list in the first non-empty bucket that
111    --  follows.
112
113    generic
114       with procedure Process (Node : Count_Type);
115    procedure Generic_Iteration (HT : Hash_Table_Type'Class);
116    --  Calls Process for each node in hash table HT
117
118    generic
119       use Ada.Streams;
120       with procedure Write
121         (Stream : not null access Root_Stream_Type'Class;
122          Node   : Node_Type);
123    procedure Generic_Write
124      (Stream : not null access Root_Stream_Type'Class;
125       HT     : Hash_Table_Type'Class);
126    --  Used to implement the streaming attribute for hashed containers. It
127    --  calls Write for each node to write its value into Stream.
128
129    generic
130       use Ada.Streams;
131       with function New_Node (Stream : not null access Root_Stream_Type'Class)
132          return Count_Type;
133    procedure Generic_Read
134      (Stream : not null access Root_Stream_Type'Class;
135       HT     : out Hash_Table_Type'Class);
136    --  Used to implement the streaming attribute for hashed containers. It
137    --  first clears hash table HT, then populates the hash table by calling
138    --  New_Node for each item in Stream.
139
140 end Ada.Containers.Hash_Tables.Generic_Bounded_Operations;