struct::map(n)
π struct::map β bestie's guide to key/value maps π
okay so this is struct::map(n), from tcllib. Sit down, grab a strawberry, we're doing data structures π
β¨ NAME β¨
struct::map β manage key/value maps. yes that's it, that's the whole vibe. a lil map. a lil dict-with-attitude. π
πΈ SYNOPSIS πΈ
package require struct::map ?1?
::struct::map mapName
mapName method ?arg arg ...?
mapName get
mapName names
mapName set name ?value?
mapName unset ?pattern...?
like. look at it. so clean. so organized. the way she just has a synopsis π
π¦ DESCRIPTION π¦
Okay bestie, here's the tea: this package gives you a snit class whose instances manage a key/value map. In other words β and I cannot stress this enough β it's an object wrapper around Tcl arrays. that's the whole thing. iconic behavior, no notes π
π API π
The main command is the one that makes maps for you:
::struct::map mapNameβ Creates a new, empty map, and it comes with an associated global Tcl command whose name is mapName. You use that command to invoke all the various operations on the map. It has this general form:
mapName method ?arg arg ...?
where method and its arguments determine the exact behavior of the command. π«Ά
and listen β if mapName is specified as %AUTO%, the package itself generates a unique name for you. no brainstorming required. The result of the command is the fully-qualified name of the instance command. slay β¨
π The commands you can actually run on a map object
mapName getβ Returns the entire map as a Tcl dictionary. the whole thing, all at once, no crumbs πmapName namesβ Returns the list of all keys known to the map, in arbitrary order. don't come for her about the ordering, she never promised you that πmapName set name ?value?β Sets key name to the specified value, if the value is specified. Returns the value for the key. Throws an error if the key is not known. she's dramatic like that πmapName unset ?pattern...?β Removes all keys matching at least one of the glob patterns from the map. If no pattern is specified, all keys are removed. In other words, the default pattern is*. The result of the command is the empty string. ghosted. gone. nothing left π
π₯ BUGS, IDEAS, FEEDBACK π₯
ngl, this document β and the package it describes β will undoubtedly contain bugs and other problems. it's giving "we're all just doing our best". Please report such in the category struct :: list of the Tcllib Trackers:
http://core.tcl.tk/tcllib/reportlist
Please also report any ideas for enhancements you may have for either the package and/or the documentation. we love a glow-up suggestion π
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 π§
and that's the page!! brought to you by tcllib, version 1, dated... well, the page footer says struct::map(n) β so consider this your official sign-off from your fave manual page bestie. go forth and map your keys to your values, no cap ππ
π¦ 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
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms