Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lists.hpp

    r266237 r46d958  
    99#define LISTS_HPP_
    1010
     11class atom;
     12
    1113/******************************** Some templates for list management ***********************************/
    1214
     
    1820{
    1921  X *vorher = end->previous;
    20   if (vorher != NULL)
     22  if (vorher != 0)
    2123    vorher->next = walker;
    2224  end->previous = walker;
     
    3133template <typename X> void unlink(X *walker)
    3234{
    33   if (walker->next != NULL)
     35  if (walker->next != 0)
    3436    walker->next->previous = walker->previous;
    35   if (walker->previous != NULL)
     37  if (walker->previous != 0)
    3638    walker->previous->next = walker->next;
    37   walker->next = NULL;
    38   walker->previous= NULL;
     39  walker->next = 0;
     40  walker->previous= 0;
    3941};
    4042
     
    4648template <typename X>  bool add(X *pointer, X *end)
    4749{
    48   if (end != NULL) {
     50  if (end != 0) {
    4951    link(pointer, end);
    5052  } else {
    51     pointer->previous = NULL;
    52     pointer->next = NULL;
     53    pointer->previous = 0;
     54    pointer->next = 0;
    5355  }
    5456  return true;
     
    5961 * \param *start  begin of list
    6062 * \param *end  end of list
    61  * \return X - if found, NULL - if not found
     63 * \return X - if found, 0 - if not found
    6264 */
    6365template <typename X, typename Y> X * find(Y *suche, X *start, X *end)
     
    6870    if (*walker->sort == *suche) return (walker);
    6971  }
    70   return NULL;
     72  return 0;
    7173};
    7274
     
    7779template <typename X> void removewithoutcheck(X *walker)
    7880{
    79   if (walker != NULL) {
     81  if (walker != 0) {
    8082    unlink(walker);
    8183    delete(walker);
    82     walker = NULL;
     84    walker = 0;
    8385  }
    8486};
     87
     88/** Removes an item from the list without check.
     89 *  specialized for atoms, because these have to be removed from the world as well
     90 *  the implementation for this declaration is in lists.cpp
     91 * \param *walker item to be removed
     92 * \return true - removing succeeded, false - given item not found in list
     93 */
     94template <> void removewithoutcheck<atom>(atom *walker);
    8595
    8696/** Removes an item from the list, checks if exists.
     
    99109  }*/
    100110  // atom found, now unlink
    101   if (walker != NULL)
     111  if (walker != 0)
    102112    removewithoutcheck(walker);
    103113  else
     
    114124{
    115125  X *pointer = start->next;
    116   X *walker = NULL;
     126  X *walker = 0;
    117127  while (pointer != end) { // go through list
    118128    walker = pointer; // mark current
     
    131141{
    132142  X *Binder = me;
    133   while(Binder->previous != NULL)
     143  while(Binder->previous != 0)
    134144    Binder = Binder->previous;
    135145  return Binder;
     
    143153{
    144154  X *Binder = me;
    145   while(Binder->next != NULL)
     155  while(Binder->next != 0)
    146156    Binder = Binder->next;
    147157  return Binder;
Note: See TracChangeset for help on using the changeset viewer.