b311480e |
1 | -- Created on: 1991-09-02 |
2 | -- Created by: Mireille MERCIEN |
3 | -- Copyright (c) 1991-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
7 | -- |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | generic class HStack from PCollection (Item as Storable) |
18 | inherits Persistent |
19 | |
20 | ---Purpose: A stack is a list of items in which items are |
21 | -- added and removed from the same end, called the |
22 | -- top of the stack. |
23 | |
24 | raises NoSuchObject from Standard |
25 | |
26 | |
27 | class StackNode instantiates HSingleList from PCollection(Item); |
28 | |
29 | class StackIterator from PCollection |
30 | |
31 | ---Purpose: Iterator of the Stack class. |
32 | |
33 | raises NoMoreObject from Standard, |
34 | NoSuchObject from Standard |
35 | is |
36 | |
37 | Create(S : HStack from PCollection) |
38 | returns StackIterator from PCollection; |
39 | ---Purpose: Creates an iterator on the stack S. |
40 | -- Set the iterator at the beginning of the stack S. |
41 | |
42 | More(me) returns Boolean from Standard; |
43 | ---Level: Public |
44 | ---Purpose: Returns True if there are other items. |
45 | |
46 | Next(me: in out) raises NoMoreObject from Standard; |
47 | ---Level: Public |
48 | ---Purpose: Sets the iterator to the next item. |
49 | |
50 | Value(me) returns any Item raises NoSuchObject from Standard; |
51 | ---Level: Public |
52 | ---Purpose: Returns the item value corresponding to |
53 | -- the current position of the iterator. |
54 | |
55 | fields |
56 | TheIterator : StackNode; |
57 | end; |
58 | |
59 | |
60 | is |
61 | Create returns mutable HStack from PCollection; |
62 | ---Purpose: Creates an empty stack. |
63 | |
64 | Depth(me) returns Integer from Standard; |
65 | ---Level: Public |
66 | ---Purpose: Returns the number of items in the stack. |
67 | ---Example: if me = (A B C) |
68 | -- returns 3 |
69 | |
70 | IsEmpty(me) returns Boolean from Standard; |
71 | ---Level: Public |
72 | ---Purpose: Returns True if the stack contains no item. |
73 | |
74 | Top(me) returns any Item |
75 | ---Level: Public |
76 | ---Purpose: Returns the item on the top of the stack. |
77 | -- Raises an exception if the stack is empty. |
78 | ---Example: before |
79 | -- me = (A B C) |
80 | -- after |
81 | -- me = (A B C) |
82 | -- returns |
83 | -- C |
84 | raises NoSuchObject from Standard; |
85 | |
86 | FTop(me) returns StackNode; |
87 | ---Level: Public |
88 | ---Purpose: Returns the field TheTop (the top of the stack). |
89 | |
90 | Push(me : mutable; T : Item); |
91 | ---Level: Public |
92 | ---Purpose: Inserts an item on the top of the stack. |
93 | ---Example: before |
94 | -- me = (A B) , T = C |
95 | -- after |
96 | -- me = (A B C) |
97 | |
98 | Pop(me : mutable) raises NoSuchObject from Standard; |
99 | ---Level: Public |
100 | ---Purpose: Removes an item from the top of the stack. |
101 | -- Raises an exception if the stack is empty. |
102 | ---Example: before |
103 | -- me = (A B C) |
104 | -- after |
105 | -- me = (A B) |
106 | -- returns |
107 | -- C |
108 | |
109 | Clear(me : mutable); |
110 | ---Level: Public |
111 | ---Purpose: Removes all the items from the stack. |
112 | ---Example: before |
113 | -- me = (A B C) |
114 | -- after |
115 | -- me = () |
116 | |
117 | ChangeTop(me:mutable; T : Item) raises NoSuchObject from Standard; |
118 | ---Level: Public |
119 | ---Purpose: Replaces the top of the stack with T. |
120 | -- Raises an exception if the stack is empty. |
121 | ---Example: before |
122 | -- me = (A B C) , T = D |
123 | -- after |
124 | -- me = (A B D) |
125 | |
126 | |
127 | ShallowCopy(me) |
128 | returns mutable like me |
129 | is redefined; |
130 | ---Level: Advanced |
131 | ---C++: function call |
132 | |
133 | |
134 | ShallowDump (me; s: in out OStream) |
135 | is redefined; |
136 | ---Level: Advanced |
137 | ---C++: function call |
138 | |
139 | |
140 | |
141 | fields |
142 | TheTop : StackNode; |
143 | TheDepth : Integer from Standard; |
144 | |
145 | end; |
146 | |
147 | |
148 | |
149 | |
150 | |
151 | |