SheafSystem  0.0.0.0
implicit_entry_map.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 IMPLICIT_ENTRY_MAP_H
22 #define IMPLICIT_ENTRY_MAP_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 POD_TYPES_H
33 #include "SheafSystem/pod_types.h"
34 #endif
35 
36 #ifndef STD_UNORDERED_MAP_H
37 #include "SheafSystem/std_unordered_map.h"
38 #endif
39 
40 #ifndef STD_MAP_H
41 #include "SheafSystem/std_map.h"
42 #endif
43 
44 namespace sheaf
45 {
46 
47 template <typename E, typename I> class implicit_entry_map_iterator;
48 template <typename T> class rc_ptr;
49 
50 // Forward declarations to enable friend declaration.
51 
52 template <typename E, typename I> class implicit_entry_map;
53 
58 template <typename E, typename I>
59 size_t
60 deep_size(const implicit_entry_map<E, I>& xmap, bool xinclude_shallow = true);
61 
65 template <typename E, typename I>
66 class SHEAF_DLL_SPEC implicit_entry_map : public any
67 {
68 
69  friend
70  size_t
71  deep_size<E, I>(const implicit_entry_map<E, I>& xmap, bool xinclude_shallow);
72 
73  friend class implicit_entry_map_iterator<E, I>;
74  friend class index_space_family;
75 
76  // ===========================================================
78  // ===========================================================
80 
81 public:
82 
87 
92 
97 
102 
107 
112 
116  bool contains_explicit_entry(pod_type xid) const;
117 
121  bool contains_implicit_entry(pod_type xid) const;
122 
127  bool contains_entry(pod_type xid) const;
128 
134  E& value(pod_type xid) const;
135 
142  E& operator [] (pod_type xid) const;
143 
147  void insert_explicit_entry(pod_type xid, E& xvalue);
148 
152  void insert_implicit_interval(I& xinterval);
153 
157  void remove_explicit_entry(pod_type xid);
158 
162  void remove_implicit_interval(pod_type xid);
163 
168  void remove_entry(pod_type xid, bool xremove_interval);
169 
173  implicit_entry_map_iterator<E, I>* iterator() const;
174 
178  pod_type begin() const;
179 
183  pod_type end() const;
184 
188  size_type ct() const;
189 
190 protected:
191 
195  static const explicit_value_type& null_explicit_value();
196 
200  static const interval_type& null_interval();
201 
205  const explicit_value_type& explicit_value(pod_type xid) const;
206 
210  const interval_type& implicit_interval(pod_type xid) const;
211 
212 private:
213 
218  void update_extrema_for_insert(pod_type xbegin, pod_type xend);
219 
224  void update_extrema_for_remove(pod_type xbegin, pod_type xend);
225 
229  typedef unordered::unordered_map<pod_type, explicit_value_type*> explicit_value_map_type;
230 
234  explicit_value_map_type _explicit_value_map;
235 
239  typedef map<pod_type, interval_type*> interval_map_type;
240 
244  interval_map_type _interval_map;
245 
249  pod_type _begin;
250 
254  pod_type _end;
255 
259  size_type _ct;
260 
262 
263 
264  // ===========================================================
266  // ===========================================================
268 
269 public:
270 
274  virtual bool is_ancestor_of(const any* other) const;
275 
280  virtual implicit_entry_map<E, I>* clone() const;
281 
285  virtual bool invariant() const;
286 
287 protected:
288 
289 private:
290 
292 
293 };
294 
295 
296 // ===========================================================
297 // NON-MEMBER FUNCTIONS
298 // ===========================================================
299 
300 
301 } // namespace sheaf
302 
303 #endif // IMPLICIT_ENTRY_MAP_H
rc_ptr< E > explicit_value_type
The type of an explicit value.
Abstract base class with useful features for all objects.
Definition: any.h:39
A map in which the entries may be implicit.
An iterator over the entries in an implicit_entry_map. This iteration is NOT order preserving...
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
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
Namespace for the sheaves component of the sheaf system.
Factory and container for a family of id spaces.
implicit_entry_map_iterator< E, I > iterator_type
The type of iterator for this map.
rc_ptr< I > interval_type
The type of an interval.
pod_index_type pod_type
The "plain old data" index type for this.
Reference-counted pointer to object of type T. T must be an implementation of concept class rc_any...
Definition: factory_2.h:47