private static NodeProvider createNodeProvider(final AtomVariable arg, final List<RuleAtom> processed, final boolean lastWME) { for (int index = 0, n = processed.size(); index < n; index++) { final RuleAtom sharedAtom = processed.get(index); final int indexArg = sharedAtom.getAllArguments().indexOf(arg); if (indexArg != -1) if (lastWME && index == n - 1) return new WMENodeProvider(indexArg); else return new TokenNodeProvider(index, indexArg); } return null; }
@Override public boolean equals(final Object other) { if (other != null && getClass().equals(other.getClass())) { final RuleAtom atom = (RuleAtom) other; return getPredicate().equals(atom.getPredicate()) && getAllArguments().equals(atom.getAllArguments()); } return false; }
@Override public boolean equals(final Object other) { if (other != null && getClass().equals(other.getClass())) { final RuleAtom atom = (RuleAtom) other; return getPredicate().equals(atom.getPredicate()) && getAllArguments().equals(atom.getAllArguments()); } return false; }
private static NodeProvider createNodeProvider(final AtomVariable arg, final List<RuleAtom> processed, final boolean lastWME) { for (int index = 0, n = processed.size(); index < n; index++) { final RuleAtom sharedAtom = processed.get(index); final int indexArg = sharedAtom.getAllArguments().indexOf(arg); if (indexArg != -1) if (lastWME && index == n - 1) return new WMENodeProvider(indexArg); else return new TokenNodeProvider(index, indexArg); } return null; }
private RuleAtom pickNextAtom(final List<RuleAtom> atoms, final Set<AtomVariable> bound) { int index = 0; if (bound.isEmpty()) for (int i = 0; i < atoms.size(); i++) { final RuleAtom atom = atoms.get(i); if (_safetyChecker.isSafe(atom)) return atoms.remove(i); } else for (int i = 0; i < atoms.size(); i++) { final RuleAtom atom = atoms.get(i); if (SetUtils.intersects(bound, atom.getAllArguments())) { index = i; if (_safetyChecker.isSafe(atom)) break; } } return atoms.remove(index); }
private RuleAtom pickNextAtom(final List<RuleAtom> atoms, final Set<AtomVariable> bound) { int index = 0; if (bound.isEmpty()) for (int i = 0; i < atoms.size(); i++) { final RuleAtom atom = atoms.get(i); if (_safetyChecker.isSafe(atom)) return atoms.remove(i); } else for (int i = 0; i < atoms.size(); i++) { final RuleAtom atom = atoms.get(i); if (SetUtils.intersects(bound, atom.getAllArguments())) { index = i; if (_safetyChecker.isSafe(atom)) break; } } return atoms.remove(index); }
/** * Static convenience function to return the instance variables used in the given atom. * * @param atom * @return return the instance variables used in the given atom. */ public static Collection<AtomDVariable> getDVars(final RuleAtom atom) { final VisitingDCollector collector = new VisitingDCollector(); for (final AtomObject obj : atom.getAllArguments()) obj.accept(collector); return collector.getVariables(); }
/** * Static convenience function to return the instance variables used in the given atom. * * @param atom * @return return the instance variables used in the given atom. */ public static Collection<AtomDVariable> getDVars(final RuleAtom atom) { final VisitingDCollector collector = new VisitingDCollector(); for (final AtomObject obj : atom.getAllArguments()) obj.accept(collector); return collector.getVariables(); }
/** * Static convenience function to return the instance variables used in the given atom. * * @param atom * @return return the instance variables used in the given atom. */ public static Collection<AtomIVariable> getIVars(final RuleAtom atom) { final VisitingICollector collector = new VisitingICollector(); for (final AtomObject obj : atom.getAllArguments()) obj.accept(collector); return collector.getVariables(); }
/** * Static convenience function to return the instance variables used in the given atom. * * @param atom * @return return the instance variables used in the given atom. */ public static Collection<AtomIVariable> getIVars(final RuleAtom atom) { final VisitingICollector collector = new VisitingICollector(); for (final AtomObject obj : atom.getAllArguments()) obj.accept(collector); return collector.getVariables(); }
/** * Static convenience function to return the variables used in the given atom. * * @param atom * @return the variables used in the given atom. */ public static Collection<AtomVariable> getVars(final RuleAtom atom) { final VisitingCollector collector = new VisitingCollector(); for (final AtomObject obj : atom.getAllArguments()) obj.accept(collector); return collector.getVariables(); }
/** * Static convenience function to return the variables used in the given atom. * * @param atom * @return the variables used in the given atom. */ public static Collection<AtomVariable> getVars(final RuleAtom atom) { final VisitingCollector collector = new VisitingCollector(); for (final AtomObject obj : atom.getAllArguments()) obj.accept(collector); return collector.getVariables(); }
final List<? extends AtomObject> args = atom.getAllArguments(); for (final AtomObject arg : processed.get(i).getAllArguments()) if (arg instanceof AtomVariable && !args.containsKey(arg)) args.put((AtomVariable) arg, createNodeProvider((AtomVariable) arg, processed));
final List<? extends AtomObject> args = atom.getAllArguments(); for (final AtomObject arg : processed.get(i).getAllArguments()) if (arg instanceof AtomVariable && !args.containsKey(arg)) args.put((AtomVariable) arg, createNodeProvider((AtomVariable) arg, processed));