SheafSystem  0.0.0.0
interval_set.h
Go to the documentation of this file.
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 
20 
21 #ifndef INTERVAL_SET_H
22 #define INTERVAL_SET_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef ANY_H
29 #include "SheafSystem/any.h"
30 #endif
31 
32 #ifndef STD_MAP_H
33 #include "SheafSystem/std_map.h"
34 #endif
35 
36 #ifndef POD_TYPES_H
37 #include "SheafSystem/pod_types.h"
38 #endif
39 
40 namespace sheaf
41 {
42 
43 class interval_set_iterator;
44 
48 struct SHEAF_DLL_SPEC interval
49 {
54 
58  pod_type _begin;
59 
63  pod_type _end;
64 };
65 
70 class SHEAF_DLL_SPEC interval_set : public any
71 {
72 
73  friend class interval_set_iterator;
74  friend SHEAF_DLL_SPEC size_t deep_size(const interval_set& xset, bool xinclude_shallow);
75 
76  // ===========================================================
78  // ===========================================================
80 
81 public:
82 
87 
91  interval_set();
92 
96  interval_set(const interval_set& xother);
97 
101  ~interval_set();
102 
106  bool operator==(const interval_set& xother) const;
107 
111  void insert_interval(pod_type xbegin, pod_type xend);
112 
116  void insert_member(pod_type xmbr);
117 
121  void remove_interval(pod_type xbegin, pod_type xend);
122 
126  void remove_member(pod_type xmbr);
127 
131  bool contains_member(pod_type xmbr) const;
132 
136  size_type member_ct(pod_type xbegin, pod_type xend) const;
137 
142  bool interval_is_empty(pod_type xbegin, pod_type xend) const;
143 
148  bool interval_is_full(pod_type xbegin, pod_type xend) const;
149 
153  pod_type begin() const;
154 
158  pod_type end() const;
159 
163  void clear();
164 
168  bool is_empty() const;
169 
174  interval_set_iterator* iterator(bool xis_full_iterator) const;
175 
176 protected:
177 
178 private:
179 
183  void put_interval(pod_type xbegin, pod_type xend, bool xvalue);
184 
186 
187 
188  // ===========================================================
190  // ===========================================================
192 
193 public:
194 
198  typedef std::map<pod_type, bool> map_type;
199 
203  typedef map_type::const_iterator map_iterator_type;
204 
208  const map_type& interval_map() const;
209 
213  bool first_map_entry() const;
214 
218  bool last_map_entry() const;
219 
220 protected:
221 
222 private:
223 
227  map_type _interval_map;
228 
230 
231  // ===========================================================
233  // ===========================================================
235 
236 public:
237 
241  virtual bool is_ancestor_of(const any* other) const;
242 
247  virtual interval_set* clone() const;
248 
252  interval_set& operator=(const interval_set& xother);
253 
257  virtual bool invariant() const;
258 
259 protected:
260 
261 private:
262 
264 
265 };
266 
267 // ===========================================================
268 // NON-MEMBER FUNCTIONS
269 // ===========================================================
270 
274 SHEAF_DLL_SPEC
275 std::ostream& operator << (std::ostream& xos, const interval_set& xset);
276 
280 SHEAF_DLL_SPEC
281 size_t deep_size(const interval_set& xset, bool xinclude_shallow = true);
282 
283 } // namespace sheaf
284 
285 #endif // ifndef INTERVAL_SET_H
286 
287 
An iterator over the integers in an interval_set.
Set of integers optimized for when the integers are concentrated in closed intervals.
Definition: interval_set.h:70
pod_index_type pod_type
The "plain old data" index type for this.
Definition: interval_set.h:53
pod_index_type pod_type
The "plain old data" index type for this set.
Definition: interval_set.h:86
std::map< pod_type, bool > map_type
The type of the interval map.
Definition: interval_set.h:198
pod_type _end
End of the interval.
Definition: interval_set.h:63
Abstract base class with useful features for all objects.
Definition: any.h:39
Struct representing the closed interval [_begin, _end].
Definition: interval_set.h:48
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
bool operator==(const singly_linked_list< T, Alloc > &lhs, const singly_linked_list< T, Alloc > &rhs)
Checks if the contents of lhs and rhs are equal, that is, whether lhs.size() == rhs.size() and each element in lhs compares equal with the element in rhs at the same position.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
Namespace for the sheaves component of the sheaf system.
pod_type _begin
Beginning of the interval.
Definition: interval_set.h:58
map_type::const_iterator map_iterator_type
The type of the interval map iterator.
Definition: interval_set.h:203