1struct::prioqueue(n) Tcl Data Structures struct::prioqueue(n)
2
3
4
5______________________________________________________________________________
6
8 struct::prioqueue - Create and manipulate prioqueue objects
9
11 package require Tcl 8.2
12
13 package require struct::prioqueue ?1.3?
14
15 ::struct::prioqueue ?-ascii|-dictionary|-integer|-real? ?prioqueueName?
16
17 prioqueueName option ?arg arg ...?
18
19 prioqueueName clear
20
21 prioqueueName destroy
22
23 prioqueueName get ?count?
24
25 prioqueueName peek ?count?
26
27 prioqueueName peekpriority ?count?
28
29 prioqueueName put item prio ?item prio ...?
30
31 prioqueueName size
32
33_________________________________________________________________
34
36 This package implements a simple priority queue using nested tcl lists.
37
38 The command ::struct::prioqueue creates a new priority queue with
39 default priority key type -integer. This means that keys given to the
40 put subcommand must have this type.
41
42 This also sets the priority ordering. For key types -ascii and -dictio‐
43 nary the data is sorted in ascending order (as with lsort -increasing),
44 thereas for -integer and -real the data is sorted in descending order
45 (as with lsort -decreasing).
46
47 Prioqueue names are unrestricted, but may be recognized as options if
48 no priority type is given.
49
50 ::struct::prioqueue ?-ascii|-dictionary|-integer|-real? ?prioqueueName?
51 The ::struct::prioqueue command creates a new prioqueue object
52 with an associated global Tcl command whose name is prioqueue‐
53 Name. This command may be used to invoke various operations on
54 the prioqueue. It has the following general form:
55
56 prioqueueName option ?arg arg ...?
57 option and the args determine the exact behavior of the command.
58 The following commands are possible for prioqueue objects:
59
60 prioqueueName clear
61 Remove all items from the prioqueue.
62
63 prioqueueName destroy
64 Destroy the prioqueue, including its storage space and associ‐
65 ated command.
66
67 prioqueueName get ?count?
68 Return the front count items of the prioqueue (but not their
69 priorities) and remove them from the prioqueue. If count is not
70 specified, it defaults to 1. If count is 1, the result is a
71 simple string; otherwise, it is a list. If specified, count
72 must be greater than or equal to 1. If there are no or too few
73 items in the prioqueue, this command will throw an error.
74
75 prioqueueName peek ?count?
76 Return the front count items of the prioqueue (but not their
77 priorities), without removing them from the prioqueue. If count
78 is not specified, it defaults to 1. If count is 1, the result
79 is a simple string; otherwise, it is a list. If specified,
80 count must be greater than or equal to 1. If there are no or
81 too few items in the queue, this command will throw an error.
82
83 prioqueueName peekpriority ?count?
84 Return the front count items priority keys, without removing
85 them from the prioqueue. If count is not specified, it defaults
86 to 1. If count is 1, the result is a simple string; otherwise,
87 it is a list. If specified, count must be greater than or equal
88 to 1. If there are no or too few items in the queue, this com‐
89 mand will throw an error.
90
91 prioqueueName put item prio ?item prio ...?
92 Put the item or items specified into the prioqueue. prio must be
93 a valid priority key for this type of prioqueue, otherwise an
94 error is thrown and no item is added. Items are inserted at
95 their priority ranking. Items with equal priority are added in
96 the order they were added.
97
98 prioqueueName size
99 Return the number of items in the prioqueue.
100
102 ordered list, prioqueue, priority queue
103
105 Copyright (c) 2003 Michael Schlenker <mic42@users.sourceforge.net>
106
107
108
109
110struct 1.3 struct::prioqueue(n)