public static void triples(GNode gnode, Collection<Triple> acc) { if ( listEnd(gnode) ) return ; Triple t = null ; t = getTriple(gnode, CAR) ; if ( t != null ) acc.add(t) ; t = getTriple(gnode, CDR) ; if ( t != null ) acc.add(t) ; }
private static Node getNode(GNode gnode, Node arc) { if ( listEnd(gnode) ) return null ; Triple t = getTriple(gnode, arc) ; if ( t == null ) return null ; return t.getObject() ; }
public static int length(GNode gnode) { if ( ! isListNode(gnode) ) return -1 ; int len = 0 ; while ( ! listEnd(gnode) ) { len++ ; gnode = next(gnode) ; } return len ; }
private static Triple getTriple(GNode gnode, Node arc) { if ( listEnd(gnode) ) return null ; Iterator<Triple> iter = gnode.findable.find(gnode.node, arc, Node.ANY) ; if ( ! iter.hasNext() ) return null ; Triple t = iter.next() ; if ( iter.hasNext() ) Log.warn(GraphList.class, "Unusual list: two arcs with same property ("+arc+")") ; NiceIterator.close(iter) ; return t ; } }
public static void members(GNode gnode, final Collection<Node> acc) { if ( ! isListNode(gnode) ) return ; while( ! listEnd(gnode) ) { Node n = car(gnode) ; if ( n != null ) acc.add(n) ; gnode = next(gnode) ; } }
public static List<Integer> indexes(GNode gnode, Node value) { List<Integer> x = new ArrayList<>() ; if ( ! isListNode(gnode) ) return x ; int idx = 0 ; while ( ! listEnd(gnode) ) { Node v = car(gnode) ; if ( v != null && v.equals(value) ) x.add(new Integer(idx)) ; gnode = next(gnode) ; idx++ ; } return x ; }
public static void allTriples(GNode gnode, Collection<Triple> acc) { if ( ! isListNode(gnode) ) return ; while( ! listEnd(gnode) ) { triples(gnode, acc) ; gnode = next(gnode) ; } }
public static Node get(GNode gnode, int idx) { // if ( idx == 0 ) // return car(gnode) ; // Node n = next(gnode) ; // return get(graph, n, idx-1) ; if ( ! isListNode(gnode) ) return null ; while ( ! listEnd(gnode) ) { if ( idx == 0 ) return car(gnode) ; gnode = next(gnode) ; idx -- ; } return null ; }
public static int index(GNode gnode, Node value) { if ( ! isListNode(gnode) ) return -1 ; int idx = 0 ; while ( ! listEnd(gnode) ) { Node v = car(gnode) ; if ( v != null && v.equals(value) ) return idx ; gnode = next(gnode) ; idx++ ; } return -1 ; }