File : bc-containers-maps-unbounded-synchronized.ads
-- Copyright (C) 1994-2000 Grady Booch and Simon Wright.
-- All Rights Reserved.
--
-- This program is free software; you can redistribute it
-- and/or modify it under the terms of the Ada Community
-- License which comes with this Library.
--
-- This program is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Ada Community License for more details.
-- You should have received a copy of the Ada Community
-- License with this library, in the file named "Ada Community
-- License" or "ACL". If not, contact the author of this library
-- for a copy.
--
-- $Id: bc-containers-maps-unbounded-synchronized.ads,v 1.1.2.1 2000/02/12 14:37:57 simon Exp $
with BC.Support.Synchronization;
generic
type Monitor is new BC.Support.Synchronization.Monitor_Base with private;
package BC.Containers.Maps.Unbounded.Synchronized is
pragma Elaborate_Body;
-- A map denotes a collection forming a dictionary of domain/range
-- pairs. Maps are cached, so that the most recently accessed
-- domain/range pair can be found on the order of O(1).
-- The hash function (the generic parameter Hash) determines the
-- allocation of pairs to hash buckets. The value returned must not
-- change during the lifetime of a given Item. The range of hash values
-- need not be constrained to the number of buckets in the map.
-- The hash function must satisfy the condition that, for objects A and
-- B, if A = B, then Hash (A) must equal Hash (B). The hash function
-- should attempt to spread the set of possible items uniformly across
-- the number of buckets. The quality of the hash function has a
-- significant impact upon performance.
-- XXX A problem in GNAT (3.11p, 3.12a2) means we have to refer to
-- the type Value as Maps.Value.
type Synchronized_Unbounded_Map is new Unbounded_Map with private;
procedure Clear (M : in out Synchronized_Unbounded_Map);
-- Empty the map of all item/value pairs. The cached item/value pair is
-- cleared.
procedure Bind
(M : in out Synchronized_Unbounded_Map; I : Item; V : Maps.Value);
-- If the item already exists in the map, raise BC.Duplicate. Otherwise,
-- add the item/value pair to the map. The cached item/value pair is set
-- to this new binding.
procedure Rebind
(M : in out Synchronized_Unbounded_Map; I : Item; V : Maps.Value);
-- If the item does not exist in the map, raise BC.Not_Found. Otherwise,
-- change the item's binding to the given value. The cached item/value
-- pair is set to this new binding.
procedure Unbind (M : in out Synchronized_Unbounded_Map; I : Item);
-- If the item does not exist in the map, raise BC.Not_Found. Otherwise,
-- remove the item/value binding. The cached item/value pair is cleared.
function Extent (M : Synchronized_Unbounded_Map) return Natural;
-- Return the number of item/value bindings in the map.
function Is_Empty (M : Synchronized_Unbounded_Map) return Boolean;
-- Return True if and only if there are no item/value bindings in the
-- map; otherwise, return False.
function Is_Bound (M : Synchronized_Unbounded_Map; I : Item) return Boolean;
-- Return True if and only if there is a binding for the given item in
-- the map; otherwise, return False. The cached item/value pair is used
-- to accelerate the search; if there is a cache hit, the time complexity
-- of this operation is O(1).
function Value_Of
(M : Synchronized_Unbounded_Map; I : Item) return Maps.Value;
-- If the item does not exist in the map, raises BC.Not_Found. Otherwise,
-- return a constant pointer to the value bound to the given item. The
-- cached item/value pair is used to accelerate the search; if there is a
-- cache hit, the time complexity of this operation is O(1).
private
procedure Lock (M : in out Synchronized_Unbounded_Map);
procedure Unlock (M : in out Synchronized_Unbounded_Map);
type Synchronized_Unbounded_Map is new Unbounded_Map with record
The_Monitor : BC.Support.Synchronization.Monitor_P;
end record;
procedure Initialize (M : in out Synchronized_Unbounded_Map);
procedure Adjust (M : in out Synchronized_Unbounded_Map);
procedure Finalize (M : in out Synchronized_Unbounded_Map);
end BC.Containers.Maps.Unbounded.Synchronized;