diff options
author | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2010-09-21 17:33:06 +0000 |
---|---|---|
committer | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2010-09-21 17:33:06 +0000 |
commit | ea9346f840046ee20558afb2a17dd5999d45c5c9 (patch) | |
tree | 96f657b2f5790407025c7d99d27d0eb3e6708eda /src/expr/node_value.h | |
parent | 2fa76743be4d68dbbaa54069ef91b7066ba22543 (diff) |
iterators for tim, begin<PLUS>() and end<PLUS>() should give him what he wants
Diffstat (limited to 'src/expr/node_value.h')
-rw-r--r-- | src/expr/node_value.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/expr/node_value.h b/src/expr/node_value.h index 3c21777ed..63121b981 100644 --- a/src/expr/node_value.h +++ b/src/expr/node_value.h @@ -187,6 +187,12 @@ public: template <typename T> inline iterator<T> end() const; + template <typename T, Kind kind> + inline iterator<T> begin() const; + + template <typename T, Kind kind> + inline iterator<T> end() const; + /** * Hash this NodeValue. For hash_maps, hash_sets, etc.. but this is * for expr package internal use only at present! This is likely to @@ -356,6 +362,22 @@ inline NodeValue::iterator<T> NodeValue::end() const { return iterator<T>(d_children + d_nchildren); } +template <typename T, Kind kind> +inline NodeValue::iterator<T> NodeValue::begin() const { + if (d_kind != kind) return iterator<T>(this); + NodeValue* const* firstChild = d_children; + if(getMetaKind() == kind::metakind::PARAMETERIZED) { + ++firstChild; + } + return iterator<T>(firstChild); +} + +template <typename T, Kind kind> +inline NodeValue::iterator<T> NodeValue::end() const { + if (d_kind != kind) return iterator<T>(this + 1); + return iterator<T>(d_children + d_nchildren); +} + inline bool NodeValue::isBeingDeleted() const { return NodeManager::currentNM() != NULL && NodeManager::currentNM()->isCurrentlyDeleting(this); |