Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Reducing indexOf() to constant time

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • 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




Archive powered by MHonArc 2.6.24.

Top of Page