dictNext(3)

πŸ’– dictNext(3) πŸ’–

okay bestie, we're in util/dict.h territory and this one is literally the little iterator that could ✨


🌸 NAME 🌸

dictNext β€” search for next value in dictionary. that's it, that's the whole gig πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <util/dict.h>

void *dictNext(dictCtx dict, char **id, void **plock);

πŸ¦‹ ARGUMENTS πŸ¦‹

  • dict β€” the dictionary you're iterating over. your main character, fr.
  • id β€” pointer to the identifier of the last item you found, OR a pointer to NULL if you wanna grab the first one. lowkey the "where was I" bookmark πŸ“–
  • plock β€” a place for the value lock (or NULL if you don't want one, no pressure bestie).

✨ DESCRIPTION ✨

so you can use this to iterate through values in the dictionary. the way that it does that πŸ’«

the order? it's the order of the hash of the ids. and ngl, that is not usefully externally. it's giving "chaos but make it deterministic" πŸ™ˆ

it'll return the value if found, or NULL if not. simple as.

if <plock> is non-NULL, then the lock returned in <plock> gets associated with the returned value. and until you pass that lock to dictReleaseLock(), the value will not be passed to the dictCleanupFunc callback (see dictCleanup()). so like, hold onto that lock or the cleanup crew comes for your value, no cap πŸ”’

MT-Level: Safe if <dict> is thread-safe. periodt.

πŸ‘‘ RETURN VALUE πŸ‘‘

  • plock β€” set to value lock.
  • id β€” pointer to id of found value. found her! πŸŽ‰

🌈 SEE ALSO 🌈

dictDestroy(3), dictCleanup(3), dictReleaseLock(3), dictRemove(3), dictNext(3), dictCreate(3), dictSetValue(3), dictModifyValue(3), dictSearch

(yes bestie, dictNext(3) is in its own SEE ALSO list. iconic behavior honestly 🫢)


and that's the whole page, mwah πŸ’‹ this came from ClearSilver, dated 12 July 2007 β€” yeah she's vintage but she ate and left no crumbs πŸ“βœ¨