0024645: Pointer to the last is wrong for a tree node
[occt.git] / src / PCollection / PCollection_HSet.cdl
1 -- Created on: 1991-09-02
2 -- Created by: Mireille MERCIEN
3 -- Copyright (c) 1991-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
5 --
6 -- This file is part of Open CASCADE Technology software library.
7 --
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
13 --
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
16
17 generic class HSet from PCollection (Item as Storable) 
18 inherits Persistent
19
20      ---Purpose: A set is an unordered collection of items.
21      -- We can not have duplicated items in a given set.
22     
23 raises   NoSuchObject from Standard
24
25
26     class SetNode instantiates HSingleList from PCollection(Item); 
27
28     class SetIterator from PCollection                                
29         ---Purpose: Iterator of the Set class.
30
31     raises NoMoreObject from Standard,
32            NoSuchObject from Standard
33     is     
34  
35         Create(S : HSet from PCollection) 
36         returns SetIterator from PCollection;
37         ---Purpose: Creates an iterator on the set S.
38         -- Set the iterator at the beginning of the set S.
39
40         More(me) returns Boolean from Standard;
41         ---Level: Public
42         ---Purpose: Returns True if there are other items.
43
44         Next(me: in out) raises NoMoreObject from Standard;
45         ---Level: Public
46         ---Purpose: Sets the iterator to the next item.
47                 
48         Value(me) returns any Item raises NoSuchObject from Standard;
49         ---Level: Public
50         ---Purpose: Returns the item value corresponding to 
51         -- the current position of the iterator.
52
53     fields
54          TheIterator : SetNode;
55     end;
56
57
58 is
59
60      Create returns mutable HSet from PCollection;
61         ---Purpose: Creation of an empty set.
62
63      Extent(me) returns Integer from Standard;
64         ---Level: Public
65         ---Purpose: Number of items in the set me
66         ---Example: if S is the set {a,b,c,d,e} 
67         -- Extent returns 5
68
69      Last(me) returns SetNode;
70         ---Level: Public
71         ---Purpose: Returns the field TheLast .
72         -- (the last item enterred in the set)
73
74      IsEmpty(me) returns Boolean from Standard;
75         ---Level: Public
76         ---Purpose: Returns True if the set me is empty.
77
78      Clear(me : mutable);
79         ---Level: Public
80         ---Purpose: Removes all the items of the set me.
81         ---Example: before
82         --   me = {a,b,c,d}
83         -- after
84         --   me = {}
85
86      Add(me : mutable; T : Item) returns Boolean from Standard;
87         ---Level: Public
88         ---Purpose: Adds an item T in the set me if it does not already exist.
89         -- Returns False if the item T already exists, True otherwise. 
90         ---Example: before
91         --   me = {a,b,c,d}, T = y
92         -- after
93         --   me = {a,b,c,d,y}
94
95      Remove(me : mutable; T : Item) raises NoSuchObject from Standard;
96         ---Level: Public
97         ---Purpose: Removes the item T in the set me
98         -- Raises an exception if the item is not in the set.
99         ---Example: before
100         --   me = {a,b,c,d}, T = a
101         -- after
102         --   me = {b,c,d}
103         -- returns ()
104  
105      Union(me; B : HSet from PCollection) returns mutable HSet from PCollection;
106         ---Level: Public
107         ---Purpose: Creation of a set containing all the items 
108         -- of the set me and all the items of the set B which 
109         -- are not in me.
110         ---Example: before
111         --   me = {a,b,c}, B = {d,a,f}
112         -- after
113         --   me = {a,b,c}, B = {d,a,f}
114         -- returns
115         -- {a,b,c,d,f}
116
117      Intersection(me; B : HSet from PCollection) returns mutable HSet from PCollection;
118         ---Level: Public
119         ---Purpose: Creation of a set containing all the 
120         -- items which are both in the set <me> and in the set B.
121         ---Example: before
122         --   me = {a,b,c}, B = {d,a,f}
123         -- after
124         --   me = {a,b,c}, B = {d,a,f}
125         -- returns
126         --   {a}
127
128      Difference(me; B: HSet from PCollection) returns mutable HSet from PCollection;
129         ---Level: Public
130         ---Purpose: Creation of a set containing the items 
131         -- which are in the set me and not in the set B.
132         ---Example: before
133         --   me = {a,b,c}, B = {d,a,f}
134         -- after
135         --   me = {a,b,c}, B = {d,a,f}
136         -- returns
137         --   {b,c}
138
139      Contains(me; T : Item) returns Boolean from Standard;
140         ---Level: Public
141         ---Purpose: Returns True if an item is in the set me.
142
143      IsASubset(me; S : HSet from PCollection) returns Boolean from Standard;
144         ---Level: Public
145         ---Purpose: Returns True if a set is contained in the set me.
146         -- The two sets can be identical.
147
148      IsAProperSubset(me; S : HSet from PCollection) returns Boolean from 
149         Standard;
150         ---Level: Public
151         ---Purpose: Returns True if a set is contained in the set me.
152         -- The two sets cannot be identical.
153
154      ShallowCopy(me) 
155         returns mutable like me 
156         is redefined;
157         ---Level: Advanced
158         ---C++: function call
159
160
161      ShallowDump (me; s: in out OStream) 
162         is redefined;
163         ---Level: Advanced
164         ---C++: function call
165
166
167
168 fields
169      TheExtent   : Integer from Standard;
170      TheLast     : SetNode;
171 end;