Esempio n. 1
0
ListElement *List::erase( ListElement *position )
{
   ListElement *ret = position->next();
   if( position == m_head )
   {
      // could be 0 if m_head == m_tail
      m_head = ret;
      if ( ret != 0 )
      {
         ret->prev(0);
      }
      else
         m_tail = 0;
   }
   else if ( position == m_tail )
   {
      // here, ret is 0 for sure.
      m_tail = position->prev();
      m_tail->next(0);
   }
   else {
      // normal case
      position->prev()->next( ret );
      ret->prev( position->prev() );
   }

   if( m_deletor != 0 )
      m_deletor( (void *) position->data() );

   m_size--;
   memFree( position );
   return ret;
}
Esempio n. 2
0
void List::pushBack( const void *data )
{
   ListElement *element = (ListElement *) memAlloc( sizeof( ListElement ) );
   element->data( data );

   if ( m_head == 0 )
   {
      m_head = m_tail = element;
      element->prev(0);
   }
   else {
      element->prev( m_tail );
      m_tail->next( element );
      m_tail = element;
   }

   m_size++;
   element->next( 0 );
}
Esempio n. 3
0
void List::insertBefore( ListElement *position, const void *data )
{
   ListElement *element = (ListElement *) memAlloc( sizeof( ListElement ) );
   element->data( data );

   element->next( position );
   element->prev( position->prev() );
   if( position->prev() != 0 )
   {
      position->prev()->next( element );
   }

   position->prev( element );

   m_size++;
   if ( position == m_head )
      m_head = element;
}
Esempio n. 4
0
void List::pushFront( uint32 data )
{
   ListElement *element = (ListElement *) memAlloc( sizeof( ListElement ) );
   element->iData( data );

   if ( m_head == 0 )
   {
      m_head = m_tail = element;
      element->next(0);
   }
   else {
      element->next( m_head );
      m_head->prev( element );
      m_head = element;
   }

   m_size++;
   element->prev( 0 );
}