fc9e90b1e2e32603e93cfc165bceb860960eab1a
[occt.git] / src / PCollection / PCollection_HQueue.cdl
1 -- Created on: 1993-02-10
2 -- Created by: Mireille MERCIEN
3 -- Copyright (c) 1993-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 HQueue from PCollection (Item as Storable)
18 inherits Persistent
19
20      ---Purpose: A queue is a sequence of items in which items 
21      -- are added at one end (called the back of the
22      -- queue) and removed at the other end (called
23      -- the front)
24      -- The Queue is empty if there are no elements.
25
26 raises   NoSuchObject from Standard
27
28
29     class QueueNode instantiates HSingleList from PCollection(Item);
30
31     class QueueIterator from PCollection 
32                                            
33         ---Purpose: Iterator of the class Queue.
34
35     raises NoMoreObject from Standard,
36            NoSuchObject from Standard
37     is     
38  
39         Create(Q : HQueue from PCollection) 
40         returns QueueIterator from PCollection;
41         ---Purpose: Creates an iterator on the queue Q.
42         -- Sets the iterator at the beginning of the Queue Q.
43
44         More(me) returns Boolean from Standard;
45         ---Level: Public
46         ---Purpose: Returns True if there are other items.
47
48         Next(me: in out) raises NoMoreObject from Standard;
49         ---Level: Public
50         ---Purpose: Sets the iterator to the next item.
51             
52         Value(me) returns any Item raises NoSuchObject from Standard;
53         ---Level: Public
54         ---Purpose: Returns the item value corresponding to 
55         -- the current position of the iterator.
56
57     fields
58          TheIterator : QueueNode;
59     end;
60
61
62 is      
63      Create returns mutable HQueue from PCollection;
64         ---Purpose: Creates an empty queue.
65
66      Length(me) returns Integer from Standard;
67         ---Level: Public
68         ---Purpose: Returns the number of items in the queue.
69         ---Example: before
70         --   me = (A B C) 
71         -- returns 3
72
73      IsEmpty(me) returns Boolean from Standard;
74         ---Level: Public
75         ---Purpose: Returns True if the queue contains no element.
76
77      Front(me) returns any Item raises NoSuchObject from Standard; 
78         ---Level: Public
79         ---Purpose: Returns the item at the front of the queue.
80         -- Raises an exception if the queue is empty.
81         ---Example: before
82         --   me = (A B C) 
83         -- after
84         --   me = (A B C)
85         -- returns 
86         --   A
87      
88      FFront(me) returns QueueNode; 
89         ---Level: Public
90         ---Purpose: Returns the field TheFront(the front of the queue).
91
92      FBack(me) returns QueueNode; 
93         ---Level: Public
94         ---Purpose: Returns the field Theback(the back of the queue).
95
96      Clear(me : mutable);
97         ---Level: Public
98         ---Purpose: Removes all the elements from the queue
99         ---Example: before
100         --   me = (A B C) 
101         -- after
102         --   me = ()
103
104      Push(me : mutable; T : Item);
105         ---Level: Public
106         ---Purpose: Inserts an item at the back of the queue.
107         ---Example: before
108         --   me = (A B) , T = C
109         -- after
110         --   me = (A B C)
111
112      Pop(me : mutable) raises NoSuchObject from Standard;
113         ---Level: Public
114         ---Purpose: Removes an item from the front of the queue.
115         -- Raises an exception if the queue is empty
116         ---Example: before
117         --   me = (A B C)
118         -- after
119         --   me = (B C)
120         -- returns 
121         --   A
122  
123      ChangeFront(me:mutable ; T : Item) raises NoSuchObject from Standard;
124         ---Level: Public
125         ---Purpose: Replaces the front element of the queue with T.
126         -- Raises an exception if the queue is empty.
127         ---Example: before
128         --   me = (A B C) , T = D
129         -- after
130         --   me = (D B C)
131
132      ShallowCopy(me) 
133         returns mutable like me 
134         is redefined;
135         ---Level: Advanced
136         ---C++: function call
137
138
139      ShallowDump (me; s: in out OStream) 
140         is redefined;
141         ---Level: Advanced
142         ---C++: function call
143
144
145     Destroy(me : mutable);
146     ---C++: alias ~
147     
148 fields
149      TheFront   : QueueNode;
150      TheBack    : QueueNode;
151      TheLength  : Integer from Standard;  
152 end; 
153
154
155
156
157
158