struct::skiplist(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ struct::skiplist ✨

okay so bestie, welcome to struct::skiplist, straight out of the Tcl Data Structures manual section (that's the manual name, iykyk πŸ’…). she's a lil Tcl package, she makes skiplists, and honestly? she's iconic for it.


🌸 NAME 🌸

struct::skiplist β€” create and manipulate skiplists πŸ’–


πŸŽ€ 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

πŸ¦‹ 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 literally how you talk to your skiplist and make it do stuff. The general shape of it is this:

skiplistName option ?arg arg ...?

Option and the args are what decide the exact behavior of the command. no cap.

Skip lists are the alternative data structure to binary trees, and ngl they're kind of the moment. They can be used to maintain ordered lists over any sequence of insertions and deletions. Skip lists use randomness to achieve probabilistic balancing, and because of that, the algorithms for insertion and deletion in skip lists are much simpler and faster than those for binary trees. slay.

If you wanna read more about skip lists, see Pugh, William. Skip lists: a probabilistic alternative to balanced trees In: Communications of the ACM, June 1990, 33(6) 668-676. πŸ“š

Currently, the key can be either a number or a string, and comparisons are performed with the built in greater than operator. That's just how she operates. The following commands are possible for skiplist objects:

  • skiplistName delete node ?node...? β€” Remove the specified nodes from the skiplist. bye bestie πŸ‘‹
  • skiplistName destroy β€” Destroy the skiplist, including its storage space and associated command. it's giving 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 the that node's value is updated and its node level is returned. Otherwise a new node is created and 0 is returned. (yes, "the that node's value" β€” the original said it, and I am a faithful queen 🫢)
  • skiplistName search node ?-key key? β€” Search for a given key in a skiplist. If not found then 0 is returned. If found, then a two element list of 1 followed by the node's value is retuned. πŸ”
  • skiplistName size β€” Return a count of the number of nodes in the skiplist. how many besties are in the group chat πŸ“Š
  • 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. lil stroll through the whole vibe πŸšΆβ™€οΈβœ¨

πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

Okay real talk: this document, and the package it describes, will undoubtedly contain bugs and other problems. 😭 Please report such in the category struct :: skiplist of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation. we love feedback, fr fr.

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. (that's the left-most one. the leftiest. πŸ‘‘)


⭐ KEYWORDS ⭐

skiplist


🌈 CATEGORY 🌈

Data structures


Copyright (c) 2000 Keith Vetter


and that's the whole page bestie, no notes πŸ’…

this little manual came to you from tcllib, version 1.4, dated struct::skiplist(3tcl) β€” periodt. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from