src/lemon/radix_heap.h
changeset 1247 60708e1475ae
parent 1186 448f76e44b24
child 1331 7e93d3f0406d
equal deleted inserted replaced
0:65141259f0d0 1:afb2b1bba40b
    28 namespace lemon {
    28 namespace lemon {
    29 
    29 
    30   /// \addtogroup auxdat
    30   /// \addtogroup auxdat
    31   /// @{
    31   /// @{
    32 
    32 
    33    /// A Binary Heap implementation.
    33   /// A Radix Heap implementation.
    34   
    34   
    35   ///\todo Please document...
    35   ///\todo Please document...
    36   ///
    36   ///
    37   ///\sa BinHeap
    37   ///\sa BinHeap
    38   ///\sa Dijkstra
    38   ///\sa Dijkstra
   154       boxes.push_back(RadixBox(min, size));
   154       boxes.push_back(RadixBox(min, size));
   155     }
   155     }
   156 
   156 
   157     /// \brief Move an item up into the proper box.
   157     /// \brief Move an item up into the proper box.
   158     void bubble_up(int index) {
   158     void bubble_up(int index) {
   159       if (!lower(data[index].box, index)) return;
   159       if (!lower(data[index].box, data[index].prio)) return;
   160       remove(index);
   160       remove(index);
   161       int box = findUp(data[index].box, data[index].prio);
   161       int box = findUp(data[index].box, data[index].prio);
   162       insert(box, index);      
   162       insert(box, index);      
   163     }
   163     }
   164 
   164 
   332       int s = iim[i];
   332       int s = iim[i];
   333       if( s >= 0 ) s = 0;
   333       if( s >= 0 ) s = 0;
   334       return state_enum(s);
   334       return state_enum(s);
   335     }
   335     }
   336 
   336 
   337     void print() const {
   337 //     void print() const {
   338       for (int i = 0; i < boxes.size(); ++i) {
   338 //       for (int i = 0; i < boxes.size(); ++i) {
   339 	printf("(%d, %d) ", boxes[i].min, boxes[i].size);
   339 // 	printf("(%d, %d) ", boxes[i].min, boxes[i].size);
   340 	for (int k = boxes[i].first; k != -1; k = data[k].next) {
   340 // 	for (int k = boxes[i].first; k != -1; k = data[k].next) {
   341 	  printf("%d ", data[k].prio);
   341 // 	  printf("%d ", data[k].prio);
   342 	}
   342 // 	}
   343 	printf("\n");
   343 // 	printf("\n");
   344       }
   344 //       }
   345       fflush(stdout);
   345 //       fflush(stdout);
   346     }
   346 //     }
   347 
   347 
   348   }; // class RadixHeap
   348   }; // class RadixHeap
   349 
   349 
   350 
   350 
   351   ///@}
   351   ///@}