return d_nv->end< NodeTemplate<ref_count> >();
}
+ /**
+ * Returns the iterator pointing to the first child.
+ * @return the iterator
+ */
+ template <Kind kind>
+ inline iterator begin() {
+ if(!ref_count) {
+ Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
+ }
+
+ return d_nv->begin< NodeTemplate<ref_count>, kind >();
+ }
+
+ /**
+ * Returns the iterator pointing to the end of the children (one beyond the
+ * last one.
+ * @return the end of the children iterator.
+ */
+ template <Kind kind>
+ inline iterator end() {
+ if(!ref_count) {
+ Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
+ }
+
+ return d_nv->end< NodeTemplate<ref_count>, kind >();
+ }
+
+
/**
* Returns the const_iterator pointing to the first child.
* @return the const_iterator
return d_nv->end< NodeTemplate<ref_count> >();
}
+ /**
+ * Returns the const_iterator pointing to the first child.
+ * @return the const_iterator
+ */
+ template <Kind kind>
+ inline const_iterator begin() const {
+ if(!ref_count) {
+ Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
+ }
+
+ return d_nv->begin< NodeTemplate<ref_count>, kind >();
+ }
+
+ /**
+ * Returns the const_iterator pointing to the end of the children (one
+ * beyond the last one.
+ * @return the end of the children const_iterator.
+ */
+ template <Kind kind>
+ inline const_iterator end() const {
+ if(!ref_count) {
+ Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" );
+ }
+
+ return d_nv->end< NodeTemplate<ref_count>, kind >();
+ }
+
/**
* Converts this node into a string representation.
* @return the string representation of this node.
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
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);