dbertoni    00/07/27 13:31:30

  Modified:    c/src/XPath MutableNodeRefList.cpp MutableNodeRefList.hpp
  Log:
  Added functionality to set nodes to null and remove them in-place.
  
  Revision  Changes    Path
  1.13      +37 -5     xml-xalan/c/src/XPath/MutableNodeRefList.cpp
  
  Index: MutableNodeRefList.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/MutableNodeRefList.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MutableNodeRefList.cpp    2000/07/21 19:50:02     1.12
  +++ MutableNodeRefList.cpp    2000/07/27 20:31:29     1.13
  @@ -59,8 +59,9 @@
   
   
   
  -#include <cassert>
   #include <algorithm>
  +#include <cassert>
  +#include <functional>
   
   
   
  @@ -236,10 +237,7 @@
   {
        assert(pos < getLength());
   
  -     if (theNode != 0)
  -     {
  -             m_nodeList[pos] = theNode;
  -     }
  +     m_nodeList[pos] = theNode;
   }
   
   
  @@ -364,6 +362,40 @@
                        }
                }
        }
  +}
  +
  +
  +
  +void
  +MutableNodeRefList::clearNulls()
  +{
  +#if !defined(XALAN_NO_NAMESPACES)
  +     using std::remove;
  +#endif
  +
  +     NodeListVectorType::iterator    i =
  +             m_nodeList.begin();
  +
  +     while(i != m_nodeList.end())
  +     {
  +             if (*i == 0)
  +             {
  +                     NodeListVectorType::iterator    j = i + 1;
  +
  +                     while(j != m_nodeList.end() && *j == 0)
  +                     {
  +                             ++j;
  +                     }
  +
  +                     i = m_nodeList.erase(i, j);
  +             }
  +             else
  +             {
  +                     ++i;
  +             }
  +     }
  +
  +     assert(checkForDuplicates() == false);
   }
   
   
  
  
  
  1.9       +6 -0      xml-xalan/c/src/XPath/MutableNodeRefList.hpp
  
  Index: MutableNodeRefList.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/MutableNodeRefList.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MutableNodeRefList.hpp    2000/07/21 19:50:02     1.8
  +++ MutableNodeRefList.hpp    2000/07/27 20:31:29     1.9
  @@ -215,6 +215,12 @@
                        XalanNode*      node,
                        bool            test);
   
  +     /**
  +      * Clear any null entrees in the node list.
  +      */
  +     virtual void
  +     clearNulls();
  +
        virtual XPathSupport*
        getSupport() const;
   
  
  
  

Reply via email to