struct::skiplist(n)
π struct::skiplist β the manual, but make it cute π
okay bestie, gather round, because we're talking about struct::skiplist from the Tcl Data Structures corner of the world (that's the struct::skiplist(n) page, iykyk). It's a whole vibe: create and manipulate skiplists. no cap. β¨
πΈ NAME πΈ
struct::skiplist β create and manipulate skiplists. that's it, that's the name, slay.
β¨ SYNOPSIS β¨
package require Tcl 8.5 9
package require struct::skiplist ?1.4?
skiplistName option ?arg arg ...?
skiplistName delete node ?node...?
skiplistName destroy
skiplistName insert key value
skiplistName search node ?-key key?
skiplistName size
skiplistName walk cmd
look at that syntax. immaculate. π
π¦ DESCRIPTION π¦
So. The ::struct::skiplist command creates a brand new skiplist object, and it comes with a global Tcl command attached to it whose name is skiplistName. That command is your girl β you use it to invoke all the various operations on the skiplist. Its general form is:
skiplistName option ?arg arg ...?
- option and the args decide exactly what the command does. that's the whole deal.
Skip lists are literally the alternative data structure to binary trees, and honestly? iconic. You can use them to maintain ordered lists across any sequence of insertions and deletions. The way that skip lists use randomness to achieve probabilistic balancingβ¦ and as a result the algorithms for insertion and deletion in skip lists are much simpler and faster than the ones for binary trees. ate. π₯
if you wanna read more about skip lists (and you should, nerd, respectfully), see: Pugh, William. Skip lists: a probabilistic alternative to balanced trees In: Communications of the ACM, June 1990, 33(6) 668-676.
Right now, the key can be either a number or a string, and comparisons are performed with the built in greater than operator. no extra spice, just vibes. π
These are the commands possible for skiplist objects, bestie:
skiplistName delete node ?node...?β remove the specified nodes from the skiplist. bye girl, you're gone. π«ΆskiplistName destroyβ destroy the skiplist, including its storage space and its associated command. full send, nothing left behind. πskiplistName insert key valueβ insert a node with the given key and value into the skiplist. If a node with that key already exists, then that node's value gets updated and its node level is returned. Otherwise a new node is created and0is returned. so you always get a number back, just a different number, okay? β¨skiplistName search node ?-key key?β search for a given key in a skiplist. If it's not found then0is returned. If it is found, then you get a two element list of1followed by the node's value. one means found, zero means not found, that's the entire plot. πskiplistName sizeβ return a count of the number of nodes in the skiplist. the headcount. πskiplistName walk cmdβ walk the skiplist from the first node to the last. At each node, the command cmd will be evaluated with the key and value of the current node appended. it's a little parade through your data, main character energy fr fr. π
π BUGS, IDEAS, FEEDBACK π
ngl, this document, and the package it describes, will undoubtedly contain bugs and other problems. it's giving "we know". Please report such in the category struct :: skiplist of the Tcllib Trackers:
http://core.tcl.tk/tcllib/reportlist
Also please report any ideas for enhancements you may have for either the package and/or the documentation. we wanna hear it, bestie. π
When proposing code changes, please provide unified diffs, i.e the output of diff -u. not vibes-based patches, actual diffs. π
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. yes, that exact button. left-most. π
π KEYWORDS π
skiplist
β CATEGORY β
Data structures
π COPYRIGHT π
Copyright (c) 2000 Keith Vetter
okay and that's the whole page!! this lil manual lives in tcllib, at version 1.4, and it's filed under the name struct::skiplist(n) β so if you ever need to cite her, that's the glow-up. periodt. πβ¨π¦πΈππ
π«Άππβ
π¦ 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) 2000 Keith Vetter
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms