UtlContainable* UtlSListIterator::peekAtNext(void)
{
   UtlContainable* match = NULL;

   UtlContainer::acquireIteratorConnectionLock();
   OsLock takeContainer(mContainerRefLock);
   UtlSList* myList = dynamic_cast<UtlSList*>(mpMyContainer);

   if (myList != NULL) // list still valid?
   {
      OsLock take(myList->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      // advance the iterator
      UtlLink* nextLink = (mpCurrentNode == NULL
                           ? myList->head()
                           : mpCurrentNode->next()
                           );
      if( nextLink )
      {
         match = (UtlContainable*)nextLink->data;
      }
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }

   return match;
}
Example #2
0
// Find the next like-instance of the designated object .
UtlContainable* UtlSListIterator::findNext(const UtlContainable* containableToMatch) 
{
   UtlContainable* match = NULL;

   UtlContainer::acquireIteratorConnectionLock();
   OsLock takeContainer(mContainerRefLock);
   UtlSList* myList = static_cast<UtlSList*>(mpMyContainer);
   
   OsLock take(myList->mContainerLock);
   UtlContainer::releaseIteratorConnectionLock();

   // advance the iterator
   UtlLink* nextLink = (mpCurrentNode == NULL
                        ? myList->head()
                        : mpCurrentNode->next()
                        );

   // search for the next match forward
   while (nextLink && !match)
   {
      UtlContainable *candidate = (UtlContainable*)nextLink->data;
      if (candidate && candidate->compareTo(containableToMatch) == 0)
      {
         mpCurrentNode = nextLink;
         match = candidate;
      }
      else
      {
         nextLink = nextLink->next();
      }
   }
   
   return match;
}