xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] Reducing indexOf() to constant time
- From: Elliotte Harold <elharo AT metalab.unc.edu>
- To: Wolfgang Hoschek <whoschek AT lbl.gov>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] Reducing indexOf() to constant time
- Date: Tue, 25 Jan 2005 14:36:32 -0500
Wolfgang Hoschek wrote:
public int indexOf(Node child) {
if (children == null) return -1;
if (child.getParent() != this) return -1;
// if (child.isNamespace()) return -1; // ??? Not sure
This test is not strictly necessary for the same reason a call to isAttribute is not strictly necessary: it will never be a child of an element so the subsequent call to indexOf will return -1. If for some reason, we thought that lots of people were going to pass namespaces or attributes to this method, we could add this, but I doubt it's worth it. I'd rather not have the extra line of code for the much more common times when something that is a child is passed.
--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
-
[XOM-interest] Reducing indexOf() to constant time,
Wolfgang Hoschek, 01/25/2005
- Re: [XOM-interest] Reducing indexOf() to constant time, Elliotte Harold, 01/25/2005
-
Re: [XOM-interest] Reducing indexOf() to constant time,
Wolfgang Hoschek, 01/25/2005
- Re: [XOM-interest] Reducing indexOf() to constant time, Wolfgang Hoschek, 01/25/2005
- Re: [XOM-interest] Reducing indexOf() to constant time, Elliotte Harold, 01/25/2005
Archive powered by MHonArc 2.6.24.