1
----------------------------------------------------------------------
2
-- Binary_Map - Package specification --
3
-- Copyright (C) 2005 Adalog --
4
-- Author: J-P. Rosen --
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 --
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. --
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 --
33
----------------------------------------------------------------------
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 <>;
41
type Map is private; -- Object semantic
43
Not_Present : exception;
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
50
function Fetch (From : in Map; Key : Key_Type; Default_Value : Value_Type)
52
-- Returns Default_Value if Key not found
54
function Is_Present (Within : in Map; Key : Key_Type) return Boolean;
57
with procedure Action (Key : in Key_Type; Value : in out Value_Type);
58
procedure Iterate (On : Map);
60
-- Rebalance the binary map.
61
procedure Balance (The_Map : in out Map);
63
-- Clears all elements:
64
procedure Clear (The_Map : in out Map);
66
-- Check if there are elements:
67
function Is_Empty (The_Map : in Map) return Boolean;
70
with procedure Release (Value : in out Value_Type);
71
procedure Generic_Clear_And_Release (The_Map : in out Map);
74
type Slots is (Before, After);
75
type Two_Pool is array (Slots) of Map;
82
type Map is access Node;