~ubuntu-branches/ubuntu/jaunty/adacontrol/jaunty

« back to all changes in this revision

Viewing changes to src/binary_map.ads

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Brenta
  • Date: 2006-08-24 08:44:11 UTC
  • Revision ID: james.westby@ubuntu.com-20060824084411-1r15uio1h75lqgpx
Tags: upstream-1.4r20
ImportĀ upstreamĀ versionĀ 1.4r20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
----------------------------------------------------------------------
 
2
--  Binary_Map - Package specification                              --
 
3
--  Copyright (C) 2005 Adalog                                       --
 
4
--  Author: J-P. Rosen                                              --
 
5
--                                                                  --
 
6
--  ADALOG   is   providing   training,   consultancy,   expertise, --
 
7
--  assistance and custom developments  in Ada and related software --
 
8
--  engineering techniques.  For more info about our services:      --
 
9
--  ADALOG                   Tel: +33 1 41 24 31 40                 --
 
10
--  19-21 rue du 8 mai 1945  Fax: +33 1 41 24 07 36                 --
 
11
--  94110 ARCUEIL            E-m: info@adalog.fr                    --
 
12
--  FRANCE                   URL: http://www.adalog.fr              --
 
13
--                                                                  --
 
14
--  This  unit is  free software;  you can  redistribute  it and/or --
 
15
--  modify  it under  terms of  the GNU  General Public  License as --
 
16
--  published by the Free Software Foundation; either version 2, or --
 
17
--  (at your  option) any later version.  This  unit is distributed --
 
18
--  in the hope  that it will be useful,  but WITHOUT ANY WARRANTY; --
 
19
--  without even the implied warranty of MERCHANTABILITY or FITNESS --
 
20
--  FOR A  PARTICULAR PURPOSE.  See the GNU  General Public License --
 
21
--  for more details.   You should have received a  copy of the GNU --
 
22
--  General Public License distributed  with this program; see file --
 
23
--  COPYING.   If not, write  to the  Free Software  Foundation, 59 --
 
24
--  Temple Place - Suite 330, Boston, MA 02111-1307, USA.           --
 
25
--                                                                  --
 
26
--  As  a special  exception, if  other files  instantiate generics --
 
27
--  from  this unit,  or you  link this  unit with  other  files to --
 
28
--  produce an executable,  this unit does not by  itself cause the --
 
29
--  resulting executable  to be covered  by the GNU  General Public --
 
30
--  License.  This exception does  not however invalidate any other --
 
31
--  reasons why  the executable  file might be  covered by  the GNU --
 
32
--  Public License.                                                 --
 
33
----------------------------------------------------------------------
 
34
 
 
35
generic
 
36
   type Key_Type   is private;
 
37
   type Value_Type is private;
 
38
   with function "<" (Left, Right : Key_Type) return Boolean is <>;
 
39
   with function ">" (Left, Right : Key_Type) return Boolean is <>;
 
40
package Binary_Map is
 
41
   type Map is private;     -- Object semantic
 
42
 
 
43
   Not_Present : exception;
 
44
 
 
45
   procedure Add        (To     : in out Map; Key : Key_Type; Value : Value_Type);
 
46
   procedure Delete     (From   : in out Map; Key : Key_Type);
 
47
   function  Fetch      (From   : in     Map; Key : Key_Type) return Value_Type;
 
48
   -- Raises Not_Present if Key not found
 
49
 
 
50
   function  Fetch      (From   : in     Map; Key : Key_Type; Default_Value : Value_Type)
 
51
                        return Value_Type;
 
52
   -- Returns Default_Value if Key not found
 
53
 
 
54
   function  Is_Present (Within : in     Map; Key : Key_Type) return Boolean;
 
55
 
 
56
   generic
 
57
      with procedure Action (Key : in Key_Type; Value : in out Value_Type);
 
58
   procedure Iterate (On : Map);
 
59
 
 
60
   -- Rebalance the binary map.
 
61
   procedure Balance (The_Map : in out Map);
 
62
 
 
63
   -- Clears all elements:
 
64
   procedure Clear (The_Map : in out Map);
 
65
 
 
66
   -- Check if there are elements:
 
67
   function Is_Empty (The_Map : in Map) return Boolean;
 
68
 
 
69
   generic
 
70
      with procedure Release (Value : in out Value_Type);
 
71
   procedure Generic_Clear_And_Release (The_Map : in out Map);
 
72
 
 
73
private
 
74
   type Slots is (Before, After);
 
75
   type Two_Pool is array (Slots) of Map;
 
76
   type Node is
 
77
      record
 
78
         Key      : Key_Type;
 
79
         Value    : Value_Type;
 
80
         Children : Two_Pool;
 
81
      end record;
 
82
   type Map is access Node;
 
83
end Binary_Map;
 
84
 
 
85