21 #ifndef DEPTH_FIRST_ITR_IMPL_H 22 #define DEPTH_FIRST_ITR_IMPL_H 24 #ifndef SHEAF_DLL_SPEC_H 25 #include "SheafSystem/sheaf_dll_spec.h" 29 #ifndef ASSERT_CONTRACT_H 30 #include "SheafSystem/assert_contract.h" 33 #ifndef DEPTH_FIRST_ITR_H 34 #include "SheafSystem/depth_first_itr.h" 37 #ifndef INDEX_SPACE_ITERATOR_H 38 #include "SheafSystem/index_space_iterator.h" 62 release_cover_id_space_iterators();
68 _anchor->detach_from_state();
74 _client_filter.detach_from_state();
110 _action = NOT_AN_ACTION;
112 _client_filter.detach_from_state();
116 initialize_order(NOT_AN_ORDER);
117 _state = NOT_A_STATE;
127 ensure(order() == NOT_AN_ORDER);
128 ensure(!is_initialized());
129 ensure(descending());
131 ensure(visit_once());
139 template <
typename T>
151 _action = NOT_AN_ACTION;
153 _client_filter.detach_from_state();
157 initialize_order(NOT_AN_ORDER);
158 _state = NOT_A_STATE;
188 ensure(order() == xother.
order());
190 ensure(is_initialized() ? anchor().is_same_state(&xother.
anchor()) :
true);
191 ensure(is_initialized() ? anchor().version() == xother.
anchor().
version() :
true);
192 ensure(is_initialized() ? filter().is_same_state(&(const_cast<depth_first_itr&>(xother).filter())) :
true);
193 ensure(is_initialized() ? descending() == xother.
descending() :
true);
194 ensure(is_initialized() ? strict() == xother.
strict() :
true);
196 ensure(unexecutable(
this is first member of iteration or is_done()));
203 template <
typename T>
232 _anchor->detach_from_state();
239 _client_filter.detach_from_state();
250 initialize_order(NOT_AN_ORDER);
264 assertion(!is_initialized());
265 assertion(is_done());
271 initialize_order(lother.
_order);
275 initialize_traversal(lother.
anchor());
276 if(lother.
filter().index() !=~ lother.anchor().version_index())
278 initialize_filter(lother.
filter().index());
289 ensure(order() == xother.
order());
291 ensure(is_initialized() ? anchor().is_same_state(&xother.
anchor()) :
true);
292 ensure(is_initialized() ? anchor().version() == xother.
anchor().
version() :
true);
293 ensure(is_initialized() ? filter().is_same_state(&(const_cast<depth_first_itr&>(xother).filter())) :
true);
294 ensure(is_initialized() ? descending() == xother.
descending() :
true);
295 ensure(is_initialized() ? strict() == xother.
strict() :
true);
304 template <
typename T>
311 require(is_initialized());
312 require(_path_tail.empty());
316 disable_invariant_check();
321 _index = _anchor->index();
325 put_has_visited(_index,
true);
330 _state = _transition_fcn[FIRST][PASS];
334 enable_invariant_check();
345 template <
typename T>
353 require(is_initialized());
354 require(anchor().state_is_read_write_accessible());
357 require(anchor().host()->contains_member(xmbr));
361 put_has_visited(xmbr->
index(),
true);
365 ensure(has_visited(xmbr));
368 template <
typename T>
375 require(is_initialized());
378 require(anchor().state_is_read_accessible());
379 require(anchor().host()->contains_member(xmbr));
383 put_has_visited(xmbr->
index(),
false);
387 ensure(!has_visited(xmbr));
390 template <
typename T>
408 template <
typename T>
426 template <
typename T>
440 _transition_fcn = PREORDER_TRANSITION_FCN;
443 _transition_fcn = POSTORDER_TRANSITION_FCN;
446 _transition_fcn = LINKORDER_TRANSITION_FCN;
449 _transition_fcn = BIORDER_TRANSITION_FCN;
452 _transition_fcn = TRIORDER_TRANSITION_FCN;
461 ensure(order() == xorder);
468 template <
typename T>
475 require(anchor_is_ancestor_of(xanchor));
481 define_old_variable(
bool old_descending = _descending);
482 define_old_variable(
bool old_strict = _strict);
487 initialize_anchor(xanchor);
491 initialize_has_visited(xanchor);
495 initialize_filter(_anchor->version_index());
497 #ifdef DIAGNOSTIC_OUTPUT 499 cout <<
"in depth_first_itr<T>::initialize_traversal(xanchor): " << endl
500 <<
"_anchor = " << *_anchor << endl
501 <<
"_filter = " << _filter << endl;
507 ensure(is_initialized());
509 ensure(anchor().is_same_state(&xanchor));
510 ensure(anchor().is_same_type(&xanchor));
511 ensure(anchor().version() == xanchor.
version());
512 ensure(filter().index() == anchor().version_index());
513 ensure(descending() == old_descending);
514 ensure(strict() == old_strict);
521 template <
typename T>
528 require(is_initialized());
529 require(anchor().state_is_read_accessible());
530 require(anchor().host()->contains_member(xanchor_hub_id));
535 define_old_variable(
bool old_descending = _descending);
536 define_old_variable(
bool old_strict = _strict);
537 define_old_variable(
scoped_index old_filter_index = filter().index());
538 define_old_variable(
int old_anchor_version = anchor().version());
542 _anchor->attach_to_state(xanchor_hub_id);
549 #ifdef DIAGNOSTIC_OUTPUT 551 cout <<
"in depth_first_itr<T>::initialize_traversal(xanchor_hub_id): " << endl
552 <<
"_anchor = " << *_anchor << endl
553 <<
"_filter = " << *_filter << endl;
559 ensure(is_initialized());
561 ensure(anchor().index() == xanchor_hub_id);
562 ensure(anchor().version() == old_anchor_version);
563 ensure(filter().index() == old_filter_index);
564 ensure(descending() == old_descending);
565 ensure(strict() == old_strict);
572 template <
typename T>
579 require(is_initialized());
580 require(anchor().state_is_read_accessible());
581 require(anchor().host()->contains_member(xanchor_id));
586 define_old_variable(
bool old_descending = _descending);
587 define_old_variable(
bool old_strict = _strict);
588 define_old_variable(
scoped_index old_filter_index = filter().index());
589 define_old_variable(
int old_anchor_version = anchor().version());
591 initialize_traversal(xanchor_id.
hub_pod());
596 ensure(is_initialized());
598 ensure(anchor().index() ==~ xanchor_id);
599 ensure(anchor().version() == old_anchor_version);
600 ensure(filter().index() == old_filter_index);
601 ensure(descending() == old_descending);
602 ensure(strict() == old_strict);
609 template <
typename T>
616 require(anchor_is_ancestor_of(xanchor));
624 _anchor = xanchor.
clone();
626 else if(!_anchor->is_same_type(&xanchor))
628 release_cover_id_space_iterators();
630 _anchor->detach_from_state();
632 _anchor = xanchor.
clone();
639 _index = _anchor->host()->member_id(
false);
640 _greater_index = _index;
641 _lesser_index = _index;
647 ensure(_anchor != 0);
648 ensure(_anchor->is_same_state(&xanchor));
649 ensure(_anchor->is_same_type(&xanchor));
657 template <
typename T>
673 ensure(_has_visited != 0);
682 template <
typename T>
689 require(_anchor != 0);
690 require(_anchor->state_is_read_accessible());
691 require(_client_filter.is_attached());
714 int lversion = _anchor->version();
716 if(lversion == COARSEST_COMMON_REFINEMENT_VERSION)
720 _filter = _client_filter.members();
727 if(_client_filter.index() == lversion_index)
732 _filter = _client_filter.members();
739 _filter =
new zn_to_bool(*(_client_filter.members()));
747 ensure(_filter != 0);
755 template <
typename T>
762 require(_anchor != 0);
763 require(_anchor->state_is_read_accessible());
764 require(_anchor->host()->includes_subposet(&xfilter));
769 define_old_variable(
bool old_descending = _descending);
770 define_old_variable(
bool old_strict = _strict);
772 _client_filter.attach_to_state(&xfilter);
779 ensure(_filter != 0);
780 ensure(_client_filter.is_same_state(&xfilter));
781 ensure(descending() == old_descending);
782 ensure(strict() == old_strict);
791 template <
typename T>
798 require(_anchor != 0);
799 require(_anchor->state_is_read_accessible());
800 require(_anchor->host()->includes_subposet(xfilter_hub_id));
805 _client_filter.attach_to_state(_anchor->host(), xfilter_hub_id);
811 ensure(_filter != 0);
812 ensure(_client_filter.index() == xfilter_hub_id);
820 template <
typename T>
827 require(_anchor != 0);
828 require(_anchor->state_is_read_accessible());
829 require(_anchor->host()->includes_subposet(xfilter_id));
834 initialize_filter(xfilter_id.
hub_pod());
838 ensure(_filter != 0);
839 ensure(_client_filter.index() ==~ xfilter_id);
847 template <
typename T>
854 require(_anchor != 0);
855 require(_anchor->state_is_read_accessible());
856 require(!xfilter_name.empty() ?
857 _anchor->host()->includes_subposet(xfilter_name) :
863 if(xfilter_name.empty())
865 _client_filter.attach_to_state(_anchor->host(), _anchor->version_name());
869 _client_filter.attach_to_state(_anchor->host(), xfilter_name);
876 ensure(_filter != 0);
877 ensure(!xfilter_name.empty() ?
878 _client_filter.name() == xfilter_name :
879 _client_filter.name() == anchor().version_name());
887 template <
typename T>
898 _anchor->host()->get_read_access();
900 if(_path_head_lc != 0)
902 _anchor->host()->release_cover_id_space_iterator(*_path_head_lc);
908 _anchor->host()->release_cover_id_space_iterator(*_path_head);
912 while(!_path_tail.empty())
914 _anchor->host()->release_cover_id_space_iterator(*_path_tail.top());
918 _anchor->host()->release_access();
924 assertion(_path_head_lc == 0);
925 assertion(_path_head == 0);
926 assertion(_path_tail.empty());
931 ensure(_path_head_lc == 0);
932 ensure(_path_head == 0);
933 ensure(_path_tail.empty());
940 template <
typename T>
943 iterator_state_names[NOT_A_STATE+1] =
946 "INIT_COVER_ITERATOR",
948 "INC_COVER_ITERATOR",
949 "ERASE_COVER_ITERATOR",
953 "EXECUTE_PREVISIT_ACTION",
954 "EXECUTE_LINK_ACTION",
955 "EXECUTE_POSTVISIT_ACTION",
960 template <
typename T>
963 PREORDER_TRANSITION_FCN[NOT_A_STATE-1][FAIL+1] =
967 EXECUTE_PREVISIT_ACTION, EXECUTE_PREVISIT_ACTION,
968 TEST_HAS_VISITED, TEST_PATH_TAIL,
969 INC_COVER_ITERATOR, DESCEND,
970 TEST_HAS_VISITED, TEST_PATH_TAIL,
971 NOT_A_STATE, NOT_A_STATE,
972 EXECUTE_PREVISIT_ACTION, EXECUTE_PREVISIT_ACTION,
974 INC_COVER_ITERATOR, INC_COVER_ITERATOR,
975 INIT_COVER_ITERATOR, INIT_COVER_ITERATOR,
976 NOT_A_STATE, NOT_A_STATE,
977 NOT_A_STATE, NOT_A_STATE
981 template <
typename T>
984 POSTORDER_TRANSITION_FCN[NOT_A_STATE-1][FAIL+1] =
988 INIT_COVER_ITERATOR, INIT_COVER_ITERATOR,
989 TEST_HAS_VISITED, EXECUTE_POSTVISIT_ACTION,
990 INC_COVER_ITERATOR, DESCEND,
991 TEST_HAS_VISITED, EXECUTE_POSTVISIT_ACTION,
992 NOT_A_STATE, NOT_A_STATE,
993 INIT_COVER_ITERATOR, INIT_COVER_ITERATOR,
995 INC_COVER_ITERATOR, INC_COVER_ITERATOR,
996 NOT_A_STATE, NOT_A_STATE,
997 NOT_A_STATE, NOT_A_STATE,
998 TEST_PATH_TAIL, TEST_PATH_TAIL
1001 template <
typename T>
1004 LINKORDER_TRANSITION_FCN[NOT_A_STATE-1][FAIL+1] =
1008 INIT_COVER_ITERATOR, INIT_COVER_ITERATOR,
1009 TEST_HAS_VISITED, TEST_PATH_TAIL,
1010 EXECUTE_LINK_ACTION, DESCEND,
1011 TEST_HAS_VISITED, TEST_PATH_TAIL,
1012 TEST_HAS_VISITED, TEST_PATH_TAIL,
1013 INIT_COVER_ITERATOR, INIT_COVER_ITERATOR,
1015 EXECUTE_LINK_ACTION, EXECUTE_LINK_ACTION,
1016 NOT_A_STATE, NOT_A_STATE,
1017 INC_COVER_ITERATOR, INC_COVER_ITERATOR,
1018 NOT_A_STATE, NOT_A_STATE
1021 template <
typename T>
1024 BIORDER_TRANSITION_FCN[NOT_A_STATE-1][FAIL+1] =
1028 EXECUTE_PREVISIT_ACTION, EXECUTE_PREVISIT_ACTION,
1029 TEST_HAS_VISITED, EXECUTE_POSTVISIT_ACTION,
1030 INC_COVER_ITERATOR, DESCEND,
1031 TEST_HAS_VISITED, EXECUTE_POSTVISIT_ACTION,
1032 NOT_A_STATE, NOT_A_STATE,
1033 EXECUTE_PREVISIT_ACTION, EXECUTE_PREVISIT_ACTION,
1035 INC_COVER_ITERATOR, INC_COVER_ITERATOR,
1036 INIT_COVER_ITERATOR, INIT_COVER_ITERATOR,
1037 NOT_A_STATE, NOT_A_STATE,
1038 TEST_PATH_TAIL, TEST_PATH_TAIL
1041 template <
typename T>
1044 TRIORDER_TRANSITION_FCN[NOT_A_STATE-1][FAIL+1] =
1048 EXECUTE_PREVISIT_ACTION, EXECUTE_PREVISIT_ACTION,
1049 TEST_HAS_VISITED, EXECUTE_POSTVISIT_ACTION,
1050 EXECUTE_LINK_ACTION, DESCEND,
1051 TEST_HAS_VISITED, EXECUTE_POSTVISIT_ACTION,
1052 TEST_HAS_VISITED, EXECUTE_POSTVISIT_ACTION,
1053 EXECUTE_PREVISIT_ACTION, EXECUTE_PREVISIT_ACTION,
1055 EXECUTE_LINK_ACTION, EXECUTE_LINK_ACTION,
1056 INIT_COVER_ITERATOR, INIT_COVER_ITERATOR,
1057 INC_COVER_ITERATOR, INC_COVER_ITERATOR,
1058 TEST_PATH_TAIL, TEST_PATH_TAIL
1070 template <
typename T>
1090 template <
typename T>
1101 result = (_anchor != 0) && (_has_visited != 0) && (_filter != 0);
1110 template <
typename T>
1117 require(is_initialized());
1130 template <
typename T>
1137 require(is_initialized());
1150 template <
typename T>
1173 template <
typename T>
1184 result = _descending;
1193 template <
typename T>
1213 template <
typename T>
1224 require(is_initialized());
1239 template <
typename T>
1250 result = (_state == NOT_A_STATE);
1259 template <
typename T>
1268 _index.invalidate();
1270 _action = NOT_AN_ACTION;
1271 _state = NOT_A_STATE;
1275 release_cover_id_space_iterators();
1279 while(!_filtered_path_tail.empty())
1281 _filtered_path_tail.pop();
1286 ensure(invariant());
1292 template <
typename T>
1299 require(!is_done());
1327 #ifdef DIAGNOSTIC_OUTPUT 1328 cout <<
"in depth_first_itr<T>::next: _state = " << iterator_state_names[_state];
1329 if(is_initialized())
1331 cout <<
"\t\t_filtered_path_tail: " << _filtered_path_tail.top();
1332 cout <<
"\t _index: " << _index;
1339 case INIT_COVER_ITERATOR:
1343 if(_path_head_lc != 0)
1345 _anchor->host()->release_cover_id_space_iterator(*_path_head_lc);
1348 _path_head_lc = &_anchor->host()->get_cover_id_space_iterator(_descending, _index);
1355 _path_head_lc->force_is_done();
1365 if(!_path_head_lc->is_done())
1373 _state = _transition_fcn[INIT_COVER_ITERATOR][PASS];
1380 _state = _transition_fcn[INIT_COVER_ITERATOR][FAIL];
1385 case TEST_HAS_VISITED:
1390 lc_index = _path_head_lc->hub_pod();
1392 if(_visit_once && has_visited(lc_index))
1397 _state = _transition_fcn[TEST_HAS_VISITED][PASS];
1404 _state = _transition_fcn[TEST_HAS_VISITED][FAIL];
1408 case INC_COVER_ITERATOR:
1412 _path_head_lc->next();
1416 if(!_path_head_lc->is_done())
1421 _state = _transition_fcn[INC_COVER_ITERATOR][PASS];
1428 _state = _transition_fcn[INC_COVER_ITERATOR][FAIL];
1433 case ERASE_COVER_ITERATOR:
1443 #ifdef DIAGNOSTIC_OUTPUT 1444 cout <<
"in depth_first_itr<T>::next::ERASE_COVER_ITERATOR " 1445 <<
"erasing " << _path_head_lc->hub_pod()
1446 <<
" in cover of " << _path_head
1451 _path_head_lc->next();
1452 _anchor->host()->clear_cover(_descending, litem);
1458 if(!_path_head_lc->is_done())
1463 _state = _transition_fcn[ERASE_COVER_ITERATOR][PASS];
1470 _state = _transition_fcn[ERASE_COVER_ITERATOR][FAIL];
1479 lc_index = _path_head_lc->hub_pod();
1481 put_has_visited(lc_index,
true);
1485 if(_index !=~ _anchor->index())
1487 assertion(_index.pod() == _path_head->hub_pod());
1489 _path_tail.push(_path_head);
1493 if(filter(_path_head->hub_pod()))
1495 _filtered_path_tail.push(_path_head->hub_pod());
1499 _path_head = _path_head_lc;
1507 _state = _transition_fcn[DESCEND][PASS];
1511 case TEST_PATH_TAIL:
1516 if(_index == _anchor->index())
1522 _state = _transition_fcn[TEST_PATH_TAIL][PASS];
1528 _state = _transition_fcn[TEST_PATH_TAIL][FAIL];
1537 _anchor->host()->release_cover_id_space_iterator(*_path_head_lc);
1541 if(_path_tail.empty())
1545 _path_head_lc = _path_head;
1550 _index = _anchor->index();
1556 _path_head_lc = _path_head;
1560 if(!_filtered_path_tail.empty() &&
1561 (_filtered_path_tail.top() == _path_tail.top()->hub_pod()))
1565 assertion(!_filtered_path_tail.empty());
1566 _filtered_path_tail.pop();
1569 _path_head = _path_tail.top();
1574 _index = _path_head->hub_pod();
1581 _state = _transition_fcn[ASCEND][PASS];
1585 case EXECUTE_PREVISIT_ACTION:
1596 if(filter(_index) && (!_strict || !(_index == _anchor->index())) )
1606 _state = _transition_fcn[EXECUTE_PREVISIT_ACTION][PASS];
1607 _action = PREVISIT_ACTION;
1619 _state = _transition_fcn[EXECUTE_PREVISIT_ACTION][FAIL];
1624 case EXECUTE_LINK_ACTION:
1626 #ifdef DIAGNOSTIC_OUTPUT 1628 cout <<
"\t\t*_path_head_lc: " << _path_head_lc->hub_pod() << endl;
1633 if( filter(_index) && (!_strict || !(_index == _anchor->index())) )
1641 _state = _transition_fcn[EXECUTE_LINK_ACTION][PASS];
1642 _action = LINK_ACTION;
1652 _state = _transition_fcn[EXECUTE_LINK_ACTION][FAIL];
1657 case EXECUTE_POSTVISIT_ACTION:
1663 if( filter(_index) && (!_strict || !(_index == _anchor->index())) )
1671 _state = _transition_fcn[EXECUTE_POSTVISIT_ACTION][PASS];
1672 _action = POSTVISIT_ACTION;
1682 _state = _transition_fcn[EXECUTE_POSTVISIT_ACTION][FAIL];
1691 _index.invalidate();
1695 _state = NOT_A_STATE;
1696 _action = NOT_AN_ACTION;
1714 template <
typename T>
1721 require(is_initialized());
1722 require(anchor().state_is_read_accessible());
1726 define_old_variable(
bool old_descending = _descending);
1727 define_old_variable(
bool old_strict = _strict);
1736 clear_has_visited();
1744 ensure(invariant());
1745 ensure(descending() == old_descending);
1746 ensure(strict() == old_strict);
1760 template <
typename T>
1769 require(is_initialized());
1770 require(xreset ? anchor().state_is_read_accessible():
true);
1785 ensure(result >= 0);
1793 template <
typename T>
1812 template <
typename T>
1830 template <
typename T>
1835 bool result =
false;
1839 require(is_initialized());
1840 require(anchor().state_is_read_accessible());
1841 require(anchor().host()->contains_member(xhub_id));
1854 template <
typename T>
1861 require(is_initialized());
1862 require(anchor().state_is_read_accessible());
1863 require(anchor().host()->contains_member(xid));
1867 return has_visited(xid.
hub_pod());
1870 template <
typename T>
1877 require(is_initialized());
1878 require(anchor().state_is_read_accessible());
1881 require(anchor().host()->is_same_state(xmbr->
host()));
1888 template <
typename T>
1895 require(is_initialized());
1896 require(anchor().state_is_read_accessible());
1897 require(anchor().host()->contains_member(xhub_id));
1905 ensure(has_visited(xhub_id) == xvalue);
1912 template <
typename T>
1919 require(is_initialized());
1920 require(anchor().state_is_read_accessible());
1921 require(anchor().host()->contains_member(xid));
1925 put_has_visited(xid.
hub_pod(), xvalue);
1929 ensure(has_visited(xid) == xvalue);
1936 template <
typename T>
1944 template <
typename T>
1953 _visit_once = xvisit_once;
1957 ensure(visit_once() == xvisit_once);
1964 template <
typename T>
1973 require(is_initialized());
1977 result = !greater_index().is_valid();
1981 ensure(result == !greater_index().
is_valid());
1988 template <
typename T>
1995 require(is_initialized());
1996 require(!is_done());
2001 (_action == LINK_ACTION) ? _index.pod() :
2002 (_filtered_path_tail.empty() ?
invalid_pod_index() : _filtered_path_tail.top());
2008 return _greater_index;
2011 template <
typename T>
2018 require(is_initialized());
2019 require(!is_done());
2030 _lesser_index = (_action == LINK_ACTION) ? _path_head_lc->hub_pod() : _index.pod();
2036 return _lesser_index;
2039 template <
typename T>
2059 template <
typename T>
2066 require(action() == LINK_ACTION);
2070 _state = ERASE_COVER_ITERATOR;
2090 template <
typename T>
2097 require(!is_done());
2105 ensure( (action() == LINK_ACTION) ? (result == greater_index()) : (result == lesser_index()) );
2112 template <
typename T>
2121 require(!is_done());
2125 result = _path_tail.size();
2145 template <
typename T>
2165 template <
typename T>
2180 ensure(result != 0);
2188 template <
typename T>
2201 if(invariant_check())
2203 disable_invariant_check();
2205 invariance( is_initialized() ? order() != NOT_AN_ORDER :
true);
2206 invariance( !is_initialized() ? is_done() :
true);
2207 invariance( is_initialized() ? anchor().is_attached() == (_has_visited != 0) :
true );
2208 invariance( is_initialized() == (_has_visited != 0));
2218 invariance( (action() == NOT_AN_ACTION) == is_done() );
2219 invariance( (_state == NOT_A_STATE) == is_done() );
2220 invariance( _new_filter ? _filter != 0 :
true );
2221 invariance( is_initialized() == (_anchor != 0) );
2222 invariance( !is_initialized() ? !_new_filter :
true );
2227 enable_invariant_check();
action_type
The types of action a client should take when the iterator returns control to the client...
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
void clear_has_visited()
Makes has_visited(i) false for all i.
void put_has_visited(pod_index_type xhub_id, bool xvalue)
Set the visited marker for hub id xhub_id to xvalue. Intended for use reseting iterator without havin...
poset_state_handle * host() const
The poset which this is a handle to a component of.
virtual void initialize_has_visited(const abstract_poset_member &xanchor)
Initializes the has_visited markers.
A client handle for a subposet.
zn_to_bool * members() const
Get the members of the subposet.
virtual abstract_poset_member & anchor()
The poset member whose downset is being iterated over; the top member of the domain of iteration...
size_t depth()
The length of the path from anchor() to the current member.
virtual void detach_item()
Detaches the item handle to the current index. Empty in this class; intended for redefinition in desc...
virtual void reset(bool xreset_markers=true)
Restarts the iteration over the down set of anchor().
bool is_done() const
True if iteration finished.
order_type
The types of order in which the iterator will visit the members of the poset. Determines which action...
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
int version(bool xunalias=true) const
The (possibly aliased) version of this component. The version of the host used when evaluating proper...
bool has_visited(pod_index_type xhub_id) const
True if this has already visited member with hub id xhub_id.
void initialize_order(order_type xorder)
Initializes _order and _transition_fcn.
void initialize_filter()
Initializes the filter subposet from the client filter.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
bool _descending
True if iterating over the up/down set of anchor.
order_type order() const
The order of the iteration. Determines which actions are exported to the client.
bool invariant() const
The class invariant.
A client handle for a general, abstract partially order set.
bool filter(pod_index_type xhub_id)
The value of the filter at hub id xhub_id.
int ct(bool xreset=false)
The number of members of the iteration set, from the current member to the end, inclusive. If xreset, reset before computing the count.
const scoped_index & greater_index() const
The index of the greater member of the current link.
const scoped_index & index() const
The index of the component state this handle is attached to.
iterator_state
The states for the finite state machine that controls iteration.
namespace_poset * host() const
The namespace this poset resides in. Obsolete; use name_space() instead.
depth_first_itr()
Default constructor; creates an unattached iterator,.
virtual depth_first_itr * clone() const
Make a new instance of the same type as this.
const scoped_index & index() const
The index of the current member of the iteration.
action_type action() const
The type of action the client should take when the iterator returns control to the client...
void reserve_has_visited(pod_index_type xub)
Ensures has_visited(i) is a legal call for 0 <= i < xub.
Abstract base class with useful features for all objects.
A map from Zn (the integers mod n) to bools. A characteristic function used to represent subsets of Z...
virtual void force_is_done()
Force the iterator to be done.
bool visit_once() const
True if traversal should only visit a member once; that is, it should not revisit members it has alre...
The general depth-first iterator over the intersection of a poset member anchor's whole with its down...
virtual pod_index_type version_index(int xversion) const
The subposet hub id of the whole() subposet for version xversion.
bool _visit_once
True if traversal should only visit a member once; that is, it should not revisit members it has alre...
void initialize_traversal(const abstract_poset_member &xanchor)
Initializes the anchor, has_visited markers and filter.
An index within the external ("client") scope of a given id space.
virtual bool is_attached() const
True if this handle is attached to a non-void state.
bool strict() const
True if iterating over xstrict up/down set of anchor.
void mark_not_visited(abstract_poset_member *xmbr)
Mark xmbr as not visited. Warning: this function can change the state of the iteration in unpredictab...
void initialize_anchor(const abstract_poset_member &xanchor)
Initializes the anchor.
void mark_visited(abstract_poset_member *xmbr)
Mark xmbr as visited. Warning: this function can change the state of the iteration in unpredictable w...
subposet & filter()
The subposet which is the filter; Defines what is passed, not what is blocked.
virtual bool anchor_is_ancestor_of(const abstract_poset_member &xmbr) const
True if xmbr conforms to the type of anchor of this.
depth_first_itr & operator=(const depth_first_itr &xother)
Assignment operator.
virtual void attach_item()
Attaches the item handle to the current index. Empty in this class; intended for redefinition in desc...
abstract_poset_member * clone(bool xnew_state, bool xauto_access=true) const
Virtual constructor; makes a new handle of the same type as this, attached to a new state (xnew_state...
const bool NO_RESET
Iteration marker reset control.
void release_cover_id_space_iterators()
Release the cover iterators back to the pool of iterators.
void next()
Makes this the next member of the subset.
virtual ~depth_first_itr()
Destructor.
void put_visit_once(bool xvisit_once)
Set visit_once() to xvisit_once.
int_type pod_index_type
The plain old data index type.
Namespace for the sheaves component of the sheaf system.
bool is_maximal()
True if the current member has no greater member within the subposet visited by this iterator...
subposet_state & member(pod_index_type xindex)
The subposet with index xindex (mutable version).
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
const scoped_index & lesser_index() const
The index of the lesser member of the current link.
void first()
Moves this to the first member of the iteration.
An abstract client handle for a member of a poset.
virtual bool is_initialized() const
True if this has been initialized for iteration with respect to a specific anchor.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
bool descending() const
True if iterating over down set of anchor.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
order_type _order
The order of the iteration.
void erase_cover()
Schedules the lesser member entry in the cover of the greater member of the current link for deletion...
poset_powerset_state & powerset() const
The set of subposets of this poset.
bool _strict
True if iterating over the strict up/down set of anchor.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.