public NodeSet selectParentChild(NodeSet al, int mode, boolean rememberContext) { if (!(al instanceof VirtualNodeSet) && al.getLength() == 1) { return hasChildrenInSet(al.get(0), mode, rememberContext); } NodeProxy n, p;  ExtArrayNodeSet result = new ExtArrayNodeSet(); DocumentImpl lastDoc = null; int sizeHint = -1; switch (mode) { case NodeSet.DESCENDANT : for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); if (lastDoc == null || n.doc != lastDoc) { lastDoc = n.doc; sizeHint = getSizeHint(lastDoc); } if ((p = al.parentWithChild(n.doc, n.gid, true, false, -1)) != null) { if (rememberContext) n.addContextNode(p); else n.copyContext(p); result.add(n, sizeHint); } } break; case NodeSet.ANCESTOR : for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next(); if (lastDoc == null || n.doc != lastDoc) { lastDoc = n.doc; sizeHint = al.getSizeHint(lastDoc); } if ((p = al.parentWithChild(n.doc, n.gid, true, false, -1)) != null) { if (rememberContext) p.addContextNode(n); else p.copyContext(n); result.add(p, sizeHint); } } break; }      result.sort(); return result;
public NodeSet selectParentChild(NodeSet al, int mode) { return selectParentChild(al, mode, false);
	public NodeSet selectParentChild(NodeSet al, int mode, boolean rememberContext) {		if (!(al instanceof VirtualNodeSet) && al.getLength() == 1) {			return hasChildrenInSet(al.get(0), mode, rememberContext);		}		NodeProxy n, p;		//		long start = System.currentTimeMillis();		ExtArrayNodeSet result = new ExtArrayNodeSet();		DocumentImpl lastDoc = null;		int sizeHint = -1;		switch (mode) {			case NodeSet.DESCENDANT :				for (Iterator i = iterator(); i.hasNext();) {					n = (NodeProxy) i.next();					if (lastDoc == null || n.doc != lastDoc) {						lastDoc = n.doc;						sizeHint = getSizeHint(lastDoc);					}					if ((p = al.parentWithChild(n.doc, n.gid, true, false, -1))						!= null) {						if (rememberContext)							n.addContextNode(p);						else							n.copyContext(p);						result.add(n, sizeHint);					}				}				break;			case NodeSet.ANCESTOR :				for (Iterator i = iterator(); i.hasNext();) {					n = (NodeProxy) i.next();					if (lastDoc == null || n.doc != lastDoc) {						lastDoc = n.doc;						sizeHint = al.getSizeHint(lastDoc);					}					if ((p = al.parentWithChild(n.doc, n.gid, true, false, -1))						!= null) {						if (rememberContext)							p.addContextNode(n);						else							p.copyContext(n);						result.add(p, sizeHint);					}				}				break;		}		//				LOG.debug(		//					"getChildren found "		//						+ result.getLength()		//						+ " in "		//						+ (System.currentTimeMillis() - start));		result.sort();		return result;	}