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:34:22 -0500

Wolfgang Hoschek wrote:

Node.java:

private ParentNode parent = null;
int parentPosition = -1; // WH

ParentNode.java:

final void fastInsertChild(Node child, int position) {
if (children == null) children = new ArrayList(1);
if (position == children.size())
children.add(child);
else
children.add(position, child);
// children.add(position, child);
child.setParent(this);
child.parentPosition = position; // WH
}


Wouldn't this be required to update all subsequent nodes? i.e. when you insert a node in the middle of an element, you'd have to change the parent position of not just the inserted node but everything that follows it in its parents? or am I missing something here?

--
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