xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mor...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/dom DupFilterIterator.java
Date Wed, 26 Sep 2001 13:26:25 GMT
morten      01/09/26 06:26:25

  Modified:    java/src/org/apache/xalan/xsltc/dom DupFilterIterator.java
  Log:
  Modified the DupFilterIterator so that it also orders nodes.
  PR:		bugzilla 3466
  Obtained from:	n/a
  Submitted by:	morten@xml.apache.org
  Reviewed by:	morten@xml.apache.org
  
  Revision  Changes    Path
  1.8       +20 -18    xml-xalan/java/src/org/apache/xalan/xsltc/dom/DupFilterIterator.java
  
  Index: DupFilterIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DupFilterIterator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DupFilterIterator.java	2001/09/19 15:53:42	1.7
  +++ DupFilterIterator.java	2001/09/26 13:26:25	1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DupFilterIterator.java,v 1.7 2001/09/19 15:53:42 morten Exp $
  + * @(#)$Id: DupFilterIterator.java,v 1.8 2001/09/26 13:26:25 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -107,6 +107,9 @@
        * @return A reference to this node iterator
        */
       public NodeIterator setStartNode(int node) {
  +
  +	int i, j; // loop variables declared first for speed - don't move!!!
  +
   	// KeyIndex iterators are always relative to the root node, so there
   	// is never any point in re-reading the iterator (and we SHOULD NOT).
   	if ((_source instanceof KeyIndex) && (_data != null)) return this;
  @@ -127,28 +130,27 @@
   		    System.arraycopy(_data, 0, newArray, 0, _last);
   		    _data = newArray;
   		}
  -		if (!isDup(node)) _data[_last++] = node;
  +
  +		// Go through all nodes in turn
  +		for (i=0; i<_last; i++) {
  +		    // Is this a duplicate of the new node
  +		    if (_data[i] == node) {
  +			break;
  +		    }
  +		    // Should the new node be inserted at this position?
  +		    else if (_data[i] > node) {
  +			for (j = _last++; j>i; j--)
  +			    _data[j] = _data[j-1];
  +			_data[i] = node;
  +			break;
  +		    }
  +		}
  +		if (i == _last) _data[_last++] = node;
   	    }
   	}
   
   	_current = 0;  // set to beginning 
   	return this;
  -    }
  -
  -    /**
  -     * Check if a node is already in the _data array. The nodes should be in
  -     * document order or reverse document order, so we may be able to use
  -     * binary search here.
  -     */
  -    private boolean isDup(int node) {
  -	boolean retval = false;
  -	int size = _data.length;
  -	for (int i=0; i<size; i++) {
  -	    if (_data[i] == node) {
  -		retval = true; break;
  -	    }
  -	}
  -	return retval;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message