SheafSystem  0.0.0.0
hash_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/hash_index_space_state.h"
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/hash_index_space_handle.h"
24 #include "SheafSystem/hash_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  hash_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 
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  hash_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 // HASH_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  _begin = max_pod_index();
186  _end = min_pod_index();
187 
188  for(to_range_type::const_iterator itr = _to_range.begin();
189  itr != _to_range.end();
190  ++itr)
191  {
192  update_extrema(itr->first);
193  }
194 
195  // Postconditions:
196 
197  // Exit
198 
199  return;
200 }
201 
202 void
204 reserve(size_type xcapacity)
205 {
206  // Preconditions:
207 
208  // Body:
209 
210  if(xcapacity > capacity())
211  {
212  size_type lbucket_ct = (xcapacity / 2) + (xcapacity % 2);
213 
214  _to_domain.rehash(lbucket_ct);
215  _to_range.rehash(lbucket_ct);
216  }
217 
218  // Postconditions:
219 
220  ensure(invariant());
221  ensure(capacity() >= xcapacity);
222 
223  // Exit:
224 
225  return;
226 }
227 
230 capacity() const
231 {
232  // Preconditions:
233 
234  // Body:
235 
236  size_type result = (2 * _to_range.bucket_count());
237 
238  // Postconditions:
239 
240  ensure(is_basic_query);
241 
242  // Exit:
243 
244  return result;
245 }
246 
247 // PROTECTED MEMBER FUNCTIONS
248 
249 // PRIVATE MEMBER FUNCTIONS
250 
251 
252 // ===========================================================
253 // MAP REPRESENTATION FACET
254 // ===========================================================
255 
256 // PUBLIC MEMBER FUNCTIONS
257 
258 // PROTECTED MEMBER FUNCTIONS
259 
260 void
262 map_rep_insert_entry(pod_type xdomain_id, pod_type xrange_id)
263 {
264  // Preconditions:
265 
266  require(!contains_hub(xrange_id));
267  require(!contains(xdomain_id));
268 
269  // Body:
270 
271  // Assign mapping.
272 
273  _to_range[xdomain_id] = xrange_id;
274  _to_domain[xrange_id] = xdomain_id;
275 
276  // Postconditions:
277 
278  // Not finished inserting entry; do not ensure invariant.
279 
280  ensure(contains(xdomain_id, xrange_id));
281 
282  // Exit
283 
284  return;
285 }
286 
287 void
290 {
291  // Preconditions:
292 
293  require(!contains_hub(xrange_id));
294 
295  // Body:
296 
297  pod_type old_next_id = next_id();
298 
299  _to_domain[xrange_id] = old_next_id;
300  _to_range[old_next_id] = xrange_id;
301 
302  // Postconditions:
303 
304  // Not finished pushing back; do not ensure invariant.
305 
306  ensure(contains(old_next_id, xrange_id));
307 
308  // Exit
309 
310  return;
311 }
312 
313 void
316 {
317  // Preconditions:
318 
319  require(allocated_iterator(xitr));
320  require(!contains_hub(xrange_id));
321 
322  // Body:
323 
324  define_old_variable(pod_type old_itr_pod = xitr.pod());
325  define_old_variable(pod_type old_itr_hub_pod = xitr.hub_pod());
326 
328 
329  not_implemented();
330 
331  // Postconditions:
332 
333  // Not finished inserting entry, do not ensure invariant.
334 
335  ensure(contains(old_itr_pod, xrange_id));
336  ensure(xitr.pod() == old_itr_pod+1);
337  ensure(xitr.hub_pod() == old_itr_hub_pod);
338 
339  // Exit:
340 
341  return;
342 }
343 
346 map_rep_remove_entry(pod_type xid, bool xis_range_id)
347 {
348  // Preconditions:
349 
350  // Body:
351 
352  size_type result = 0;
353 
354  if(xis_range_id)
355  {
356  // Find the domain id for xid, if there is one.
357 
358  to_domain_type::iterator itr = _to_domain.find(xid);
359  if(itr != _to_domain.end())
360  {
361  // Erase the entry in the _to_range map.
362 
363  _to_range.erase(itr->second);
364 
365  // Erase the entry in the _to_domain map.
366 
367  _to_domain.erase(itr);
368 
369  // Removed 1 entry.
370 
371  result = 1;
372  }
373  }
374  else
375  {
376  // Find the range id for xid, if there is one.
377 
378  to_range_type::iterator itr = _to_range.find(xid);
379  if(itr != _to_range.end())
380  {
381  // Erase the entry in the _to_domain map.
382 
383  _to_domain.erase(itr->second);
384 
385  // Erase the entry in the _to_range map.
386 
387  _to_range.erase(itr);
388 
389  // Removed 1 entry.
390 
391  result = 1;
392  }
393  }
394 
395  // Postconditions:
396 
397  // Not finished removing entry; do not ensure invariant.
398 
399  ensure(xis_range_id ? !contains_hub(xid) : !contains(xid));
400 
401  // Exit
402 
403  return result;
404 }
405 
406 void
409 {
410  // Preconditions:
411 
412  require(allocated_iterator(xitr));
413  require(!xitr.is_done());
414  require(contains(xitr.pod()));
415 
416  // Body:
417 
418  define_old_variable(pod_type old_itr_id = xitr.pod());
419  define_old_variable(pod_type old_itr_hub_id = xitr.hub_pod());
420 
422 
423  not_implemented();
424 
425  // Postconditions:
426 
427  ensure(!contains(old_itr_id));
428  ensure(!contains(old_itr_hub_id));
429  ensure(xitr.is_done() || xitr.pod() > old_itr_id);
430 
431  // Exit:
432 
433  return;
434 }
435 
436 void
439 {
440  // Preconditions:
441 
442  // Body:
443 
444  _to_range.clear();
445  _to_domain.clear();
446 
447  // Postconditions:
448 
449  // Not finished clearing; do not ensure invariant.
450  // Map rep is empty, but _ct not reset, so can't ensure is_empty.
451 
452  ensure(unexecutable("map rep is empty"));
453 
454  // Exit:
455 
456  return;
457 }
458 
459 void
462 {
463  // Preconditions:
464 
465  // Body:
466 
467  // Build the gathered _to_domain map.
468 
469  _to_domain.clear();
470  _ct = 0;
471 
472  pod_type ldomain_id = 0;
473  pod_type lrange_id;
474 
475  to_range_type::iterator lto_range_itr = _to_range.begin();
476  while(lto_range_itr != _to_range.end())
477  {
478  lrange_id = lto_range_itr->second;
479 
480  if(hub_id_space().contains(lrange_id))
481  {
482  // The range id has not been delete.
483  // Add it to the map.
484 
485  _to_domain[lrange_id] = ldomain_id;
486 
487  // Increment the domain id.
488 
489  ++ldomain_id;
490 
491  // Increment the id space count.
492 
493  ++_ct;
494  }
495 
496  // Increment to the next entry in the _to_range map.
497 
498  ++lto_range_itr;
499  }
500 
501  // Build the gathered _to_range map.
502 
503  _to_range.clear();
504 
505  to_domain_type::iterator lto_domain_itr = _to_domain.begin();
506  while(lto_domain_itr != _to_domain.end())
507  {
508  // Insert the entry into the map.
509 
510  _to_range[lto_domain_itr->second] = lto_domain_itr->first;
511 
512  // Increment the iterator.
513 
514  ++lto_domain_itr;
515  }
516 
517  // Postconditions:
518 
519  ensure(unexecutable("map rep is gathered"));
520 
521  // Exit:
522 
523  return;
524 }
525 
526 // PRIVATE MEMBER FUNCTIONS
527 
528 
529 // ===========================================================
530 // EXPLICIT_INDEX_SPACE_STATE FACET
531 // ===========================================================
532 
533 // PUBLIC MEMBER FUNCTIONS
534 
535 bool
538 {
539  // Preconditions:
540 
541  require(is_ancestor_of(&xother));
542 
543  // Body:
544 
545  const hash_index_space_state& lother =
546  dynamic_cast<const hash_index_space_state&>(xother);
547 
551 // result = result && (_to_range == lother._to_range);
552 // result = result && (_to_domain == lother._to_domain);
553 
554  // Postconditions:
555 
556  // Exit
557 
558  return result;
559 }
560 
563 deep_size(bool xinclude_shallow) const
564 {
565  // Preconditions:
566 
567  // Body:
568 
569  size_type result = sheaf::deep_size(*this, xinclude_shallow);
570 
571  // Postconditions:
572 
573  ensure(result >= 0);
574 
575  // Exit:
576 
577  return result;
578 }
579 
580 // PROTECTED MEMBER FUNCTIONS
581 
585 {
586  // Preconditions:
587 
588  require(is_ancestor_of(&xother));
589 
590  // Body:
591 
592  const hash_index_space_state& lother =
593  dynamic_cast<const hash_index_space_state&>(xother);
594 
595  _to_domain = lother._to_domain;
596  _to_range = lother._to_range;
597 
598  (void) scattered_insertion_index_space_state::operator=(xother);
599 
600  // Postconditions:
601 
602  ensure(invariant());
603  ensure((*this) == xother);
604 
605  // Exit
606 
607  return *this;
608 }
609 
610 // PRIVATE MEMBER FUNCTIONS
611 
612 
613 // ===========================================================
614 // INDEX SPACE FACET
615 // ===========================================================
616 
617 // PUBLIC MEMBER FUNCTIONS
618 
619 bool
621 contains(pod_type xid) const
622 {
623  // Preconditions:
624 
625  // Body:
626 
627  bool result = (_to_range.find(xid) != _to_range.end());
628 
629  // Postconditions:
630 
631  ensure(is_basic_query);
632 
633  // Exit
634 
635  return result;
636 }
637 
638 bool
641 {
642  // Preconditions:
643 
644  // Body:
645 
646  bool result = (_to_domain.find(xhub_id) != _to_domain.end());
647 
648  // Postconditions:
649 
650  ensure(is_basic_query);
651 
652  // Exit
653 
654  return result;
655 }
656 
657 bool
659 contains(pod_type xid, pod_type xhub_id) const
660 {
661  // Preconditions:
662 
663  // Body:
664 
665  to_range_type::const_iterator itr = _to_range.find(xid);
666 
667  bool result = (itr != _to_range.end()) && (itr->second == xhub_id);
668 
669  // Postconditions:
670 
671  ensure(is_basic_query);
672 
673  // Exit:
674 
675  return result;
676 }
677 
680 pod(pod_type xhub_id) const
681 {
682  // Preconditions:
683 
684  // Body:
685 
686  to_domain_type::const_iterator itr = _to_domain.find(xhub_id);
687 
688  pod_type result =
689  (itr == _to_domain.end()) ? invalid_pod_index() : itr->second;
690 
691  // Postconditions:
692 
693  ensure(!is_valid(result) || contains(result));
694 
695  // Exit
696 
697  return result;
698 }
699 
703 {
704  // Preconditions:
705 
706  // Body:
707 
708  to_range_type::const_iterator itr = _to_range.find(xid);
709 
710  pod_type result =
711  (itr == _to_range.end()) ? invalid_pod_index() : itr->second;
712 
713  // Postconditions:
714 
715  ensure(!is_valid(result) || contains_unglued_hub(result));
716 
717  // Exit:
718 
719  return result;
720 }
721 
722 // PROTECTED MEMBER FUNCTIONS
723 
724 // PRIVATE MEMBER FUNCTIONS
725 
726 
727 // ===========================================================
728 // HANDLE POOL FACET
729 // ===========================================================
730 
731 // PUBLIC MEMBER FUNCTIONS
732 
736 {
737  // Preconditions:
738 
739  // Body:
740 
741  size_type result = handles().ct();
742 
743  // Postconditions:
744 
745  ensure(result >= 0);
746 
747  // Exit:
748 
749  return result;
750 }
751 
755 {
756  // Preconditions:
757 
758  // Body:
759 
760  size_type result = sheaf::deep_size(handles(), true);
761 
762  // Postconditions:
763 
764  ensure(result >= 0);
765 
766  // Exit:
767 
768  return result;
769 }
770 
774 {
775  // Preconditions:
776 
777  // Body:
778 
779  hash_index_space_handle& result = handles().get();
780  attach(result);
781 
782  // Postconditions:
783 
784  ensure(result.is_attached());
785 
786  // Exit:
787 
788  return result;
789 }
790 
791 void
794 {
795  // Preconditions:
796 
797  require(allocated_id_space(xid_space));
798 
799  // Body:
800 
801  // Detach the handle.
802 
803  xid_space.detach();
804 
805  // Release the handle to the pool.
806 
807  handles().release(reinterpret_cast<hash_index_space_handle&>(xid_space));
808 
809  // Postconditions:
810 
811  ensure(is_basic_query);
812 
813  // Exit:
814 
815  return;
816 }
817 
818 bool
820 allocated_id_space(const index_space_handle& xid_space) const
821 {
822  // Preconditions:
823 
824  // Body:
825 
826  const hash_index_space_handle* lid_space =
827  dynamic_cast<const hash_index_space_handle*>(&xid_space);
828 
829  bool result = (lid_space != 0) && handles().allocated(*lid_space);
830 
831  // Postconditions:
832 
833  ensure(is_basic_query);
834 
835  // Exit:
836 
837  return result;
838 }
839 
840 // PROTECTED MEMBER FUNCTIONS
841 
842 // PRIVATE MEMBER FUNCTIONS
843 
845 sheaf::hash_index_space_state::
846 handles()
847 {
848  // Preconditions:
849 
850  // Body:
851 
853 
854  // Postconditions:
855 
856  ensure(is_basic_query);
857 
858  // Exit:
859 
860  return result;
861 }
862 
863 
864 // ===========================================================
865 // ITERATOR POOL FACET
866 // ===========================================================
867 
868 // PUBLIC MEMBER FUNCTIONS
869 
873 {
874  // Preconditions:
875 
876  // Body:
877 
878  size_type result = iterators().ct();
879 
880  // Postconditions:
881 
882  ensure(result >= 0);
883 
884  // Exit:
885 
886  return result;
887 }
888 
892 {
893  // Preconditions:
894 
895  // Body:
896 
897  size_type result = sheaf::deep_size(iterators(), true);
898 
899  // Postconditions:
900 
901  ensure(result >= 0);
902 
903  // Exit:
904 
905  return result;
906 }
907 
911 {
912  // Preconditions:
913 
914  // Body:
915 
916  hash_index_space_iterator& result = iterators().get();
917  attach(result);
918 
919  // Postconditions:
920 
921  ensure(result.is_attached());
922 
923  // Exit:
924 
925  return result;
926 }
927 
928 void
931 {
932  // Preconditions:
933 
934  require(allocated_iterator(xitr));
935 
936  // Body:
937 
938  // Detach the iterator.
939 
940  xitr.detach();
941 
942  // Release the iterator to the pool.
943 
944  iterators().release(reinterpret_cast<hash_index_space_iterator&>(xitr));
945 
946  // Postconditions:
947 
948  ensure(is_basic_query);
949 
950  // Exit:
951 
952  return;
953 }
954 
955 bool
958 {
959  // Preconditions:
960 
961  // Body:
962 
963  const hash_index_space_iterator* litr =
964  dynamic_cast<const hash_index_space_iterator*>(&xitr);
965 
966  bool result = (litr != 0) && iterators().allocated(*litr);
967 
968  // Postconditions:
969 
970  ensure(is_basic_query);
971 
972  // Exit:
973 
974  return result;
975 }
976 
977 // PROTECTED MEMBER FUNCTIONS
978 
979 // PRIVATE MEMBER FUNCTIONS
980 
982 sheaf::hash_index_space_state::
983 iterators()
984 {
985  // Preconditions:
986 
987  // Body:
988 
990 
991  // Postconditions:
992 
993  ensure(is_basic_query);
994 
995  // Exit:
996 
997  return result;
998 }
999 
1000 
1001 // ===========================================================
1002 // FACTORY FACET
1003 // ===========================================================
1004 
1005 // PUBLIC MEMBER FUNCTIONS
1006 
1007 const std::string&
1009 class_name() const
1010 {
1011  static const std::string result("hash_index_space_state");
1012  return result;
1013 }
1014 
1017 clone() const
1018 {
1019  // Preconditions:
1020 
1021  // Body:
1022 
1024 
1025  // Postconditions:
1026 
1027  ensure(result != 0);
1028  ensure(is_same_type(result));
1029 
1030  // Exit:
1031 
1032  return result;
1033 }
1034 
1035 // PROTECTED MEMBER FUNCTIONS
1036 
1037 // PRIVATE MEMBER FUNCTIONS
1038 
1039 bool
1040 sheaf::hash_index_space_state::
1041 make_prototype()
1042 {
1043  // Preconditions:
1044 
1045  // Body:
1046 
1048 
1049  id_space_factory().insert_prototype(lproto);
1050 
1051  // Postconditions:
1052 
1053  // Exit:
1054 
1055  return true;
1056 }
1057 
1058 
1059 // ===========================================================
1060 // ANY FACET
1061 // ===========================================================
1062 
1063 // PUBLIC MEMBER FUNCTIONS
1064 
1065 bool
1067 is_ancestor_of(const any *other) const
1068 {
1069  // Preconditions:
1070 
1071  require(other != 0);
1072 
1073  // Body:
1074 
1075  // True if other conforms to this
1076 
1077  bool result = dynamic_cast<const hash_index_space_state*>(other) != 0;
1078 
1079  // Postconditions:
1080 
1081  // Exit:
1082 
1083  return result;
1084 }
1085 
1086 bool
1088 invariant() const
1089 {
1090  bool result = true;
1091 
1092  if(invariant_check())
1093  {
1094  // Prevent recursive calls to invariant
1095 
1097 
1098  // Must satisfy base class invariant
1099 
1101 
1102  // Invariances for this class:
1103 
1104  // Finished, turn invariant checking back on.
1105 
1107  }
1108 
1109  // Exit
1110 
1111  return result;
1112 }
1113 
1114 // PROTECTED MEMBER FUNCTIONS
1115 
1116 // PRIVATE MEMBER FUNCTIONS
1117 
1118 
1119 // ===========================================================
1120 // NON-MEMBER FUNCTIONS
1121 // ===========================================================
1122 
1123 size_t
1124 sheaf::
1125 deep_size(const hash_index_space_state& xn, bool xinclude_shallow)
1126 {
1127  // Preconditions:
1128 
1129  // Body:
1130 
1131  size_t result = xinclude_shallow ? sizeof(xn) : 0;
1132 
1133  // Add any contributions from the parent class.
1134 
1136  result += deep_size(ixn, false);
1137 
1138  // Add contribution from unordered_map<pod_type, pod_type> to_domain.
1139 
1141  typedef no_deep_size_policy<unordered_map<pod_type, pod_type> > to_domain_policy_type;
1142  result += deep_size<pod_type, pod_type, to_domain_policy_type>(xn._to_domain, false);
1143 
1144  // Add contribution from unordered_map<pod_type, pod_type> _to_range.
1145 
1146  typedef no_deep_size_policy<unordered_map<pod_type, pod_type> > to_range_policy_type;
1147  result += deep_size<pod_type, pod_type, to_range_policy_type>(xn._to_range, false);
1148 
1149  // Postconditions:
1150 
1151  ensure(result >= 0);
1152 
1153  // Exit
1154 
1155  return result;
1156 }
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 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 operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
virtual pod_type index() const
Index of this space.
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
An abstract iterator over the ids of an id space.
virtual void map_rep_gather()
Gathers the map representation into an interval.
pod_type pod() const
The current id in the iteration.
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
An hash map implementation of class scattered_insertion_index_space_handle. This representation is in...
virtual bool is_persistent() const
True if this id space should be written to disk.
virtual void map_rep_push_back(pod_type xrange_id)
Inserts entry (next_id(), xrange_id) into the map representation.
STL namespace.
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 void detach()=0
Detach this handle form its state, if any.
static size_type iterator_pool_deep_size()
The deep size of the iterator pool.
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.
static size_type handle_pool_deep_size()
The deep size of the handle pool.
virtual void map_rep_insert_entry(pod_type xdomain_id, pod_type xrange_id)
Inserts entry (xdomain_id, xrange_id) into the map representation.
Abstract base class with useful features for all objects.
Definition: any.h:39
bool is_done() const
True if iteration is finished.
static size_type iterator_pool_ct()
The number of iterators in the 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 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 ...
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
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.
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 is_attached() const
True if this handle is attached to a state.
SHEAF_DLL_SPEC pod_index_type max_pod_index()
The maximum pod index value.
Definition: pod_types.cc:43
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.
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
hash_index_space_state()
Default constructor.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
const hub_index_space_handle & hub_id_space() const
The hub id space.
static size_type handle_pool_ct()
The number of handles in the pool.
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 void reserve(size_type xcapacity)
Reserve enough memory for xcapacity number of ids.
to_domain_type _to_domain
The representation of the range id to domain id map.
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 bool contains(pod_type xid) const
True if this space contains id xid.
virtual void update_extrema()
Update the id extrema.
virtual index_space_handle & get_id_space() const
The id space handle with this state.
virtual hash_index_space_state & operator=(const explicit_index_space_state &xother)
Assignment operator.
An hash map implementation of class scattered_insertion_index_space_state. This representation is int...
SHEAF_DLL_SPEC pod_index_type min_pod_index()
The minimum pod index value.
Definition: pod_types.cc:49
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.
size_type _ct
The number of members.
virtual const std::string & class_name() const
The name of this class.
virtual hash_index_space_state * clone() const
Virtual constructor; create a new instance of the same type at this.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
to_range_type _to_range
The representation of the domain id to range id map.
pod_index_type pod_type
The "plain old data" index type for this.
virtual size_type capacity() const
The number of ids reserved in memory.
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.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual pod_type unglued_hub_pod(pod_type xid) const
The pod index in the hub id space equivalent to xid in this id space.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
virtual void map_rep_clear()
Removes all entrires from the map representation.
An iterator over an id space in which the equivalence between the ids in the space and the hub id spa...
bool is_empty() const
True if there are no ids in the space.
Factory and container for a family of id spaces.
virtual ~hash_index_space_state()
Destructor.
virtual void release_id_space(index_space_handle &xid_space) const
Release the id space handle xid_space.
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_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
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
virtual bool contains(pod_type xid) const
True if this space contains id xid.
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...
static hash_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, size_type xcapacity)
Create a new hash id space in the id space family xid_space at the next available id space index with...
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
friend SHEAF_DLL_SPEC size_t deep_size(const hash_index_space_state &xn, bool xinclude_shallow)
The deep size of hash_index_space_state& xn.