critbit0_contains(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– critbit0_contains(3) πŸ’–

okay bestie, so this one lives in the Library Functions Manual and it's genuinely the easiest little function in the whole critbit family, no cap πŸ¦‹


✨ NAME ✨

critbit0_contains β€” check whether a string is in the critbit tree πŸ”πŸŒ³


🌸 SYNTAX 🌸

like, copy this exactly, don't freestyle it:

#include <libowfat/critbit.h>

critbit0_tree cb = { 0 };

int critbit0_contains(critbit0_tree* cb,const char* str);

see that = { 0 }? that's you initialising your tree to empty before you do literally anything else. main character setup energy πŸ‘‘


πŸ’… DESCRIPTION πŸ’…

so critbit0_contains goes and looks up the string you hand it inside the critbit0 tree. that's it. that's the whole job.

if str is in cb, critbit0_contains returns 1 πŸŽ‰ otherwise it returns 0 😭

it's giving "yes or no, no in between" and honestly? iconic.


⭐ RETURN VALUE ⭐

  • 1 β€” the key was found πŸ’– slay
  • 0 β€” it wasn't πŸ™ˆ

🫢 SEE ALSO 🫢

  • critbit0_insert(3) β€” go put stuff in the tree first, bestie, you can't find what you never added πŸŽ€

and that's the whole page!! πŸ’œ this little gem comes from the Library Functions Manual, filed under critbit0_contains(3), and it's still the same critbit0_contains(3) down at the bottom too β€” consistent queen, we love to see it βœ¨πŸŒΈπŸ¦‹