list_pq.h
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:2k
开发平台:

MultiPlatform

  1. /*******************************************************************************
  2. +
  3. +  LEDA-R  3.2.3
  4. +
  5. +  list_pq.h
  6. +
  7. +  Copyright (c) 1995  by  Max-Planck-Institut fuer Informatik
  8. +  Im Stadtwald, 66123 Saarbruecken, Germany     
  9. +  All rights reserved.
  10. *******************************************************************************/
  11. #include <LEDA/basic.h>
  12. class list_pq_elem
  13. {
  14.   friend class list_pq;
  15.   GenPtr key;
  16.   GenPtr inf;
  17.   list_pq_elem* succ;
  18.   list_pq_elem* pred;
  19.   list_pq_elem(GenPtr k, GenPtr i, list_pq_elem* p, list_pq_elem* s) 
  20.   { key = k; 
  21.     inf = i; 
  22.     pred = p;
  23.     succ = s;
  24.    }
  25.   LEDA_MEMORY(list_pq_elem)
  26. };
  27. #define PRIO_IMPL      list_pq
  28. #define PRIO_IMPL_ITEM list_pq_item
  29. typedef list_pq_elem* list_pq_item;
  30. #define PRIO_IMPL_DATA list_pq_item head;
  31.                        int          count;
  32. #include <LEDA/impl/prio_impl.h>
  33. inline list_pq::list_pq()    { head = nil; count = 0; }
  34. inline list_pq::list_pq(int) { error_handler(1,"no list_pq(int) constructor");}
  35. inline list_pq::list_pq(int,int) { error_handler(1,"no list_pq(int,int) constructor");}
  36. inline list_pq::~list_pq() { clear(); }
  37. inline list_pq_item list_pq::first_item()              const { return head;   }
  38. inline list_pq_item list_pq::next_item(list_pq_item x) const { return x->succ;}
  39. inline GenPtr list_pq::key(list_pq_item it) const { return it->key; }
  40. inline GenPtr list_pq::inf(list_pq_item it) const { return it->inf; }
  41. inline void list_pq::del_min()  { del_item(find_min());   }
  42. inline void list_pq::decrease_key(list_pq_item it, GenPtr x)  
  43. { copy_key(x);
  44.   clear_key(it->key);
  45.   it->key = x; 
  46.  }
  47. inline void list_pq::change_inf(list_pq_item it, GenPtr y)
  48. { copy_inf(y);
  49.   clear_inf(it->inf);
  50.   it->inf = y; 
  51.  }
  52. inline int  list_pq::size()  const  { return count; }