-
Notifications
You must be signed in to change notification settings - Fork 6
/
pragmarc-data_structures-bags-unbounded-protection.adb
69 lines (61 loc) · 2.42 KB
/
pragmarc-data_structures-bags-unbounded-protection.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- PragmAda Reusable Component (PragmARC)
-- Copyright (C) 2021 by PragmAda Software Engineering. All rights reserved.
-- Released under the terms of the BSD 3-Clause license; see https://opensource.org/licenses
-- **************************************************************************
--
-- History:
-- 2021 May 01 J. Carter V2.1--Adhere to coding standard
-- 2020 Nov 01 J. Carter V2.0--Initial Ada-12 version
----------------------------------------------------------------------------
-- 2020 Feb 15 J. Carter V1.2--Make more Object.Operation friendly
-- 2016 Jun 01 J. Carter V1.1--Changed comments for empty declarative parts
-- 2013 Mar 01 J. Carter V1.0--Initial Ada-07 version
--------------------------------------------------------------------
-- 2002 Oct 01 J. Carter V1.3--Added Context to Iterate
-- 2001 May 01 J. Carter V1.2--Improved time complexity of Empty
-- 2000 Dec 01 J. Carter V1.1--Revised implementation of Iterate
-- 2000 May 01 J. Carter V1.0--Initial release
--
package body PragmARC.Data_Structures.Bags.Unbounded.Protection is
protected body Handle is
procedure Add (Item : in Element) is
-- Empty
begin -- Add
Bag.Add (Item => Item);
end Add;
procedure Clear is
-- Empty
begin -- Clear
Bag.Clear;
end Clear;
procedure Delete (Item : in Element) is
-- Empty
begin -- Delete
Bag.Delete (Item => Item);
end Delete;
function Empty return Boolean is
(Bag.Empty);
function Find (Key : in Element) return Find_Result is
Result : Implementation.Find_Result;
begin -- Find
Result := Bag.Find (Key);
if Result.Found then
return (Found => True, Item => Result.Item);
else
return (Found => False);
end if;
end Find;
procedure Iterate (Action : access procedure (Item : in out Element) ) is
procedure Local is new Implementation.Iterate (Action => Action.all);
begin -- Iterate
Local (Over => Bag);
end Iterate;
function Size return Natural is
(Bag.Size);
procedure Update (Item : in Element) is
-- Empty
begin -- Update
Bag.Update (Item => Item);
end Update;
end Handle;
end PragmARC.Data_Structures.Bags.Unbounded.Protection;