KeyIterator< S, T > Class Template Reference#include <KeyIterator.h>
List of all members.
|
Public Member Functions |
| INLINE T & | current_data () |
| | Return data of current element.
|
| INLINE const S & | current_key () const |
| INLINE S & | current_key () |
| | Return key of current element.
|
| INLINE void | reset () |
| | Go back to the beginning of the iteration space.
|
| INLINE void | set_to_last () |
| | Set the iterator to the last value Useful if you need to iterator backwards.
|
| INLINE void | next (iter_option option=STOP_ON_GHOSTS) |
| | go to the next valid element, or if STOP_AT_GHOSTS to the next element
|
| INLINE void | operator++ () |
| | go to next element according to how KeyIterator was defined
|
| INLINE void | prev (iter_option option=STOP_ON_GHOSTS) |
| | go to the previous valid element, or if STOP_AT_GHOSTS to the previous element
|
| INLINE void | operator-- () |
| | go to next element according to how KeyIterator was defined
|
| INLINE Boolean | end () |
| | Return true if there no more Nodes to iterate on.
|
| INLINE Boolean | valid () |
| | Equivalent to NOT end().
|
| INLINE Boolean | current_valid () const |
| | Return true iff valid() would return 1 AND the current node is still valid.
|
| INLINE Boolean | current_invalid () const |
| | Equivalent to ( ! current_valid() ).
|
| INLINE | KeyIterator (const KeyIterator< S, T > &other) |
| | This method copies the entire state (including current element) of the iterator.
|
| INLINE KeyIterator< S, T > & | operator= (const KeyIterator< S, T > &other) |
| | This method copies the entire state (including current element) of the iterator.
|
| INLINE | KeyIterator (const TypedBaseMap< S, T > &map, iter_option option=STOP_ON_GHOSTS) |
| | Constructor -- note: The iterator does not contain a copy of the map -- it just contains some pointers into it, therefore the map may not have items deleted or inserted during the lifetime of this iterator.
|
| INLINE KeyIterator< S, T > & | operator= (const TypedBaseMap< S, T > &map) |
| INLINE | KeyIterator (const TypedBaseRefMap< S, T > &map, iter_option option=STOP_ON_GHOSTS) |
| | Constructor -- note: The iterator does not contain a copy of the map -- it just contains some pointers into it, therefore the map may not have items deleted or inserted during the lifetime of this iterator.
|
| INLINE KeyIterator< S, T > & | operator= (const TypedBaseRefMap< S, T > &map) |
| INLINE | ~KeyIterator () |
Detailed Description
template<class S, class T>
class KeyIterator< S, T >
A template for a complex iterator over a map for keys of type S to objects of type T where:
1. 'S' is a class with:
a) <, == and << operators taking S& arguments.
b) a copy constructor S(S &) to clone the
input object or simple enough structure
for the default copy constructor to work.
2. 'T' is a class derived from Listable.
These Iterators are designed to work much like the general Collection Iterator:
Declare an iterator:
--or--
This implementation works with the reference counting scheme of Collections. Thus, it is not possible for an element of a Collection to be deleted out from under an iterator. It is possible, however, for the current() node to suddenly become invalid--that is for the object suddenly being made inaccessable, turning the current node into a ghost-node. It is illegal to try to access the current node if it is a ghost-node. This can be checked by calling current_valid().
Ghost nodes can only be encountered in live structures by loosing ownership of the current node, but they are more frequent in reference structures. If an object is deleted from a live structure, references to it will remain. These, too, become "ghost-nodes". By default, ghost-nodes are skipped over by the iterator. For example, the Iterator forms described above skip over ghost-nodes. However, if an iterator is declared as the default, it is still possible to check for ghost nodes within the iteration space by calling next() and prev() using the STOP_AT_GHOSTS option: next(STOP_AT_GHOSTS) --or-- prev(STOP_AT_GHOSTS).
Also, it is possible to declare an iterator which will always stop on the ghost nodes. This is done by passing a positive flag in the constructor after the name of the list. This can be done as follows:
BaseIter Li(some_collection, STOP_AT_GHOSTS)
(iterate over whole list including ghosts)
In these above forms, the increment and decrement will stop on ghost nodes. next() and prev() will still stop on ghost- nodes only if they have the STOP_AT_GHOSTS flag. The general rule is that the ++ and -- operators behave according to how the Iterator was declared, while next and prev behave according to whether they have an argument.
Definition at line 89 of file KeyIterator.h.
Constructor & Destructor Documentation
|
|
This method copies the entire state (including current element) of the iterator.
If you don't like this, then immediately follow this constructor with a call to reset()
Definition at line 282 of file KeyIterator.h. |
|
|
Constructor -- note: The iterator does not contain a copy of the map -- it just contains some pointers into it, therefore the map may not have items deleted or inserted during the lifetime of this iterator.
|
|
|
Constructor -- note: The iterator does not contain a copy of the map -- it just contains some pointers into it, therefore the map may not have items deleted or inserted during the lifetime of this iterator.
|
Member Function Documentation
|
template<class S, class T> |
| INLINE T & KeyIterator< S, T >::current_data |
( |
|
) |
|
|
|
|
Return data of current element.
Cause an error if valid() == 0
Definition at line 187 of file KeyIterator.h.
References BaseIter::current().
Referenced by _add_asserts_to_ranges(), _add_range_refs(), BinRep::_ascii_format(), _intersect_range_maps(), _print(), _print_range_map(), _print_var_map(), _range_maps_equal(), IPCPProcData::add_constant_set(), PropConstWS::add_consts(), add_dummy_eta_assignments_after_loops(), add_dummy_global_assignments_at_calls(), IPCPProcData::add_maymods(), AliasSets::aliases(), AliasSets::AliasSets(), already_ip_ssa(), build_def_map(), Program::clean(), SSAControlRangeDict::clear(), GSAControlRangeDict::clear(), SSAControlRangeDict::clear_ranges(), GSAControlRangeDict::clear_ranges(), IPCPProcData::compute_rtoporder(), ProgramUnit::create_program_unit(), InterProcConstProp::expand_all_substituted(), find_main_pgm(), find_pgm(), SSAControlRangeDict::icdom_touch(), GSAControlRangeDict::icdom_touch(), IPCPProcData::IPCPProcData(), main(), make_ip_ssa(), modify_dummy_eta_assignments_after_loops(), SSAControlRangeDict::num_computed_ranges(), SSAControlRangeData::num_computed_ranges(), GSAControlRangeDict::num_computed_ranges(), GSAControlRangeData::num_computed_ranges(), IPCPConstants::operator==(), optimize_ssa_beta(), optimize_ssa_eta(), optimize_ssa_gamma(), optimize_ssa_mu(), SSAFullRangeDict::print(), SSAFullRangeData::print(), SSAControlRangeDict::print(), SSAControlRangeData::print(), RangeAccessor::print(), Program::print(), IPCPProcData::print(), GSAFullRangeDict::print(), GSAFullRangeData::print(), GSAControlRangeDict::print(), GSAControlRangeData::print(), FormatDB::print(), DefLocMap::print(), ControlRangeDict::print(), InterPCodeDomain::print(), AliasSets::print(), AIRangeDict::print(), IPCPConstants::print_constants(), InterProcConstProp::print_consts_sets(), print_dmap(), print_gmap(), process(), remove_dummy_assignments(), remove_maymod_assertions(), SSAProgramUnit::rename_variables(), StmtRanges::simplify_min_max(), SSAControlRangeDict::stats(), GSAControlRangeDict::stats(), SSAFullRangeData::succs(), GSAFullRangeData::succs(), SSAControlRangeDict::touch(), GSAControlRangeDict::touch(), undo_ip_ssa(), PropCtrlRangeWS::update_out_ranges(), Program::write(), and FormatDB::write(). |
|
template<class S, class T> |
| INLINE const S & KeyIterator< S, T >::current_key |
( |
|
) |
const |
|
|
|
Definition at line 194 of file KeyIterator.h.
References BaseIter::current_key().
Referenced by _add_asserts_to_ranges(), _add_range_refs(), BinRep::_ascii_format(), _create_new_consts(), _create_old_const_mods(), _intersect_range_maps(), _print(), _print_range_map(), _print_var_map(), _range_maps_equal(), _update_old_consts(), IPCPProcData::add_constant_set(), PropConstWS::add_consts(), IPCPProcData::add_consts_to_pgm(), IPCPProcData::add_maymods(), AliasSets::aliases(), AliasSets::AliasSets(), SSAFullRangeDict::data_touch(), DefLocMap::DefLocMap(), IPCPProcData::IPCPProcData(), main(), modified_vars(), IPCPConstants::operator==(), optimize_ssa_beta(), optimize_ssa_eta(), optimize_ssa_gamma(), optimize_ssa_mu(), SSAFullRangeDict::pretty_print(), RangeAccessor::pretty_print(), GSAFullRangeDict::pretty_print(), ControlRangeDict::pretty_print(), SSAFullRangeDict::print(), SSAFullRangeData::print(), SSAControlRangeDict::print(), SSAControlRangeData::print(), RangeAccessor::print(), IPCPProcData::print(), GSAFullRangeDict::print(), GSAFullRangeData::print(), GSAControlRangeDict::print(), GSAControlRangeData::print(), DefLocMap::print(), ControlRangeDict::print(), AliasSets::print(), AIRangeDict::print(), IPCPConstants::print_constants(), InterProcConstProp::print_consts_sets(), print_dmap(), print_gmap(), StmtRefRanges::range_vars(), StmtRanges::range_vars(), SSAControlRangeData::range_vars(), GSAControlRangeData::range_vars(), SSAProgramUnit::rename_variables(), StmtRanges::simplify_min_max(), SSAControlRangeDict::stats(), GSAControlRangeDict::stats(), SSAControlRangeDict::touch(), and GSAControlRangeDict::touch(). |
|
template<class S, class T> |
| INLINE S & KeyIterator< S, T >::current_key |
( |
|
) |
|
|
|
template<class S, class T> |
| INLINE void KeyIterator< S, T >::reset |
( |
|
) |
|
|
|
template<class S, class T> |
| INLINE void KeyIterator< S, T >::set_to_last |
( |
|
) |
|
|
|
|
go to the next valid element, or if STOP_AT_GHOSTS to the next element
|
|
template<class S, class T> |
| INLINE void KeyIterator< S, T >::operator++ |
( |
|
) |
|
|
|
|
go to the previous valid element, or if STOP_AT_GHOSTS to the previous element
|
|
template<class S, class T> |
| INLINE void KeyIterator< S, T >::operator-- |
( |
|
) |
|
|
|
|
Equivalent to NOT end().
Definition at line 261 of file KeyIterator.h.
References BaseIter::valid().
Referenced by _add_asserts_to_ranges(), _add_range_refs(), BinRep::_ascii_format(), _create_new_consts(), _create_old_const_mods(), _intersect_range_maps(), _print(), _print_range_map(), _print_var_map(), _range_maps_equal(), _update_old_consts(), IPCPProcData::add_constant_set(), PropConstWS::add_consts(), IPCPProcData::add_consts_to_pgm(), add_dummy_eta_assignments_after_loops(), add_dummy_global_assignments_at_calls(), IPCPProcData::add_maymods(), AliasSets::aliases(), AliasSets::AliasSets(), already_ip_ssa(), build_def_map(), Program::clean(), SSAControlRangeDict::clear(), GSAControlRangeDict::clear(), SSAControlRangeDict::clear_ranges(), GSAControlRangeDict::clear_ranges(), IPCPProcData::compute_rtoporder(), ProgramUnit::create_program_unit(), SSAFullRangeDict::data_touch(), InterProcConstProp::expand_all_substituted(), find_main_pgm(), find_pgm(), SSAControlRangeDict::icdom_touch(), GSAControlRangeDict::icdom_touch(), IPCPProcData::IPCPProcData(), main(), make_ip_ssa(), modified_vars(), modify_dummy_eta_assignments_after_loops(), SSAControlRangeDict::num_computed_ranges(), SSAControlRangeData::num_computed_ranges(), GSAControlRangeDict::num_computed_ranges(), GSAControlRangeData::num_computed_ranges(), IPCPConstants::operator==(), optimize_ssa_beta(), optimize_ssa_eta(), optimize_ssa_gamma(), optimize_ssa_mu(), SSAFullRangeDict::pretty_print(), RangeAccessor::pretty_print(), GSAFullRangeDict::pretty_print(), ControlRangeDict::pretty_print(), SSAFullRangeDict::print(), SSAFullRangeData::print(), SSAControlRangeDict::print(), SSAControlRangeData::print(), RangeAccessor::print(), Program::print(), IPCPProcData::print(), GSAFullRangeDict::print(), GSAFullRangeData::print(), GSAControlRangeDict::print(), GSAControlRangeData::print(), FormatDB::print(), DefLocMap::print(), ControlRangeDict::print(), InterPCodeDomain::print(), AliasSets::print(), AIRangeDict::print(), IPCPConstants::print_constants(), InterProcConstProp::print_consts_sets(), print_dmap(), print_gmap(), process(), StmtRefRanges::range_vars(), StmtRanges::range_vars(), SSAControlRangeData::range_vars(), GSAControlRangeData::range_vars(), remove_dummy_assignments(), remove_maymod_assertions(), SSAProgramUnit::rename_variables(), StmtRanges::simplify_min_max(), SSAControlRangeDict::stats(), GSAControlRangeDict::stats(), SSAFullRangeData::succs(), GSAFullRangeData::succs(), SSAControlRangeDict::touch(), GSAControlRangeDict::touch(), undo_ip_ssa(), PropCtrlRangeWS::update_out_ranges(), and Program::write(). |
|
|
Return true iff valid() would return 1 AND the current node is still valid.
This function will return 0 even if valid() returns 1 if the current node is invalid, which will happen if the current node has become a ghost node by being deleted from its Collection. In the event that the current node is invalid, it is a checked run-time error to make a call to current(). However, the valid() method still returns 1 since the end of the iteration space has not yet been reached. Also, the operator++/--/prev()/next() methods will all work correctly and properly find the next element in the iteration space. If there is any chance that the current element pointed to by a BaseIter can be deleted, both valid() and current_valid() must return 1 for a call to current() to be acceptable.
Definition at line 268 of file KeyIterator.h.
References BaseIter::current_valid(). |
|
|
This method copies the entire state (including current element) of the iterator.
If you don't like this, then immediately follow this constructor with a call to reset()
Definition at line 290 of file KeyIterator.h. |
The documentation for this class was generated from the following file:
|