public NodeSet selectAncestorDescendant( NodeSet al, int mode, boolean includeSelf, boolean rememberContext) { NodeProxy n, p;  DocumentImpl lastDoc = null; int sizeHint = -1; ExtArrayNodeSet result = new ExtArrayNodeSet(); switch (mode) { case 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, false, includeSelf, -1)) != null) { if (rememberContext) n.addContextNode(p); else n.copyContext(p); result.add(n, sizeHint); } } break; case ANCESTOR : for (Iterator i = iterator(); i.hasNext();) { n = (NodeProxy) i.next();  if (lastDoc == null || n.doc != lastDoc) { lastDoc = n.doc; sizeHint = al.getSizeHint(lastDoc); } p = al.parentWithChild(n.doc, n.gid, false, includeSelf, -1); if (p != null) { if (rememberContext) p.addContextNode(n); else p.copyContext(n); result.add(p, sizeHint); } } break; }       return result;
public NodeSet selectAncestorDescendant(NodeSet al, int mode) { return selectAncestorDescendant(al, mode, false);
	public NodeSet selectAncestorDescendant(		NodeSet al,		int mode,		boolean includeSelf,		boolean rememberContext) {		NodeProxy n, p;		//		long start = System.currentTimeMillis();		DocumentImpl lastDoc = null;		int sizeHint = -1;		ExtArrayNodeSet result = new ExtArrayNodeSet();		switch (mode) {			case DESCENDANT :				for (Iterator i = iterator(); i.hasNext();) {					n = (NodeProxy) i.next();					// get a size hint for every new document encountered					if (lastDoc == null || n.doc != lastDoc) {						lastDoc = n.doc;						sizeHint = getSizeHint(lastDoc);					}					if ((p = al.parentWithChild(n.doc, n.gid, false, includeSelf, -1))						!= null) {						if (rememberContext)							n.addContextNode(p);						else							n.copyContext(p);						result.add(n, sizeHint);					}				}				break;			case ANCESTOR :				for (Iterator i = iterator(); i.hasNext();) {					n = (NodeProxy) i.next();					// get a size hint for every new document encountered					if (lastDoc == null || n.doc != lastDoc) {						lastDoc = n.doc;						sizeHint = al.getSizeHint(lastDoc);					}					p = al.parentWithChild(n.doc, n.gid, false, includeSelf, -1);					if (p != null) {						if (rememberContext)							p.addContextNode(n);						else							p.copyContext(n);						result.add(p, sizeHint);					}				}				break;		}		//result.sort();		//				LOG.debug(		//					"getDescendants found "		//						+ result.getLength()		//						+ " in "		//						+ (System.currentTimeMillis() - start));		return result;	}