if (temp.getLength() == 0) targetClasses = targetClasses.append(rollEdgeOut(allowed, o, visited, stopList)); if (targetClasses.isEmpty()) ins = ins.append(rollEdgeIn(allowed, currEdge, visited, stopList)); ins = ins.append(rollEdgeIn(allowed, currEdge, visited, stopList)); for (int i = 0; i < targetClasses.getLength(); i++) ins = ins.append(targetClasses.elementAt(i));
/** * Apply the _disjunction rule to an specific label for an _individual * * @param _node * @param _disjunction */ protected void applyDisjunctionRule(final Individual node, final ATermAppl disjunction) { // _disjunction is now in the form not(and([not(d1), not(d2), ...])) final ATermAppl a = (ATermAppl) disjunction.getArgument(0); ATermList disjuncts = (ATermList) a.getArgument(0); final ATermAppl[] disj = new ATermAppl[disjuncts.getLength()]; for (int index = 0; !disjuncts.isEmpty(); disjuncts = disjuncts.getNext(), index++) { disj[index] = ATermUtils.negate((ATermAppl) disjuncts.getFirst()); if (node.hasType(disj[index])) return; } final DisjunctionBranch newBranch = new DisjunctionBranch(_strategy.getABox(), _strategy, node, disjunction, node.getDepends(disjunction), disj); _strategy.addBranch(newBranch); newBranch.tryNext(); }
test(Ts[0].getLength() == 10, "length-1"); test(Ts[0].indexOf(_factory.makeInt(2), 0) == 2, "indexOf-1"); test(Ts[0].indexOf(_factory.makeInt(10), 0) == -1, "indexOf-2"); test(Ts[0].indexOf(_factory.makeInt(0), 0) == 0, "indexOf-3"); test(Ts[0].indexOf(_factory.makeInt(5), 0) == 5, "indexOf-4"); test(Ts[0].lastIndexOf(_factory.makeInt(1), -1) == 9, "lastIndexOf-1"); test(Ts[0].lastIndexOf(_factory.makeInt(0), -1) == 0, "lastIndexOf-2"); test(Ts[0].lastIndexOf(_factory.makeInt(10), -1) == -1, "lastIndexOf-3"); test(Ts[2].concat(Ts[3]).equals(Ts[4]), "concat-1"); test(Ts[0].concat(Ts[1]).equals(Ts[0]), "concat-2"); test(Ts[4].append(_factory.makeInt(7)).equals(Ts[5]), "append-1"); Ts[7] = Ts[3].insert(_factory.parse("3")); Ts[7] = Ts[7].insert(_factory.parse("2")); Ts[7] = Ts[7].insert(_factory.parse("1")); test(Ts[7].equals(Ts[4]), "insert-1"); test(Ts[1].insert(_factory.parse("1")).equals(_factory.parse("[1]")), "insert-2"); test(Ts[4].insertAt(_factory.parse("7"), Ts[4].getLength()).equals(Ts[5]), "insert-3"); test(Ts[5].getPrefix().equals(Ts[4]), "prefix-1"); test(Ts[5].getLast().equals(_factory.parse("7")), "last-1");
private boolean addRoleChainTransition(final TransitionGraph<Role> tg, final Role s, final ATermList chain) { final Role firstRole = _rbox.getRole(chain.getFirst()); final Role lastRole = _rbox.getRole(chain.getLast()); final boolean firstRoleSame = s.isEquivalent(firstRole); final boolean lastRoleSame = s.isEquivalent(lastRole); final int length = chain.getLength(); if (firstRoleSame) { if (lastRoleSame && length != 2) return false; addRoleChainTransition(tg, tg.getFinalState(), tg.getFinalState(), chain.getNext(), length - 1); } else if (lastRoleSame) addRoleChainTransition(tg, tg.getInitialState(), tg.getInitialState(), chain, length - 1); else addRoleChainTransition(tg, tg.getInitialState(), tg.getFinalState(), chain, length); return true; }
/** * Filter non-primes * * @param numbers * @return List of primes. */ private ATermList filterNonPrimes(final ATermList listOfnumbers) { ATermList numbers = listOfnumbers; ATermList primes = _factory.makeList(); numbers = numbers.getNext(); while (!numbers.isEmpty()) { final ATermInt prime = (ATermInt) numbers.getFirst(); numbers = filterMultiples(prime.getInt(), numbers); primes = primes.append(prime); } return _factory.makeList(_factory.makeInt(1), primes); }
static public ATermList toSet(final ATermList list) { if (isSet(list)) return list; final int size = list.getLength(); ATerm[] a = toArray(list); if (a == null || a.length < size) a = new ATerm[Math.max(100, size)]; Arrays.sort(a, 0, size, Comparators.termComparator); ATermList set = makeList(a[size - 1]); for (int i = size - 2; i >= 0; i--) { final ATerm s = set.getFirst(); if (!s.equals(a[i])) set = set.insert(a[i]); } return set; }
public static ATermList makeList(final Collection<ATermAppl> set) { ATermList list = EMPTY_LIST; for (final ATerm term : set) list = list.insert(term); return list; }
@Override public ATermList dictPut(final ATerm key, final ATerm value) { if (isEmpty()) { final ATermList pair = getEmpty().insert(value).insert(key); return getEmpty().insert(pair); } ATermList pair = (ATermList) _first; if (key.equals(pair.getFirst())) { pair = getEmpty().insert(value).insert(pair); return _next.insert(pair); } return _next.dictPut(key, value).insert(_first); }
@Override public ATermList dictRemove(final ATerm key) { if (isEmpty()) return this; final ATermList pair = (ATermList) _first; if (key.equals(pair.getFirst())) return _next; return _next.dictRemove(key).insert(_first); }