peiyongz    2003/11/03 14:00:31

  Modified:    c/src/xercesc/util RefHash3KeysIdPool.c
                        RefHash3KeysIdPool.hpp
  Log:
  RefHashTable-like enumeration accessing added
  
  Revision  Changes    Path
  1.8       +78 -0     xml-xerces/c/src/xercesc/util/RefHash3KeysIdPool.c
  
  Index: RefHash3KeysIdPool.c
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/RefHash3KeysIdPool.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RefHash3KeysIdPool.c      29 Oct 2003 16:18:05 -0000      1.7
  +++ RefHash3KeysIdPool.c      3 Nov 2003 22:00:31 -0000       1.8
  @@ -56,6 +56,9 @@
   
   /**
    * $Log$
  + * Revision 1.8  2003/11/03 22:00:31  peiyongz
  + * RefHashTable-like enumeration accessing added
  + *
    * Revision 1.7  2003/10/29 16:18:05  peiyongz
    * size() added and Reset() bug fixed
    *
  @@ -447,6 +450,7 @@
           ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero);
   
       Reset();
  +    resetKey();
   }
   
   template <class TVal> 
RefHash3KeysIdPoolEnumerator<TVal>::~RefHash3KeysIdPoolEnumerator()
  @@ -492,6 +496,80 @@
   template <class TVal> int RefHash3KeysIdPoolEnumerator<TVal>::size() const
   {
       return fToEnum->fIdCounter;
  +}
  +
  +template <class TVal> void RefHash3KeysIdPoolEnumerator<TVal>::resetKey()
  +{
  +    fCurHash = (unsigned int)-1;
  +    fCurElem = 0;
  +    findNext();
  +}
  +
  +template <class TVal> bool RefHash3KeysIdPoolEnumerator<TVal>::hasMoreKeys() const
  +{
  +    //
  +    //  If our current has is at the max and there are no more elements
  +    //  in the current bucket, then no more elements.
  +    //
  +    if (!fCurElem && (fCurHash == fToEnum->fHashModulus))
  +        return false;
  +
  +    return true;
  +}
  +
  +template <class TVal> void 
RefHash3KeysIdPoolEnumerator<TVal>::nextElementKey(void*& retKey1, int& retKey2, int& 
retKey3)
  +{
  +    // Make sure we have an element to return
  +    if (!hasMoreKeys())
  +        ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements);
  +
  +    //
  +    //  Save the current element, then move up to the next one for the
  +    //  next time around.
  +    //
  +    RefHash3KeysTableBucketElem<TVal>* saveElem = fCurElem;
  +    findNext();
  +
  +    retKey1 = saveElem->fKey1;
  +    retKey2 = saveElem->fKey2;
  +    retKey3 = saveElem->fKey3;
  +
  +    return;
  +}
  +
  +template <class TVal> void RefHash3KeysIdPoolEnumerator<TVal>::findNext()
  +{
  +    //
  +    //  If there is a current element, move to its next element. If this
  +    //  hits the end of the bucket, the next block will handle the rest.
  +    //
  +    if (fCurElem)
  +        fCurElem = fCurElem->fNext;
  +
  +    //
  +    //  If the current element is null, then we have to move up to the
  +    //  next hash value. If that is the hash modulus, then we cannot
  +    //  go further.
  +    //
  +    if (!fCurElem)
  +    {
  +        fCurHash++;
  +        if (fCurHash == fToEnum->fHashModulus)
  +            return;
  +
  +        // Else find the next non-empty bucket
  +        while (true)
  +        {
  +            if (fToEnum->fBucketList[fCurHash])
  +                break;
  +
  +            // Bump to the next hash value. If we max out return
  +            fCurHash++;
  +            if (fCurHash == fToEnum->fHashModulus)
  +                return;
  +        }
  +        fCurElem = fToEnum->fBucketList[fCurHash];
  +    }
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.7       +19 -0     xml-xerces/c/src/xercesc/util/RefHash3KeysIdPool.hpp
  
  Index: RefHash3KeysIdPool.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/RefHash3KeysIdPool.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RefHash3KeysIdPool.hpp    29 Oct 2003 16:17:48 -0000      1.6
  +++ RefHash3KeysIdPool.hpp    3 Nov 2003 22:00:31 -0000       1.7
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.7  2003/11/03 22:00:31  peiyongz
  + * RefHashTable-like enumeration accessing added
  + *
    * Revision 1.6  2003/10/29 16:17:48  peiyongz
    * size() added
    *
  @@ -290,7 +293,20 @@
       void Reset();
       int  size() const;
   
  +    // -----------------------------------------------------------------------
  +    //  New interface 
  +    // -----------------------------------------------------------------------
  +    void resetKey();
  +    void nextElementKey(void*&, int&, int&);
  +    bool hasMoreKeys()   const;
  +
   private :
  +
  +    // -----------------------------------------------------------------------
  +    //  Private methods
  +    // -----------------------------------------------------------------------
  +    void findNext();
  +
       // -----------------------------------------------------------------------
       //  Data Members
       //  fAdoptedElems
  @@ -308,6 +324,9 @@
       bool                       fAdoptedElems;
       unsigned int               fCurIndex;
       RefHash3KeysIdPool<TVal>*  fToEnum;
  +
  +    RefHash3KeysTableBucketElem<TVal>*   fCurElem;
  +    unsigned int                         fCurHash;
   };
   
   XERCES_CPP_NAMESPACE_END
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to