UMap(3U)
β¨ UMap β bestie edition β¨
ok so this is a page from the InterViews Reference Manual, section 3U, and it's all about UMap π (yes we're folding the header in, it's giving intro energy, keep up π«Ά)
πΈ NAME πΈ
UMap β keeps a mapping between two sets of pointers πΊοΈβ¨
π SYNOPSIS π
#include <Unidraw/umap.h>
π¦ DESCRIPTION π¦
okay so UMap is an abstract class β meaning it's the blueprint, not the finished fit π β for objects that store an arbitrary number of pointer pairs, and can search to find either member of a pair if you hand it the other one. like a situationship but for pointers, no cap π
A UMapElem object stores each pointer pair inside the UMap. UMapElem is also an abstract class, and it defines virtuals for returning either member of the pair β those two members are called the id and the tag. Subclasses of UMapElem redefine these virtuals to return whichever member of the pair they actually store. lowkey elegant, highkey iconic β¨
π UMAPELEM PUBLIC OPERATIONS π
UMapElem()β the base class constructor does literally nothing by default. it's giving "shows up, says nothing, leaves" πvirtual void* id()virtual void* tag()β these return the id or the tag that theUMapElemstores. subclasses typically define two member variables that hold the pair's values, then redefine these operations to return them. that's the whole vibe π«Ά
π UMAP PUBLIC OPERATIONS π
virtual ~UMap()β the destructor deletes allUMapElemobjects in theUMap. it does not play, it cleans house π§Ήπint Count()β returns the number of mappings in theUMap, which corresponds to the number ofUMapElems that have been registered. it's the headcount bestie πvoid Clear()β deletes all theUMapElemmappings in theUMapwithout destroying theUMap. so the container stays, the contents dip. important distinction, don't @ me π
π UMAP PROTECTED OPERATIONS π
UMap()β the base class constructor does nothing by default. again. zero notes, zero action πvoid Register(UMapElem*)void Unregister(UMapElem*)β register or remove aUMapElemfrom theUMap. in and out, revolving door energy πͺβ¨int Index(UMapElem*)UMapElem* Elem(int index)β aUMapstores itsUMapElems in its_elemsUArrayprotected member variable.Indexreturns the index of the givenUMapElemin theUArray, whileElemreturns theUMapElemat a specified index. these operations just do the corresponding operations on theUArrayβ no extra sauce, they're delegating π«‘virtual UMapElem* FindId(void* id)virtual UMapElem* FindTag(void* tag)βFindIdsearches theUMapfor theUMapElemelement containing the given id, whileFindTagsearches for the one with the given tag. by default these operations do linear searches, comparing their arguments against the values that theUMapElems'idandtagoperations return. the comparison is based on the pointer values β so it's comparing addresses, fr fr.
subclasses can redefine these operations to make more sophisticated comparisons based on the id or tag's actual type. for example, if either the id is a string, then FindId might do a string comparison to detect a match. glow-up your search, bestie β¨π
π SEE ALSO π
UArray(3U)
no cap, every flag, every virtual, every default is still in here β I just made it cute π
and that's the whole page, bestie π this one came from the Unidraw crew, dated 4 October 1990, filed under UMap(3U) β go forth and map those pointers, you absolute icon ππ¦β
π¦ 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