예제 #1
0
UtlContainable* UtlSListIterator::insertAfterPoint(UtlContainable* insertedObject)
{
   UtlContainable*    result = NULL;

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

   if (myList)
   {
      OsLock take(myList->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      if (mpCurrentNode == UtlListIterator::OFF_LIST_END)
      {
         mpCurrentNode = UtlLink::listBefore(myList, NULL, insertedObject); /* append to tail */
      }
      else
      {
         UtlLink::listAfter(myList, mpCurrentNode, insertedObject);
      }

      result = insertedObject;
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }

   return result;
}
예제 #2
0
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;
}
예제 #3
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;
}