SheafSystem  0.0.0.0
postorder_iterator.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Implementation for class postorder_iterator
19 
20 #include "SheafSystem/postorder_iterator.h"
21 #include "SheafSystem/assert_contract.h"
22 
26 {
27 
28  // Preconditions:
29 
30  // Body:
31 
32  initialize_order(POSTORDER);
33 
34  // Postconditions:
35 
36  ensure(invariant());
37  ensure(!is_initialized());
38 
39  // Exit
40 
41  return;
42 }
43 
47 {
48 
49  // Preconditions:
50 
51  // Body:
52 
53  // Postconditions:
54 
55  ensure(invariant());
56 
57  // Exit
58 
59  return;
60 }
61 
64 {
65  // Preconditions:
66 
67  // Body:
68 
69  // Postconditions:
70 
71 }
72 
73 
74 bool
76 is_ancestor_of(const any* xother) const
77 {
78  bool result;
79 
80  // Preconditions:
81 
82  // Body:
83 
84  result = dynamic_cast<const postorder_iterator*>(xother) != 0;
85 
86  // Postconditions:
87 
88  // Exit
89 
90  return result;
91 }
92 
95 clone() const
96 {
97  postorder_iterator* result;
98 
99  // Preconditions:
100 
101  // Body:
102 
103  result = new postorder_iterator;
104 
105  // Postconditions:
106 
107  ensure(result != 0);
108  ensure(is_same_type(result));
109  ensure(!result->is_initialized());
110 
111  // Exit
112 
113  return result;
114 }
115 
116 bool
118 invariant() const
119 {
120  bool result = true;
121 
122  // Preconditions:
123 
124  // Body:
125 
127  invariance(order()==POSTORDER);
128 
129  // Postconditions:
130 
131  // Exit
132 
133  return result;
134 }
135 
136 // OTHER CONSTRUCTORS
137 
140  bool xdown,
141  bool xstrict)
142  : filtered_depth_first_iterator(xanchor, xdown, xstrict, POSTORDER)
143 {
144 
145  // Preconditions:
146 
147  // Body:
148 
149  // Postconditions:
150 
151  ensure(invariant());
152 
153  // Exit:
154 
155  return;
156 }
157 
160  const subposet& xfilter,
161  bool xdown,
162  bool xstrict)
163  : filtered_depth_first_iterator(xanchor, xfilter, xdown, xstrict, POSTORDER)
164 {
165 
166  // Preconditions:
167 
168  // Body:
169 
170  // Postconditions:
171 
172  ensure(invariant());
173 
174  // Exit:
175 
176  return;
177 }
178 
181  pod_index_type xfilter_index,
182  bool xdown,
183  bool xstrict)
184  : filtered_depth_first_iterator(xanchor, xfilter_index, xdown, xstrict, POSTORDER)
185 {
186 
187  // Preconditions:
188 
189  // Body:
190 
191  // Postconditions:
192 
193  ensure(invariant());
194 
195  // Exit:
196 
197  return;
198 }
199 
202  const scoped_index& xfilter_index,
203  bool xdown,
204  bool xstrict)
205  : filtered_depth_first_iterator(xanchor, xfilter_index, xdown, xstrict, POSTORDER)
206 {
207 
208  // Preconditions:
209 
210  // Body:
211 
212  // Postconditions:
213 
214  ensure(invariant());
215 
216  // Exit:
217 
218  return;
219 }
220 
223  const std::string& xfilter_name,
224  bool xdown,
225  bool xstrict)
226  : filtered_depth_first_iterator(xanchor, xfilter_name, xdown, xstrict, POSTORDER)
227 {
228 
229  // Preconditions:
230 
231  // Body:
232 
233  // Postconditions:
234 
235  ensure(invariant());
236 
237  // Exit:
238 
239  return;
240 }
A client handle for a subposet.
Definition: subposet.h:86
virtual bool is_initialized() const
True if this has been initialized for iteration with respect to a specific anchor.
void initialize_order(order_type xorder)
Initializes _order and _transition_fcn.
Dperecated. Use postorder_itr. Specialization of the filtered depth-first iterator which exposes the ...
Abstract base class with useful features for all objects.
Definition: any.h:39
bool invariant() const
The class invariant.
order_type order() const
The order of the iteration. Determines which actions are exported to the client.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
postorder_iterator()
Default constructor; creates an unattached iterator, with and all-pass filter.
virtual postorder_iterator * clone() const
Make a new instance of the same type as this.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
An abstract client handle for a member of a poset.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.