Version 8 of prioqueue

Updated 2006-01-10 02:02:55

Documentation is at http://tcllib.sourceforge.net/doc/prioqueue.html

   This part of the [struct] (data structures) submodule of [tcllib]
   provides a prioritized queue.

Simple usage example:

 package require struct 1.3
 # create a prioqueue with integer priorities
 set pq [::struct::prioqueue -integer]

 # get some random things an put them in the queue
 for {set i 0} {$i < 100} {incr i} {
    $pq put item$i [expr {int(rand()*500)}]
 }

 # Iterate over the queue and output the items in priority order
 # To process the whole queue in one step better use:
 # foreach item [$pq get [$pq size]] { ... } 
 while {[$pq size]} {
    puts stdout [$pq get]
 }

 # destroy the queue after use
 $pq destroy

Ken: Is there a way to change the priority to only retrieve the smallest number in the queue instead of the largest number


Category Package; see struct - Tcllib | Category Data Structure