SheafSystem  0.0.0.0
array_index_space_state.cc
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 #include "SheafSystem/array_index_space_state.h"
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/array_index_space_handle.h"
24 #include "SheafSystem/array_index_space_iterator.h"
25 #include "SheafSystem/deep_size.h"
26 #include "SheafSystem/index_space_family.h"
27 #include "SheafSystem/hub_index_space_handle.h"
28 
29 using namespace std;
30 using namespace unordered;
31 
32 // ===========================================================
33 // SPACE FACTORY FACET
34 // ===========================================================
35 
36 // PUBLIC MEMBER FUNCTIONS
37 
41  const std::string& xname,
42  bool xis_persistent,
43  size_type xcapacity)
44 {
45  // Preconditions:
46 
47  require(!xname.empty());
48  require(!xid_spaces.contains(xname));
49  require(xcapacity >= 0);
50 
51  // Body:
52 
54  lstate->new_state(xid_spaces, xname, xis_persistent);
55 
56  lstate->reserve(xcapacity);
57 
58  array_index_space_handle result(*lstate);
59 
60  // Postconditions:
61 
62  ensure(&result.id_spaces() == &xid_spaces);
63  ensure(xid_spaces.contains(xname));
64  ensure(result.conforms_to_state(xname));
65 
66  ensure(result.is_persistent() == xis_persistent);
67  ensure(result.name() == xname);
68 
69  ensure(result.capacity() >= xcapacity);
70 
71  // Exit:
72 
73  return result;
74 }
75 
78 new_space(index_space_family& xid_spaces,
79  pod_index_type xid,
80  const std::string& xname,
81  bool xis_persistent,
82  size_type xcapacity)
83 {
84  // Preconditions:
85 
86  require(!xid_spaces.contains(xid));
87  require(xid_spaces.is_explicit_interval(xid));
88  require(!xname.empty());
89  require(!xid_spaces.contains(xname));
90  require(xcapacity >= 0);
91 
92  // Body:
93 
95  lstate->new_state(xid_spaces, xid, xname, xis_persistent);
96 
97  lstate->reserve(xcapacity);
98 
99  array_index_space_handle result(*lstate);
100 
101  // Postconditions:
102 
103  ensure(&result.id_spaces() == &xid_spaces);
104  ensure(xid_spaces.contains(xname));
105  ensure(result.conforms_to_state(xname));
106 
107  ensure(result.index() == xid);
108  ensure(result.is_persistent() == xis_persistent);
109  ensure(result.name() == xname);
110 
111  ensure(result.capacity() >= xcapacity);
112 
113  // Exit:
114 
115  return result;
116 }
117 
118 // PROTECTED MEMBER FUNCTIONS
119 
120 // PRIVATE MEMBER FUNCTIONS
121 
122 
123 // ===========================================================
124 // ARRAY_INDEX_SPACE_STATE FACET
125 // ===========================================================
126 
127 // PUBLIC MEMBER FUNCTIONS
128 
129 // PROTECTED MEMBER FUNCTIONS
130 
134 {
135  // Preconditions:
136 
137  // Body:
138 
139  reserve(0);
140 
141  // Postconditions:
142 
143  ensure(invariant());
144  ensure(is_empty());
145  ensure(capacity() >= 0);
146 
147  // Exit:
148 
149  return;
150 }
151 
154 {
155  // Preconditions:
156 
157  // Body:
158 
159  // nothing to do.
160 
161  // Postconditions:
162 
163  // Exit:
164 
165  return;
166 }
167 
168 // PRIVATE MEMBER FUNCTIONS
169 
170 
171 // ===========================================================
172 // MUTABLE INDEX SPACE FACET
173 // ===========================================================
174 
175 // PUBLIC MEMBER FUNCTIONS
176 
177 void
180 {
181  // Preconditions:
182 
183  // Body:
184 
185  if(_ct >= 1)
186  {
187  to_domain_type::const_iterator itr = _to_domain.begin();
188 
189  // Initialize values to the first entry.
190 
191  _begin = itr->second;
192  _end = itr->second + 1;
193 
194  ++itr; // Increment iterator to the second entry.
195 
196  while(itr != _to_domain.end())
197  {
198  update_extrema(itr->second);
199 
200  ++itr;
201  }
202  }
203  else
204  {
205  assertion(is_empty());
206 
208  }
209 
210  // Postconditions:
211 
212  // Exit
213 
214  return;
215 }
216 
217 void
219 reserve(size_type xcapacity)
220 {
221  // Preconditions:
222 
223  // Body:
224 
225  if(xcapacity > capacity())
226  {
227  _to_range.reserve(xcapacity);
228  _to_domain.rehash(xcapacity / 2);
229  }
230 
231  // Postconditions:
232 
233  ensure(invariant());
234  ensure(capacity() >= xcapacity);
235 
236  // Exit:
237 
238  return;
239 }
240 
243 capacity() const
244 {
245  // Preconditions:
246 
247  // Body:
248 
249  size_type result = _to_range.ub();
250 
251  // Postconditions:
252 
253  ensure(is_basic_query);
254 
255  // Exit:
256 
257  return result;
258 }
259 
260 // PROTECTED MEMBER FUNCTIONS
261 
262 void
265 {
266  // cout << endl << "Entering array_index_space_state::update_extrema_after_remove." << endl;
267  // cout << "id space name: " << id_spaces().name(index()) << endl;
268 
269  // Preconditions:
270 
271 
272  // Body:
273 
274  // We've just removed a member, so new bounds must be
275  // within old bounds.
276 
277  if(_ct > 0)
278  {
279  // cout << "The id space is not empty." << endl;
280  // cout << "Find the new begin." << endl;
281 
282  for(pod_index_type i = _begin; i < _end; ++i)
283  {
284  // cout << "i: " << i;
285  if(is_valid(_to_range[i]))
286  {
287  // cout << " is begin." << endl;
288  _begin = i;
289  break;
290  }
291  // cout << endl;
292  }
293 
294  // cout << "Find the new end." << endl;
295 
296  for(pod_index_type i = _end - 1; i >= _begin; --i)
297  {
298  // cout << "i: " << i;
299  if(is_valid(_to_range[i]))
300  {
301  // cout << " is last." << endl;
302  _end = i+1;
303  break;
304  }
305  // cout << endl;
306  }
307 
308  }
309  else
310  {
311  // cout << "The id space is empty." << endl;
312 
313  assertion(is_empty());
314 
316  }
317 
318  // Postconditions:
319 
320  // Exit
321 
322  // cout << "Leaving array_index_space_state::update_extrema_after_remove." << endl;
323  return;
324 }
325 
326 // PRIVATE MEMBER FUNCTIONS
327 
328 
329 // ===========================================================
330 // MAP REPRESENTATION FACET
331 // ===========================================================
332 
333 // PUBLIC MEMBER FUNCTIONS
334 
335 // PROTECTED MEMBER FUNCTIONS
336 
337 void
339 map_rep_insert_entry(pod_type xdomain_id, pod_type xrange_id)
340 {
341  // Preconditions:
342 
343  require(!contains_hub(xrange_id));
344  require(!contains(xdomain_id));
345 
346  // Body:
347 
348  // Assign mapping.
349 
350  _to_domain[xrange_id] = xdomain_id;
351  _to_range.force_item(xdomain_id, xrange_id);
352 
353  // Postconditions:
354 
355  // Not finished inserting entry; do not ensure invariant.
356 
357  ensure(contains(xdomain_id, xrange_id));
358 
359  // Exit
360 
361  return;
362 }
363 
364 void
367 {
368  // Preconditions:
369 
370  require(!contains_hub(xrange_id));
371 
372  // Body:
373 
374  pod_type old_next_id = next_id();
375 
376  _to_domain[xrange_id] = old_next_id;
377  _to_range.force_item(old_next_id, xrange_id);
378 
379  // Postconditions:
380 
381  // Not finished pushing back; do not ensure invariant.
382 
383  ensure(contains(old_next_id, xrange_id));
384 
385  // Exit
386 
387  return;
388 }
389 
390 void
393 {
394  // Preconditions:
395 
396  require(allocated_iterator(xitr));
397  require(!contains_hub(xrange_id));
398 
399  // Body:
400 
401  define_old_variable(pod_type old_itr_pod = xitr.pod());
402  define_old_variable(pod_type old_itr_hub_pod = xitr.hub_pod());
403 
405 
406  not_implemented();
407 
408  // Postconditions:
409 
410  // Not finished inserting entry, do not ensure invariant.
411 
412  ensure(contains(old_itr_pod, xrange_id));
413  ensure(xitr.pod() == old_itr_pod+1);
414  ensure(xitr.hub_pod() == old_itr_hub_pod);
415 
416  // Exit:
417 
418  return;
419 }
420 
423 map_rep_remove_entry(pod_type xid, bool xis_range_id)
424 {
425  // cout << endl << "Entering array_index_space_state::map_rep_remove_entry." << endl;
426  // cout << "id space name: " << id_spaces().name(index()) << endl;
427  // cout << "xid: " << xid << endl;
428  // cout << "xis_range_id: " << xis_range_id << endl;
429  // cout << "domain id: " << (xis_range_id ? pod(xid) : xid) << endl;
430 
431  // Preconditions:
432 
433  // Body:
434 
435  size_type result = 0;
436 
437  if(xis_range_id)
438  {
439  // Xid is a range id.
440  // Check if it is in the map.
441 
442  to_domain_type::iterator itr = _to_domain.find(xid);
443  if(itr != _to_domain.end())
444  {
445  // "Erase" the entry in the _to_range map
446  // by initializing it to invalid.
447 
448  _to_range.initialize(itr->second);
449 
450  // Erase the entry in the _to_domain map.
451 
452  _to_domain.erase(itr);
453 
454  // Removed 1 entry.
455 
456  result = 1;
457  }
458  }
459  else
460  {
461  // Xid is a domain id
462  // Check if it is in the map.
463 
464  if(contains(xid))
465  {
466  // Erase the entry in the _to_domain map.
467 
468  pod_type lrange_id = _to_range[xid];
469  _to_domain.erase(lrange_id);
470 
471  // "Erase" the entry in the _to_range map
472  // by initializing it to invalid.
473 
474  _to_range.initialize(xid);
475 
476  // Removed 1 entry.
477 
478  result = 1;
479  }
480  }
481 
482  // Postconditions:
483 
484  // Not finished removing entry; do not ensure invariant.
485 
486  ensure(xis_range_id ? !contains_hub(xid) : !contains(xid));
487 
488  // Exit
489 
490  // cout << "Leaving array_index_space_state::map_rep_remove_entry." << endl;
491  return result;
492 }
493 
494 void
497 {
498  // Preconditions:
499 
500  require(allocated_iterator(xitr));
501  require(!xitr.is_done());
502  require(contains(xitr.pod()));
503 
504  // Body:
505 
506  define_old_variable(pod_type old_itr_id = xitr.pod());
507  define_old_variable(pod_type old_itr_hub_id = xitr.hub_pod());
508 
510 
511  not_implemented();
512 
513  // Postconditions:
514 
515  ensure(!contains(old_itr_id));
516  ensure(!contains(old_itr_hub_id));
517  ensure(xitr.is_done() || xitr.pod() > old_itr_id);
518 
519  // Exit:
520 
521  return;
522 }
523 
524 void
527 {
528  // Preconditions:
529 
530  // Body:
531 
532  _to_range.clear();
533  _to_domain.clear();
534 
535  // Postconditions:
536 
537  // Not finished clearing; do not ensure invariant.
538  // Map rep is empty, but _ct not reset, so can't ensure is_empty.
539 
540  ensure(unexecutable("map rep is empty"));
541 
542  // Exit:
543 
544  return;
545 }
546 
547 void
550 {
551  // Preconditions:
552 
553  // Body:
554 
555  // Initialize map members.
556 
557  _to_domain.clear();
558  _ct = 0;
559 
560  // Rebuild the to_domain map while gathering the to_range map.
561 
562  pod_type ldomain_id = 0;
563  pod_type lrange_id;
564 
565  for(pod_type i = 0; i < _end; i++)
566  {
567  lrange_id = _to_range[i];
568 
569  if(is_valid(lrange_id) && hub_id_space().contains(lrange_id))
570  {
571  _to_range[ldomain_id] = lrange_id;
572  _to_domain[lrange_id] = ldomain_id;
573 
574  ldomain_id++;
575 
576  // Update the count.
577 
578  _ct++;
579  }
580  }
581 
582  // ldomain_id should now be the same as _ct.
583 
584  assertion(ldomain_id == _ct);
585 
586  // The valid part of the to_range map is now gathered
587  // into the first part of the array. Initialize the
588  // remainder of the array to invalid.
589 
590  _to_range.initialize(ldomain_id, _to_range.ub());
591 
592  // Postconditions:
593 
594  ensure(unexecutable("map rep is gathered"));
595 
596  // Exit:
597 
598  return;
599 }
600 
601 // PRIVATE MEMBER FUNCTIONS
602 
603 
604 // ===========================================================
605 // EXPLICIT_INDEX_SPACE_STATE FACET
606 // ===========================================================
607 
608 // PUBLIC MEMBER FUNCTIONS
609 
610 bool
613 {
614  // Preconditions:
615 
616  require(is_ancestor_of(&xother));
617 
618  // Body:
619 
620  const array_index_space_state& lother =
621  dynamic_cast<const array_index_space_state&>(xother);
622 
624  result = result && (_to_range.ub() == lother._to_range.ub());
625  pod_type lindex(0);
626  while(result && lindex < _to_range.ub())
627  {
628  result = (_to_range[lindex] == lother._to_range[lindex]);
629  ++lindex;
630  }
633  //result = result && (_to_domain == lother._to_domain);
634 
635  // Postconditions:
636 
637  // Exit
638 
639  return result;
640 }
641 
644 deep_size(bool xinclude_shallow) const
645 {
646  // Preconditions:
647 
648  // Body:
649 
650  size_type result = sheaf::deep_size(*this, xinclude_shallow);
651 
652  // Postconditions:
653 
654  ensure(result >= 0);
655 
656  // Exit:
657 
658  return result;
659 }
660 
661 // PROTECTED MEMBER FUNCTIONS
662 
666 {
667  // Preconditions:
668 
669  require(is_ancestor_of(&xother));
670 
671  // Body:
672 
673  const array_index_space_state& lother =
674  dynamic_cast<const array_index_space_state&>(xother);
675 
676  _to_domain = lother._to_domain;
677  _to_range = lother._to_range;
678 
679  (void) scattered_insertion_index_space_state::operator=(xother);
680 
681  // Postconditions:
682 
683  ensure(invariant());
684  ensure((*this) == xother);
685 
686  // Exit
687 
688  return *this;
689 }
690 
691 // PRIVATE MEMBER FUNCTIONS
692 
693 
694 // ===========================================================
695 // INDEX SPACE FACET
696 // ===========================================================
697 
698 // PUBLIC MEMBER FUNCTIONS
699 
700 bool
702 contains(pod_type xid) const
703 {
704  // Preconditions:
705 
706  // Body:
707 
708  bool result =
709  (0 <= xid) && (xid < _to_range.ub()) && is_valid(_to_range[xid]);
710 
711  // Postconditions:
712 
713  ensure(is_basic_query);
714 
715  // Exit
716 
717  return result;
718 }
719 
720 bool
723 {
724  // Preconditions:
725 
726  // Body:
727 
728  bool result = (_to_domain.find(xhub_id) != _to_domain.end());
729 
730  // Postconditions:
731 
732  ensure(is_basic_query);
733 
734  // Exit
735 
736  return result;
737 }
738 
739 bool
741 contains(pod_type xid, pod_type xhub_id) const
742 {
743  // Preconditions:
744 
745  // Body:
746 
747  bool result =
748  is_valid(xid) && (0 <= xid) &&
749  (xid < _to_range.ub()) && (xhub_id == _to_range[xid]);
750 
751  // Postconditions:
752 
753  ensure(is_basic_query);
754 
755  // Exit:
756 
757  return result;
758 }
759 
762 pod(pod_type xhub_id) const
763 {
764  // Preconditions:
765 
766  // Body:
767 
768  to_domain_type::const_iterator itr = _to_domain.find(xhub_id);
769 
770  pod_type result =
771  (itr == _to_domain.end()) ? invalid_pod_index() : itr->second;
772 
773  // Postconditions:
774 
775  ensure(!is_valid(result) || contains(result));
776 
777  // Exit
778 
779  return result;
780 }
781 
785 {
786  // Preconditions:
787 
788  // Body:
789 
790  pod_type result;
791  if((0 <= xid) && (xid < _to_range.ub()))
792  {
793  result = _to_range[xid];
794  }
795  else
796  {
797  result = invalid_pod_index();
798  }
799 
800  // Postconditions:
801 
802  ensure(!is_valid(result) || contains_unglued_hub(result));
803 
804  // Exit:
805 
806  return result;
807 }
808 
809 // PROTECTED MEMBER FUNCTIONS
810 
811 // PRIVATE MEMBER FUNCTIONS
812 
813 
814 // ===========================================================
815 // HANDLE POOL FACET
816 // ===========================================================
817 
818 // PUBLIC MEMBER FUNCTIONS
819 
823 {
824  // Preconditions:
825 
826  // Body:
827 
828  size_type result = handles().ct();
829 
830  // Postconditions:
831 
832  ensure(result >= 0);
833 
834  // Exit:
835 
836  return result;
837 }
838 
842 {
843  // Preconditions:
844 
845  // Body:
846 
847  size_type result = sheaf::deep_size(handles(), true);
848 
849  // Postconditions:
850 
851  ensure(result >= 0);
852 
853  // Exit:
854 
855  return result;
856 }
857 
861 {
862  // Preconditions:
863 
864  // Body:
865 
866  array_index_space_handle& result = handles().get();
867  attach(result);
868 
869  // Postconditions:
870 
871  ensure(result.is_attached());
872 
873  // Exit:
874 
875  return result;
876 }
877 
878 void
881 {
882  // Preconditions:
883 
884  require(allocated_id_space(xid_space));
885 
886  // Body:
887 
888  // Detach the handle.
889 
890  xid_space.detach();
891 
892  // Release the handle to the pool.
893 
894  handles().release(reinterpret_cast<array_index_space_handle&>(xid_space));
895 
896  // Postconditions:
897 
898  ensure(is_basic_query);
899 
900  // Exit:
901 
902  return;
903 }
904 
905 bool
907 allocated_id_space(const index_space_handle& xid_space) const
908 {
909  // Preconditions:
910 
911  // Body:
912 
913  const array_index_space_handle* lid_space =
914  dynamic_cast<const array_index_space_handle*>(&xid_space);
915 
916  bool result = (lid_space != 0) && handles().allocated(*lid_space);
917 
918  // Postconditions:
919 
920  ensure(is_basic_query);
921 
922  // Exit:
923 
924  return result;
925 }
926 
927 // PROTECTED MEMBER FUNCTIONS
928 
929 // PRIVATE MEMBER FUNCTIONS
930 
932 sheaf::array_index_space_state::
933 handles()
934 {
935  // Preconditions:
936 
937  // Body:
938 
940 
941  // Postconditions:
942 
943  ensure(is_basic_query);
944 
945  // Exit:
946 
947  return result;
948 }
949 
950 
951 // ===========================================================
952 // ITERATOR POOL FACET
953 // ===========================================================
954 
955 // PUBLIC MEMBER FUNCTIONS
956 
960 {
961  // Preconditions:
962 
963  // Body:
964 
965  size_type result = iterators().ct();
966 
967  // Postconditions:
968 
969  ensure(result >= 0);
970 
971  // Exit:
972 
973  return result;
974 }
975 
979 {
980  // Preconditions:
981 
982  // Body:
983 
984  size_type result = sheaf::deep_size(iterators(), true);
985 
986  // Postconditions:
987 
988  ensure(result >= 0);
989 
990  // Exit:
991 
992  return result;
993 }
994 
998 {
999  // Preconditions:
1000 
1001  // Body:
1002 
1003  array_index_space_iterator& result = iterators().get();
1004  attach(result);
1005 
1006  // Postconditions:
1007 
1008  ensure(result.is_attached());
1009 
1010  // Exit:
1011 
1012  return result;
1013 }
1014 
1015 void
1018 {
1019  // Preconditions:
1020 
1021  require(allocated_iterator(xitr));
1022 
1023  // Body:
1024 
1025  // Detach the iterator.
1026 
1027  xitr.detach();
1028 
1029  // Release the iterator to the pool.
1030 
1031  iterators().release(reinterpret_cast<array_index_space_iterator&>(xitr));
1032 
1033  // Postconditions:
1034 
1035  ensure(is_basic_query);
1036 
1037  // Exit:
1038 
1039  return;
1040 }
1041 
1042 bool
1045 {
1046  // Preconditions:
1047 
1048  // Body:
1049 
1050  const array_index_space_iterator* litr =
1051  dynamic_cast<const array_index_space_iterator*>(&xitr);
1052 
1053  bool result = (litr != 0) && iterators().allocated(*litr);
1054 
1055  // Postconditions:
1056 
1057  ensure(is_basic_query);
1058 
1059  // Exit:
1060 
1061  return result;
1062 }
1063 
1064 // PROTECTED MEMBER FUNCTIONS
1065 
1066 // PRIVATE MEMBER FUNCTIONS
1067 
1069 sheaf::array_index_space_state::
1070 iterators()
1071 {
1072  // Preconditions:
1073 
1074  // Body:
1075 
1077 
1078  // Postconditions:
1079 
1080  ensure(is_basic_query);
1081 
1082  // Exit:
1083 
1084  return result;
1085 }
1086 
1087 
1088 // ===========================================================
1089 // FACTORY FACET
1090 // ===========================================================
1091 
1092 // PUBLIC MEMBER FUNCTIONS
1093 
1094 const std::string&
1096 class_name() const
1097 {
1098  static const std::string result("array_index_space_state");
1099  return result;
1100 }
1101 
1104 clone() const
1105 {
1106  // Preconditions:
1107 
1108  // Body:
1109 
1111 
1112  // Postconditions:
1113 
1114  ensure(result != 0);
1115  ensure(is_same_type(result));
1116 
1117  // Exit:
1118 
1119  return result;
1120 }
1121 
1122 // PROTECTED MEMBER FUNCTIONS
1123 
1124 // PRIVATE MEMBER FUNCTIONS
1125 
1126 bool
1127 sheaf::array_index_space_state::
1128 make_prototype()
1129 {
1130  // Preconditions:
1131 
1132  // Body:
1133 
1135 
1136  id_space_factory().insert_prototype(lproto);
1137 
1138  // Postconditions:
1139 
1140  // Exit:
1141 
1142  return true;
1143 }
1144 
1145 
1146 // ===========================================================
1147 // ANY FACET
1148 // ===========================================================
1149 
1150 // PUBLIC MEMBER FUNCTIONS
1151 
1152 bool
1154 is_ancestor_of(const any *other) const
1155 {
1156  // Preconditions:
1157 
1158  require(other != 0);
1159 
1160  // Body:
1161 
1162  // True if other conforms to this
1163 
1164  bool result = dynamic_cast<const array_index_space_state*>(other) != 0;
1165 
1166  // Postconditions:
1167 
1168  // Exit:
1169 
1170  return result;
1171 }
1172 
1173 bool
1175 invariant() const
1176 {
1177  bool result = true;
1178 
1179  if(invariant_check())
1180  {
1181  // Prevent recursive calls to invariant
1182 
1184 
1185  // Must satisfy base class invariant
1186 
1188 
1189  // Invariances for this class:
1190 
1191  // Finished, turn invariant checking back on.
1192 
1194  }
1195 
1196  // Exit
1197 
1198  return result;
1199 }
1200 
1201 // PROTECTED MEMBER FUNCTIONS
1202 
1203 // PRIVATE MEMBER FUNCTIONS
1204 
1205 
1206 // ===========================================================
1207 // NON-MEMBER FUNCTIONS
1208 // ===========================================================
1209 
1210 size_t
1211 sheaf::
1212 deep_size(const array_index_space_state& xn, bool xinclude_shallow)
1213 {
1214  // Preconditions:
1215 
1216  // Body:
1217 
1218  size_t result = xinclude_shallow ? sizeof(xn) : 0;
1219 
1220  // Add any contributions from the parent class.
1221 
1223  result += deep_size(ixn, false);
1224 
1225  // Add contribution from unordered_map<pod_type, pod_type> to_domain_type.
1226 
1228  typedef no_deep_size_policy<unordered_map<pod_type, pod_type> > to_domain_policy_type;
1229  result += deep_size<pod_type, pod_type, to_domain_policy_type>(xn._to_domain, false);
1230 
1231  // Add contribution from auto_block _to_range.
1232 
1233  result += deep_size(xn._to_range, false);
1234 
1235  // Postconditions:
1236 
1237  ensure(result >= 0);
1238 
1239  // Exit
1240 
1241  return result;
1242 }
virtual void reserve(size_type xcapacity)
Reserve enough memory for xcapacity number of ids.
static size_type handle_pool_deep_size()
The deep size of the handle pool.
bool contains_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space. synonym for contains...
virtual array_index_space_state & operator=(const explicit_index_space_state &xother)
Assignment operator.
virtual void map_rep_gather()
Gathers the map representation into an interval.
index_type ub() const
The upper bound on the storage array. The number of items current allocated in the storage array...
virtual pod_type index() const
Index of this space.
An abstract iterator over the ids of an id space.
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
virtual bool allocated_id_space(const index_space_handle &xid_space) const
True if and only if id space handle xid_space was allocated by the handle pool.
virtual pod_type unglued_hub_pod(pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in this id space.
pod_type pod() const
The current id in the iteration.
virtual bool invariant() const
Class invariant.
virtual size_type map_rep_remove_entry(pod_type xid, bool xis_range_id)
Removes the entry containing range id xid (xis_range_id true) or domain id xid (xis_range_id false) f...
virtual bool is_persistent() const
True if this id space should be written to disk.
virtual bool conforms_to_state(const index_space_collection &xhost, pod_type xlocal_id) const
True if this conforms to the handle type required by the state with local scope id xlocal_id in the h...
virtual void map_rep_push_back(pod_type xrange_id)
Inserts entry (next_id(), xrange_id) into the map representation.
void force_item(index_type xindex, const_reference_type xitem)
Puts the item xitem at index xindex, resizing if necessary; any other new storage allocated is uninit...
STL namespace.
void reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
virtual void detach()=0
Detach this handle form its state, if any.
An implementation of class explicit_index_space_state that supports either gathered or scattered inse...
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
virtual const index_space_family & id_spaces() const
The id space family for this (const version).
virtual ~array_index_space_state()
Destructor.
void initialize(index_type xindex)
Invokes the initialization policy on the item at xindex.
An array implementation of class scattered_insertion_index_space_state. This representation is intend...
virtual size_type capacity() const
The number of ids reserved in memory.
static size_type handle_pool_ct()
The number of handles in the pool.
virtual void detach()=0
Detach this handle form its state, if any.
void attach(explicit_index_space_handle &xid_space) const
Attach the id space handle xid_space to this state.
pod_type _end
Ending id of this space.
to_range_type _to_range
The representation of the domain id to range id map.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual void map_rep_clear()
Removes all entrires from the map representation.
bool is_done() const
True if iteration is finished.
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual void map_rep_push(index_space_iterator &xitr, pod_type xrange_id)
Inserts entry (xitr.pod(), xrange_id) into the map representation. Increments all domain ids greater ...
std::string name() const
Name of this space.
Do not call deep_size on either the key or value.
Definition: deep_size.h:54
virtual bool allocated_iterator(const index_space_iterator &xitr) const
True if and only if id space iterator xitr was allocated by the iterator pool.
virtual bool is_attached() const
True if this handle is attached to a state.
void invalidate_extrema()
Invalidate the extrema.
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.
An array implementation of class scattered_insertion_index_space_handle. This representation is inten...
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
virtual void map_rep_insert_entry(pod_type xdomain_id, pod_type xrange_id)
Inserts entry (xdomain_id, xrange_id) into the map representation.
const hub_index_space_handle & hub_id_space() const
The hub id space.
bool is_explicit_interval(pod_type xid)
True, if and only if the id space interval that contains index xid is an explicit interval...
virtual bool contains_unglued_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space.
static size_type iterator_pool_ct()
The number of iterators in the pool.
virtual void update_extrema_after_remove()
Update the id extrema after a remove operation.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
void new_state(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent)
Create a new id space state in the id space family xid_spaces at the next available id space index wi...
virtual void release_id_space(index_space_handle &xid_space) const
Release the id space handle xid_space.
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
size_type capacity() const
The number of ids reserved in memory.
virtual void update_extrema()
Update the id extrema.
size_type _ct
The number of members.
virtual bool contains(pod_type xid) const
True if this space contains id xid.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
An iterator over an id space in which the equivalence between the ids in the space and the hub id spa...
pod_index_type pod_type
The "plain old data" index type for this.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual index_space_handle & get_id_space() const
The id space handle with this state.
virtual const std::string & class_name() const
The name of this class.
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
static array_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, size_type xcapacity)
Create a new array id space in the id space family xid_spaces at the next available id space index wi...
array_index_space_state()
Default constructor.
friend SHEAF_DLL_SPEC size_t deep_size(const array_index_space_state &xn, bool xinclude_shallow)
The deep size of array_index_space_state& xn.
bool is_empty() const
True if there are no ids in the space.
Factory and container for a family of id spaces.
void clear()
Remove all items.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
static factory< explicit_index_space_state > & id_space_factory()
A factory for making descendants of this class.
pod_type _begin
Beginning id of this space.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
Definition: pod_types.cc:31
pod_type next_id() const
The id inserted by the next call to push_back.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
virtual bool is_attached() const
True if this iterator is attached to a state.
A reallocated pool of objects of type T. Objects in the pool are either allocated or stored in a free...
Definition: list_pool.h:42
static size_type iterator_pool_deep_size()
The deep size of the iterator pool.
to_domain_type _to_domain
The representation of the range id to domain id map.
virtual array_index_space_state * clone() const
Virtual constructor; create a new instance of the same type at this.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().