struct::skiplist(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– 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 and 0 is 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 then 0 is returned. If it is found, then you get a two element list of 1 followed 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 (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