EC_HTABLE_ITER(3)

πŸ’– EC_HTABLE_ITER β€” bestie we're gonna walk the whole hash table πŸ’–

okay so this is part of the libecoli programmer's manual, and today's main character is ec_htable_iter β€” the little function that lets you stroll through every single element chillin' inside a hash table. no cap. πŸšΆβ™€οΈβœ¨


🌸 NAME 🌸

ec_htable_iter β€” iterate the elements in the hash table. that's it, that's the vibe. πŸ’…


✨ SYNOPSIS ✨

#include <ecoli/htable.h>

struct ec_htable_elt_ref * ec_htable_iter(
    const struct ec_htable   *htable   /* The hash table. */
);

so you pull in the header #include <ecoli/htable.h>, and then you call ec_htable_iter() handing it your hash table β€” that's the const struct ec_htable *htable argument, aka The hash table. β€” and it hands you back a struct ec_htable_elt_ref *. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

the typical usage is, like, literally this:

for (iter = ec_htable_iter(htable);
     iter != NULL;
     iter = ec_htable_iter_next(iter)) {
   printf("  %s: %p0,
       ec_htable_iter_get_key(iter),
       ec_htable_iter_get_val(iter));
}

it's giving classic for-loop main character energy: kick it off with ec_htable_iter(htable), keep going while iter != NULL, and then scoot to the next one with ec_htable_iter_next(iter). inside the loop you grab the key with ec_htable_iter_get_key(iter) and the value with ec_htable_iter_get_val(iter). periodt. πŸ‘‘


🫢 RETURN VALUE 🫢

you get back an iterator element, or NULL if the htable is empty. that's the whole tea. if it's NULL, bestie, there's nothing in there to iterate. 😭


🌈 SEE ALSO 🌈

squad goals, all of them, go read these too:


Copyright (C) 2010-2026 Olivier Matz, Robin Jarry.


okay that's the whole page, mwah πŸ’‹ this came from the libecoli manual and it's dated 2026-06-11, page EC_HTABLE_ITER(3). go iterate something iconic, bestie, you got this 🧚⭐

πŸ“¦ where this page comes from