예제 #1
0
UtlContainable* UtlHashMapIterator::value() const
{
   UtlContainable* currentValue = NULL;
   
   UtlContainer::acquireIteratorConnectionLock();
   OsLock take(const_cast<OsBSem&>(mContainerRefLock));
   UtlHashMap* myHashMap = dynamic_cast<UtlHashMap*>(mpMyContainer);
   if (myHashMap)
   {
      OsLock container(myHashMap->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      if (   (mPosition < myHashMap->numberOfBuckets())
          && (mpCurrentPair)
          && (mPairIsValid)
          )
      {
         currentValue = (  mpCurrentPair->value != UtlHashMap::INTERNAL_NULL
                         ? mpCurrentPair->value
                         : NULL
                         );
      }
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }   

   return currentValue;
}
예제 #2
0
UtlContainable* UtlHashMapIterator::key() const
{
   UtlContainable* currentKey = NULL;
   
   UtlContainer::acquireIteratorConnectionLock();
   OsLock take(const_cast<OsBSem&>(mContainerRefLock));
   UtlHashMap* myHashMap = dynamic_cast<UtlHashMap*>(mpMyContainer);
   if (myHashMap)
   {
      OsLock container(myHashMap->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      if (   (mPosition < myHashMap->numberOfBuckets())
          && (mpCurrentPair)
          && (mPairIsValid)
          )
      {
         currentKey = mpCurrentPair->data;
      }
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }   

   return currentKey;
}
예제 #3
0
UtlContainable* UtlHashMapIterator::operator()()
{
   UtlContainable* foundKey = NULL;

   UtlContainer::acquireIteratorConnectionLock();
   OsLock take(mContainerRefLock);
   UtlHashMap* myHashMap = dynamic_cast<UtlHashMap*>(mpMyContainer);
   if (myHashMap)
   {
      OsLock container(myHashMap->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      if (mPosition < myHashMap->numberOfBuckets())
      {
         UtlPair* pair;
         for ( pair = (  mpCurrentPair
                       ? static_cast<UtlPair*>(mpCurrentPair->UtlChain::next)
                       : static_cast<UtlPair*>(myHashMap->mpBucket[mPosition].listHead())
                       );
               !pair && ++mPosition < myHashMap->numberOfBuckets();
               pair = static_cast<UtlPair*>(myHashMap->mpBucket[mPosition].listHead())
              )
         {
         }

         if(pair)
         {
            mpCurrentPair = pair;
            foundKey = pair->data;
         }
      }
      else
      {
         // mPosition >= myHashMap->numberOfBuckets(), so we've run off the end of the entries.
         mpCurrentPair = NULL;
      }
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }   

   return foundKey;
}