UList(3U)
π UList β the circular doubly-linked list class, bestie π
okay so this is UList(3U) from the InterViews Reference Manual, and she's giving classic C++ container realness. buckle up π
β¨ SYNOPSIS β¨
#include <Unidraw/ulist.h>
like, that's it. one include. she's low maintenance fr π
π¦ DESCRIPTION π¦
so UList implements a circular, doubly-linked list. and the way that works is iconic: the sentinel and each entry in the list are all instances of the UList class. every one of them holds a void pointer to the data they contain, plus pointers to the next and previous UList instance in the list. π«Ά
and here's the cute part β the sentinel UList instance is considered to represent the list. she is the list. main character energy, no cap π
πΈ PUBLIC OPERATIONS πΈ
UList(void* = nil)β create a newUListinstance, and optionally hand her the value for thevoidpointer she stores. β¨virtual ~UList()β delete the entire list. normally it's the sentinel (aka the entry that represents the list) that gets deleted explicitly. but heads up bestie: the data on the list, stored asvoid*'s, cannot be deleted in this manner. so don't come for me when your data leaks, ok? πvoid Append(UList*)void Prepend(UList*)β okay so these two hit different depending on who you call them on. when performed on the sentinel,Appendappends an element to the end of the list andPrependprepends it to the beginning of the list. but when performed on aUListinstance other than the sentinel,Appendhas the effect of inserting its argument before the instance, whilePrependhas the effect of inserting it after the instance. yes that's flipped, no I did not make that up, it's giving chaotic but we love her πvoid Remove(UList*)β unlink the specifiedUListinstance from the list it's in. the object on which this operation is called is irrelevant, so don't stress about which one you're holding, it literally does not matter π§void Delete(void*)β find theUListinstance in this list containing the givenvoidpointer, remove it from the list it's in, and delete it. bye girl πUList* Find(void*)β return theUListinstance in this list containing the givenvoidpointer. πUList* First()UList* Last()UList* End()UList* Next()UList* Prev()β return variousUListinstances in the list relative to this, i.e. as if it were the sentinel.Endreturns the sentinel (this) and is useful for detecting the end of an iteration through the list; the other operations are self-explanatory. periodt πboolean IsEmpty()β return whether or not the list has any elements. vibe check π΅οΈβοΈvoid* operator()()β return thevoidpointer that theUListstores. she's got the goods πUList* operator[](int i)β return the *i*thUListin the list, where the next element is the first, etc. indexing but make it β¨spicyβ¨
ngl the sentinel-does-everything design is highkey a slay once it clicks. iteration goesFirst()βNext()β β¦ βEnd(), and you're done. iykyk π
and that's the whole page, bestie β no notes, we ate π
this was UList(3U) from Unidraw, dated 3 October 1990 π β¨ππ¦
π¦ where this page comes from
- debian bookworm: ivtools-dev 2.0.11d.a1-1+b4
- debian trixie: ivtools-dev 2.0.11d.a1-3+b4
- ubuntu jammy: ivtools-dev 2.0.11d.a1-1build1
- ubuntu noble: ivtools-dev 2.0.11d.a1-3build1
- ubuntu questing: ivtools-dev 2.0.11d.a1-3build7
- ubuntu resolute: ivtools-dev 2.0.11d.a1-3build9
- ubuntu stonking: ivtools-dev 2.1.1+git.2025.07.26.a1-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms