1struct::prioqueue(n)          Tcl Data Structures         struct::prioqueue(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       struct::prioqueue - Create and manipulate prioqueue objects
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require struct::prioqueue  ?1.4?
14
15       ::struct::prioqueue ?-ascii|-dictionary|-integer|-real? ?prioqueueName?
16
17       prioqueueName option ?arg arg ...?
18
19       prioqueueName clear
20
21       prioqueueName remove item
22
23       prioqueueName destroy
24
25       prioqueueName get ?count?
26
27       prioqueueName peek ?count?
28
29       prioqueueName peekpriority ?count?
30
31       prioqueueName put item prio ?item prio ...?
32
33       prioqueueName size
34
35______________________________________________________________________________
36

DESCRIPTION

38       This package implements a simple priority queue using nested tcl lists.
39
40       The  command  ::struct::prioqueue creates a new priority queue with de‐
41       fault priority key type -integer. This means that keys given to the put
42       subcommand must have this type.
43
44       This also sets the priority ordering. For key types -ascii and -dictio‐
45       nary the data is sorted in ascending order (as with lsort -increasing),
46       thereas  for  -integer and -real the data is sorted in descending order
47       (as with lsort -decreasing).
48
49       Prioqueue names are unrestricted, but may be recognized as  options  if
50       no priority type is given.
51
52       ::struct::prioqueue ?-ascii|-dictionary|-integer|-real? ?prioqueueName?
53              The  ::struct::prioqueue  command creates a new prioqueue object
54              with an associated global Tcl command whose name  is  prioqueue‐
55              Name.  This  command may be used to invoke various operations on
56              the prioqueue.  It has the following general form:
57
58       prioqueueName option ?arg arg ...?
59              option and the args determine the exact behavior of the command.
60              The following commands are possible for prioqueue objects:
61
62       prioqueueName clear
63              Remove all items from the prioqueue.
64
65       prioqueueName remove item
66              Remove the selected item from this priority queue.
67
68       prioqueueName destroy
69              Destroy  the  prioqueue, including its storage space and associ‐
70              ated command.
71
72       prioqueueName get ?count?
73              Return the front count items of the  prioqueue  (but  not  their
74              priorities) and remove them from the prioqueue.  If count is not
75              specified, it defaults to 1.  If count is 1,  the  result  is  a
76              simple  string;  otherwise,  it  is a list.  If specified, count
77              must be greater than or equal to 1.  If there are no or too  few
78              items in the prioqueue, this command will throw an error.
79
80       prioqueueName peek ?count?
81              Return  the  front  count  items of the prioqueue (but not their
82              priorities), without removing them from the prioqueue.  If count
83              is  not  specified, it defaults to 1.  If count is 1, the result
84              is a simple string; otherwise, it  is  a  list.   If  specified,
85              count  must  be  greater than or equal to 1.  If there are no or
86              too few items in the queue, this command will throw an error.
87
88       prioqueueName peekpriority ?count?
89              Return the front count items  priority  keys,  without  removing
90              them from the prioqueue.  If count is not specified, it defaults
91              to 1.  If count is 1, the result is a simple string;  otherwise,
92              it is a list.  If specified, count must be greater than or equal
93              to 1.  If there are no or too few items in the queue, this  com‐
94              mand will throw an error.
95
96       prioqueueName put item prio ?item prio ...?
97              Put the item or items specified into the prioqueue. prio must be
98              a valid priority key for this type of  prioqueue,  otherwise  an
99              error  is  thrown  and  no item is added.  Items are inserted at
100              their priority ranking. Items with equal priority are  added  in
101              the order they were added.
102
103       prioqueueName size
104              Return the number of items in the prioqueue.
105

BUGS, IDEAS, FEEDBACK

107       This  document,  and the package it describes, will undoubtedly contain
108       bugs and other problems.  Please report such in the category struct  ::
109       prioqueue   of   the   Tcllib  Trackers  [http://core.tcl.tk/tcllib/re
110       portlist].  Please also report any ideas for enhancements you may  have
111       for either package and/or documentation.
112
113       When proposing code changes, please provide unified diffs, i.e the out‐
114       put of diff -u.
115
116       Note further that  attachments  are  strongly  preferred  over  inlined
117       patches.  Attachments  can  be  made  by  going to the Edit form of the
118       ticket immediately after its creation, and  then  using  the  left-most
119       button in the secondary navigation bar.
120

KEYWORDS

122       ordered list, prioqueue, priority queue
123

CATEGORY

125       Data structures
126
128       Copyright (c) 2003 Michael Schlenker <mic42@users.sourceforge.net>
129
130
131
132
133tcllib                                1.4                 struct::prioqueue(n)
Impressum