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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
-- File: PCollection_HSet.cdl
-- Created: Mon Sep 2 14:45:39 1991
-- Author: Mireille MERCIEN
-- <apc@topsn1>
---Copyright: Matra Datavision 1991
generic class HSet from PCollection (Item as Storable)
inherits Persistent
---Purpose: A set is an unordered collection of items.
-- We can not have duplicated items in a given set.
raises NoSuchObject from Standard
class SetNode instantiates HSingleList from PCollection(Item);
class SetIterator from PCollection
---Purpose: Iterator of the Set class.
raises NoMoreObject from Standard,
NoSuchObject from Standard
is
Create(S : HSet from PCollection)
returns SetIterator from PCollection;
---Purpose: Creates an iterator on the set S.
-- Set the iterator at the beginning of the set S.
More(me) returns Boolean from Standard;
---Level: Public
---Purpose: Returns True if there are other items.
Next(me: in out) raises NoMoreObject from Standard;
---Level: Public
---Purpose: Sets the iterator to the next item.
Value(me) returns any Item raises NoSuchObject from Standard;
---Level: Public
---Purpose: Returns the item value corresponding to
-- the current position of the iterator.
fields
TheIterator : SetNode;
end;
is
Create returns mutable HSet from PCollection;
---Purpose: Creation of an empty set.
Extent(me) returns Integer from Standard;
---Level: Public
---Purpose: Number of items in the set me
---Example: if S is the set {a,b,c,d,e}
-- Extent returns 5
Last(me) returns SetNode;
---Level: Public
---Purpose: Returns the field TheLast .
-- (the last item enterred in the set)
IsEmpty(me) returns Boolean from Standard;
---Level: Public
---Purpose: Returns True if the set me is empty.
Clear(me : mutable);
---Level: Public
---Purpose: Removes all the items of the set me.
---Example: before
-- me = {a,b,c,d}
-- after
-- me = {}
Add(me : mutable; T : Item) returns Boolean from Standard;
---Level: Public
---Purpose: Adds an item T in the set me if it does not already exist.
-- Returns False if the item T already exists, True otherwise.
---Example: before
-- me = {a,b,c,d}, T = y
-- after
-- me = {a,b,c,d,y}
Remove(me : mutable; T : Item) raises NoSuchObject from Standard;
---Level: Public
---Purpose: Removes the item T in the set me
-- Raises an exception if the item is not in the set.
---Example: before
-- me = {a,b,c,d}, T = a
-- after
-- me = {b,c,d}
-- returns ()
Union(me; B : HSet from PCollection) returns mutable HSet from PCollection;
---Level: Public
---Purpose: Creation of a set containing all the items
-- of the set me and all the items of the set B which
-- are not in me.
---Example: before
-- me = {a,b,c}, B = {d,a,f}
-- after
-- me = {a,b,c}, B = {d,a,f}
-- returns
-- {a,b,c,d,f}
Intersection(me; B : HSet from PCollection) returns mutable HSet from PCollection;
---Level: Public
---Purpose: Creation of a set containing all the
-- items which are both in the set <me> and in the set B.
---Example: before
-- me = {a,b,c}, B = {d,a,f}
-- after
-- me = {a,b,c}, B = {d,a,f}
-- returns
-- {a}
Difference(me; B: HSet from PCollection) returns mutable HSet from PCollection;
---Level: Public
---Purpose: Creation of a set containing the items
-- which are in the set me and not in the set B.
---Example: before
-- me = {a,b,c}, B = {d,a,f}
-- after
-- me = {a,b,c}, B = {d,a,f}
-- returns
-- {b,c}
Contains(me; T : Item) returns Boolean from Standard;
---Level: Public
---Purpose: Returns True if an item is in the set me.
IsASubset(me; S : HSet from PCollection) returns Boolean from Standard;
---Level: Public
---Purpose: Returns True if a set is contained in the set me.
-- The two sets can be identical.
IsAProperSubset(me; S : HSet from PCollection) returns Boolean from
Standard;
---Level: Public
---Purpose: Returns True if a set is contained in the set me.
-- The two sets cannot be identical.
ShallowCopy(me)
returns mutable like me
is redefined;
---Level: Advanced
---C++: function call
ShallowDump (me; s: in out OStream)
is redefined;
---Level: Advanced
---C++: function call
fields
TheExtent : Integer from Standard;
TheLast : SetNode;
end;
|