/** * The system was designed so that right-input tokens have only one fact in them. Furthermore, * they'll all have the same class type! As an optimization, then, we could skip the size check * and class comparison. For now, I'm leaving it in, using a general comparison function in the * Token class. In addition, we're assuming a token can only appear once; this is also by design, * and should always be true, unless we implement fact duplication, which CLIPS has as an option. * The user can always simulate this by using serial #s for facts. * * @returns null if not found, the found token otherwise. */ protected final Token findInMemory(TokenVector v, Token t) { Token tmp; int size = v.size(); for (int i = 0; i < size; i++) { tmp = v.elementAt(i); if (t.sortcode != tmp.sortcode) continue; if (t.data_equals(tmp)) return tmp; } return null; }
/** * Run all the tests on a given (left) token and every token in the right memory. For the true * ones, assemble a composite token and pass it along to the successors. */ protected void runTestsVaryRight(Token lt) throws ReteException { int size = right.size(); for (int i = 0; i < size; i++) { Token rt = right.elementAt(i); Token nt = appendToken(lt, rt); if (runTests(lt, rt, nt)) { int nsucc = _succ.length; for (int j = 0; j < nsucc; j++) { Successor s = _succ[j]; s.node.CallNode(nt, s.callType); } } } }
/** * Run all the tests on a given (right) token and every token in the left memory. For the true * ones, assemble a composite token and pass it along to the successors. */ protected void runTestsVaryLeft(Token rt) throws ReteException { int size = left.size(); for (int i = 0; i < size; i++) { Token lt = left.elementAt(i); Token nt = appendToken(lt, rt); if (runTests(lt, rt, nt)) { // the new token has the *left* token's tag at birth... nt.tag = rt.tag; int nsucc = _succ.length; for (int j = 0; j < nsucc; j++) { Successor s = _succ[j]; s.node.CallNode(nt, s.callType); } } } }