<commit_before><commit_msg>provide basic iterator interfaces<commit_after>/**
 * Foreach.h
 *
 * Basic iterator constructs.
 *
 * Copyright (c) 2008 <NAME> <<EMAIL>>
 */

#include "Atom.h"
#include "TLB.h"

namespace opencog {

/**
 * Invoke the callback on each atom in the outgoing set of
 * handle h.
 */
template<class T>
inline bool foreach_outgoing(Handle h, bool (T::*cb)(Atom *), T *data)
{
	Atom *atom = TLB::getAtom(h);
	const std::vector<Handle> &vh = atom->getOutgoingSet();

	for (size_t i=0; i<vh.size(); i++)
	{
		Handle hout = vh[i];
		Atom *aout = TLB::getAtom(hout);
		bool rc = (data->*cb)(aout);
		if (rc) return rc;
	}
	return false;
}

}
{'fraction_non_alphanumeric': 0.17602427921092564, 'fraction_numerical': 0.007587253414264037, 'mean_word_length': 4.038167938931298, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2064104', 'n_tokens_mistral': 273, 'n_tokens_neox': 257, 'n_words': 69}