struct::prioqueue(n)
π struct::prioqueue(n) β the Tcl Data Structures manual, but make it a group chat π
okay bestie, sit down, hydrate, because we're about to talk about priority queues and honestly? it's giving main character energy. this is the struct::prioqueue page from the Tcl Data Structures manual set, and by the end of it you're gonna be putting items in priority order like it's nothing. no cap. π
β¨ NAME β¨
struct::prioqueue β create and manipulate prioqueue objects. that's it, that's the name, and it's iconic. π¦
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require struct::prioqueue ?1.5?
::struct::prioqueue ?-ascii|-dictionary|-integer|-real? ?prioqueueName?
prioqueueName option ?arg arg ...?
prioqueueName clear
prioqueueName remove item
prioqueueName destroy
prioqueueName get ?count?
prioqueueName peek ?count?
prioqueueName peekpriority ?count?
prioqueueName put item prio ?item prio ...?
prioqueueName size
likeβ¦ look at that. every single one of those is a real thing you can do. we're so blessed. ππ
π DESCRIPTION π
so this package implements a simple priority queue using nested tcl lists. simple! elegant! lowkey genius! π
the command ::struct::prioqueue creates a brand new priority queue, and the default priority key type is -integer. which means, bestie, that the keys you hand over to the put subcommand have to be that type. no exceptions, she's strict. β¨
that same key type also sets your priority ordering, and here's the tea π:
- for key types
-asciiand-dictionary, the data is sorted in ascending order (exactly likelsort -increasing) - for
-integerand-real, the data is sorted in descending order (exactly likelsort -decreasing)
prioqueue names are unrestricted, but heads up β they may be recognized as options if no priority type is given. yes, that's a real vibe check moment, watch out for it. π
π the commands, one by one, no skips π
::struct::prioqueue ?-ascii|-dictionary|-integer|-real? ?prioqueueName?β this creates a new prioqueue object with an associated global Tcl command whose name isprioqueueName. that command is your girl β you use her to invoke all the various operations on the prioqueue. general form below, obviously:
prioqueueName option ?arg arg ...?
prioqueueName option ?arg arg ...?β hereoptionand the args decide the exact behavior of the command. the possible commands for prioqueue objects are the ones listed right below. periodt. πprioqueueName clearβ removes all items from the prioqueue. clean slate, fresh start, therapy basically. π§ΉprioqueueName remove itemβ removes the selected item from this priority queue. just that one. targeted. π―prioqueueName destroyβ destroys the prioqueue, including its storage space and its associated command. like, gone gone. πprioqueueName get ?count?β returns the frontcountitems of the prioqueue (but not their priorities) and removes them from the prioqueue. ifcountisn't specified it defaults to1. ifcountis1, the result is a simple string; otherwise it's a list. if specified,countmust be greater than or equal to1. and if there are no items, or too few items, in the prioqueue, this command will throw an error. so be normal about it. πprioqueueName peek ?count?β same energy asgetbut she doesn't remove anything β returns the frontcountitems (again, not their priorities) and leaves them right where they are.countdefaults to1.countof1gives you a simple string; otherwise you get a list. if specified,countmust be greater than or equal to1. no items or too few items? error. peek with your eyes only, bestie. πprioqueueName peekpriority ?count?β returns the frontcountitems' priority keys, without removing them from the prioqueue.countdefaults to1, and acountof1gives a simple string, otherwise a list. if specified,countmust be greater than or equal to1. no items or too few items in the queue β error. yes this is the one that shows you the receipts. π§ΎprioqueueName put item prio ?item prio ...?β puts the item or items you specify into the prioqueue.priomust be a valid priority key for this type of prioqueue β otherwise an error is thrown and no item is added, so nothing gets half-done, we love a clean fail. items are inserted at their priority ranking, and items with equal priority are added in the order they were added. first come first served among the equals, no cutting the line. πΆβοΈπΆβοΈπΆβοΈprioqueueName sizeβ returns the number of items in the prioqueue. a number. that's the whole thing. still important. π
π«Ά BUGS, IDEAS, FEEDBACK π«Ά
ngl, this document, and the package it describes, will undoubtedly contain bugs and other problems. it's not a read, it's a reality. π
please report such things in the category struct :: prioqueue of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist].
and please also report any ideas for enhancements you may have for either the package and/or the documentation. we want the glow-up ideas. β¨
when proposing code changes, please provide unified diffs, i.e. the output of diff -u.
note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. iykyk. π
β KEYWORDS β
- ordered list
- prioqueue
- priority queue
π¦ CATEGORY π¦
Data structures
π COPYRIGHT π
Copyright (c) 2003 Michael Schlenker <mic42@users.sourceforge.net>
and that's the whole page, bestie β brought to you by tcllib, version 1.5, in the struct::prioqueue(n) manual. go forth, put things in priority order, and slay. π
β¨πΈ
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2003 Michael Schlenker <mic42@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms