include/Zycore/Bitset.h(3)

πŸ“¦
version 1.5.2 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ¦‹ include/Zycore/Bitset.h β€” Library Functions Manual πŸ¦‹

okay bestie, welcome to the Zycore bitset page πŸ’– this is the header include/Zycore/Bitset.h and yeah it's a manual page manual, the "Library Functions Manual" kind, we're doing this properly. It's giving ✨C library header✨ and there is a LOT here so buckle up, no cap.


✨ NAME ✨

include/Zycore/Bitset.h πŸŽ€


🌸 SYNOPSIS 🌸

first thing's first, the includes you need to have pulled in before this one even makes sense:

#include <Zycore/Allocator.h>
#include <Zycore/Status.h>
#include <Zycore/Types.h>
#include <Zycore/Vector.h>

πŸ’… Classes

just the one lonely little struct in here:

  • struct ZyanBitset_ β€” the icon, the blueprint, the whole personality 🫢

πŸŽ€ Typedefs

  • typedef struct ZyanBitset_ ZyanBitset β€” the glow-up name for that struct πŸ’…
  • typedef ZyanStatus(* ZyanBitsetByteOperation) (ZyanU8 *v1, const ZyanU8 *v2) β€” function-pointer type, a little callback core ⭐

πŸ’– Functions

okay here is the full roster, every single one, no edits, no gatekeeping 🌈:

  • ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanBitsetInit (ZyanBitset *bitset, ZyanUSize count) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetInitEx (ZyanBitset *bitset, ZyanUSize count, ZyanAllocator *allocator, ZyanU8 growth_factor, ZyanU8 shrink_threshold) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetInitBuffer (ZyanBitset *bitset, ZyanUSize count, void *buffer, ZyanUSize capacity) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetDestroy (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetPerformByteOperation (ZyanBitset *destination, const ZyanBitset *source, ZyanBitsetByteOperation operation) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetAND (ZyanBitset *destination, const ZyanBitset *source) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetOR (ZyanBitset *destination, const ZyanBitset *source) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetXOR (ZyanBitset *destination, const ZyanBitset *source) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetFlip (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetSet (ZyanBitset *bitset, ZyanUSize index) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetReset (ZyanBitset *bitset, ZyanUSize index) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetAssign (ZyanBitset *bitset, ZyanUSize index, ZyanBool value) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetToggle (ZyanBitset *bitset, ZyanUSize index) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetTest (ZyanBitset *bitset, ZyanUSize index) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetTestMSB (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetTestLSB (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetSetAll (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetResetAll (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetPush (ZyanBitset *bitset, ZyanBool value) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetPop (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetClear (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetReserve (ZyanBitset *bitset, ZyanUSize count) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetShrinkToFit (ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetGetSize (const ZyanBitset *bitset, ZyanUSize *size) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetGetCapacity (const ZyanBitset *bitset, ZyanUSize *capacity) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetGetSizeBytes (const ZyanBitset *bitset, ZyanUSize *size) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetGetCapacityBytes (const ZyanBitset *bitset, ZyanUSize *capacity) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetCount (const ZyanBitset *bitset, ZyanUSize *count) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetAll (const ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetAny (const ZyanBitset *bitset) ✨
  • ZYCORE_EXPORT ZyanStatus ZyanBitsetNone (const ZyanBitset *bitset) ✨

πŸ”₯ Detailed Description πŸ”₯

Implements the bitset class. That's it, that's the whole description, slay πŸ‘‘


πŸ’œ Typedef Documentation πŸ’œ

🧚 typedef struct ZyanBitset_ ZyanBitset

Defines the ZyanVector struct. (yes fr fr, that's what it says πŸ’€)

All fields in this struct should be considered as "private". Any changes may lead to unexpected behavior. so like… don't touch, bestie πŸ™ˆ that's the vibe check and you failed it if you mess with these fields, no cap.

πŸ¦‹ typedef ZyanStatus(* ZyanBitsetByteOperation) (ZyanU8 *v1, const ZyanU8 *v2)

Defines the ZyanBitsetByteOperation function prototype. it's the little signature your custom byte-operation callbacks gotta match πŸ’…

Parameters

  • v1 β€” A pointer to the first byte. This value receives the result after performing the desired operation. so this one is the main character, it gets ✨changed✨ πŸ‘‘
  • v2 β€” A pointer to the second byte. supporting cast, stays put, still iconic.

Returns

A zyan status code. πŸŽ€

This function is used to perform byte-wise operations on two ZyanBitset instances. iykyk 🌈


✨ okay that's part 1 of 3, don't go anywhere bestie, the rest is coming πŸ’–

✨ Function Documentation ✨

Bestie. Sit down. We're about to go through every single function in ZyanBitset together, one by one, alphabetically, no skips, no shortcuts 🫢 These are the actual moves you make on a bitset and I'm gonna hype up each one individually.


🌸 ZYCORE_EXPORT ZyanStatus ZyanBitsetAll (const ZyanBitset * bitset)

Checks, if all bits of the given bitset are set. Yep, every last one. All of them. The whole roster 😀

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” ZYAN_STATUS_TRUE, if all bits are set, ZYAN_STATUS_FALSE, if not. Another zyan status code, if an error occurred.


πŸ’… ZYCORE_EXPORT ZyanStatus ZyanBitsetAND (ZyanBitset * destination, const ZyanBitset * source)

Performs a logical AND operation on the given ZyanBitset instances. Classic bit math, it ate πŸ’–

Parameters:

  • destination β€” A pointer to the ZyanBitset instance that is used as the first input and as the destination.
  • source β€” A pointer to the ZyanBitset instance that is used as the second input.

Returns β€” A zyan status code.

Heads up though πŸ‘€ If the destination bitmask contains more bits than the source one, the state of the remaining bits will be undefined. Not sketchy in a cute way. Sketchy in a "we genuinely do not know what those bits are now" way πŸ’€

πŸ¦‹ ZYCORE_EXPORT ZyanStatus ZyanBitsetAny (const ZyanBitset * bitset)

Checks, if at least one bit of the given bitset is set. Just one. A single bit. That's all we need, and honestly? Relatable 🌈

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” ZYAN_STATUS_TRUE, if at least one bit is set, ZYAN_STATUS_FALSE, if not. Another zyan status code, if an error occurred.


πŸŽ€ ZYCORE_EXPORT ZyanStatus ZyanBitsetAssign (ZyanBitset * bitset, ZyanUSize index, ZyanBool value)

Sets the bit at index of the given ZyanBitset instance to the specified value. You picked the value, you own the value, main character energy ✨

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • index β€” The bit index.
  • value β€” The new value.

Returns β€” A zyan status code.


🧚 ZYCORE_EXPORT ZyanStatus ZyanBitsetClear (ZyanBitset * bitset)

Deletes all bits of the given ZyanBitset instance. Not "sets them to 0", not "hides them" β€” deletes. Gone. Girlboss move 🫢

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” A zyan status code.


πŸ”₯ ZYCORE_EXPORT ZyanStatus ZyanBitsetCount (const ZyanBitset * bitset, ZyanUSize * count)

Returns the amount of bits set in the given bitset. A little census of your ones πŸ“Š

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • count β€” Receives the amount of bits set in the given bitset.

Returns β€” A zyan status code.


πŸ’€ ZYCORE_EXPORT ZyanStatus ZyanBitsetDestroy (ZyanBitset * bitset)

Destroys the given ZyanBitset instance. Into the void. Say your goodbyes πŸ™ˆ

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” A zyan status code.


🌸 ZYCORE_EXPORT ZyanStatus ZyanBitsetFlip (ZyanBitset * bitset)

Flips all bits of the given ZyanBitset instance. Every 0 becomes a 1, every 1 becomes a 0. Total glow-up inversion, obsessed πŸ’–

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” A zyan status code.


πŸ’œ ZYCORE_EXPORT ZyanStatus ZyanBitsetGetCapacity (const ZyanBitset * bitset, ZyanUSize * capacity)

Returns the current capacity of the bitset in bits. Capacity = how much room you have, not how much you're using, iykyk πŸ‘‘

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • capacity β€” Receives the size of the bitset in bits.

Returns β€” A zyan status code.


🌈 ZYCORE_EXPORT ZyanStatus ZyanBitsetGetCapacityBytes (const ZyanBitset * bitset, ZyanUSize * capacity)

Returns the current capacity of the bitset in bytes. Same capacity, byte units this time, because sometimes you just need the byte version 🧚

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • capacity β€” Receives the size of the bitset in bytes.

Returns β€” A zyan status code.


⭐ ZYCORE_EXPORT ZyanStatus ZyanBitsetGetSize (const ZyanBitset * bitset, ZyanUSize * size)

Returns the current size of the bitset in bits. Size = how much you're actually holding rn πŸŽ€

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • size β€” Receives the size of the bitset in bits.

Returns β€” A zyan status code.


πŸ¦‹ ZYCORE_EXPORT ZyanStatus ZyanBitsetGetSizeBytes (const ZyanBitset * bitset, ZyanUSize * size)

Returns the current size of the bitset in bytes. Yes bestie, there's a byte version of this one too, and it's iconic ✨

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • size β€” Receives the size of the bitset in bytes.

Returns β€” A zyan status code.


πŸ’… ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanBitsetInit (ZyanBitset * bitset, ZyanUSize count)

Initializes the given ZyanBitset instance. Fresh start, clean slate, new era πŸ’–

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • count β€” The initial amount of bits.

Returns β€” A zyan status code.

Note the ZYAN_REQUIRES_LIBC up there β€” this one comes with that requirement attached, so don't act surprised πŸ‘€

The space for the bitset is dynamically allocated by the default allocator using the default growth factor and the default shrink threshold.


πŸŽ€ ZYCORE_EXPORT ZyanStatus ZyanBitsetInitBuffer (ZyanBitset * bitset, ZyanUSize count, void * buffer, ZyanUSize capacity)

Initializes the given ZyanBitset instance and configures it to use a custom user defined buffer with a fixed size. Your buffer, your rules, we love a self-made queen πŸ‘‘

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • count β€” The initial amount of bits.
  • buffer β€” A pointer to the buffer that is used as storage for the bits.
  • capacity β€” The maximum capacity (number of bytes) of the buffer.

Returns β€” A zyan status code.


πŸ”₯ ZYCORE_EXPORT ZyanStatus ZyanBitsetInitEx (ZyanBitset * bitset, ZyanUSize count, ZyanAllocator * allocator, ZyanU8 growth_factor, ZyanU8 shrink_threshold)

Initializes the given ZyanBitset instance and sets a custom allocator and memory allocation/deallocation parameters. The full customization era, we're doing it our way πŸ’…

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • count β€” The initial amount of bits.
  • allocator β€” A pointer to a ZyanAllocator instance.
  • growth_factor β€” The growth factor.
  • shrink_threshold β€” The shrink threshold.

Returns β€” A zyan status code.

Real talk: A growth factor of 1 disables overallocation and a shrink threshold of 0 disables dynamic shrinking. Write that down, bestie 🫢

🌸 ZYCORE_EXPORT ZyanStatus ZyanBitsetNone (const ZyanBitset * bitset)

Checks, if none bits of the given bitset are set. The zero-state vibe check, and honestly sometimes the empty bitset is the moment 😌

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” ZYAN_STATUS_TRUE, if none bits are set, ZYAN_STATUS_FALSE, if not. Another zyan status code, if an error occurred.


πŸ’œ ZYCORE_EXPORT ZyanStatus ZyanBitsetOR (ZyanBitset * destination, const ZyanBitset * source)

Performs a logical OR operation on the given ZyanBitset instances. OR my beloved ✨

Parameters:

  • destination β€” A pointer to the ZyanBitset instance that is used as the first input and as the destination.
  • source β€” A pointer to the ZyanBitset instance that is used as the second input.

Returns β€” A zyan status code.

Same warning as before, no cap: If the destination bitmask contains more bits than the source one, the state of the remaining bits will be undefined 😭

🧚 ZYCORE_EXPORT ZyanStatus ZyanBitsetPerformByteOperation (ZyanBitset * destination, const ZyanBitset * source, ZyanBitsetByteOperation operation)

Performs a byte-wise operation for every byte in the given ZyanBitset instances. You bring the callback, we bring the bytes πŸ”₯

Parameters:

  • destination β€” A pointer to the ZyanBitset instance that is used as the first input and as the destination.
  • source β€” A pointer to the ZyanBitset instance that is used as the second input.
  • operation β€” A pointer to the function that performs the desired operation.

Returns β€” A zyan status code.

The operation callback is invoked once for every byte in the smallest of the ZyanBitset instances. Smallest one sets the pace, periodt.


πŸŽ€ ZYCORE_EXPORT ZyanStatus ZyanBitsetPop (ZyanBitset * bitset)

Removes the last bit of the bitset. Pop it, drop it, it's over πŸ’…

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” A zyan status code.


🌈 ZYCORE_EXPORT ZyanStatus ZyanBitsetPush (ZyanBitset * bitset, ZyanBool value)

Adds a new bit at the end of the bitset. Adding to the end, keeping the energy going, love that for us 🫢

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • value β€” The value of the new bit.

Returns β€” A zyan status code.


⭐ ZYCORE_EXPORT ZyanStatus ZyanBitsetReserve (ZyanBitset * bitset, ZyanUSize count)

Changes the capacity of the given ZyanBitset instance. Manifesting more room in advance, queen behavior πŸ‘‘

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • count β€” The new capacity (number of bits).

Returns β€” A zyan status code.


πŸ’– ZYCORE_EXPORT ZyanStatus ZyanBitsetReset (ZyanBitset * bitset, ZyanUSize index)

Sets the bit at index of the given ZyanBitset instance to 0.

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • index β€” The bit index.

Returns β€” A zyan status code.


🌸 ZYCORE_EXPORT ZyanStatus ZyanBitsetResetAll (ZyanBitset * bitset)

Sets all bits of the given ZyanBitset instance to 0.

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” A zyan status code.


πŸ’œ ZYCORE_EXPORT ZyanStatus ZyanBitsetSet (ZyanBitset * bitset, ZyanUSize index)

Sets the bit at index of the given ZyanBitset instance to 1.

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • index β€” The bit index.

Returns β€” A zyan status code.


πŸ”₯ ZYCORE_EXPORT ZyanStatus ZyanBitsetSetAll (ZyanBitset * bitset)

Sets all bits of the given ZyanBitset instance to 1. Every single one. Full send. Ate πŸ’…

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” A zyan status code.


πŸ¦‹ ZYCORE_EXPORT ZyanStatus ZyanBitsetShrinkToFit (ZyanBitset * bitset)

Shrinks the capacity of the given bitset to match it's size. (Yes, that apostrophe is in the original, and yes, we're keeping it exactly as it is πŸ’€) Snatched, cinched, capacity matched to size πŸŽ€

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” A zyan status code.


πŸ‘‘ ZYCORE_EXPORT ZyanStatus ZyanBitsetTest (ZyanBitset * bitset, ZyanUSize index)

Returns the value of the bit at index. Just peeking, no touching, we're respectful 🫢

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • index β€” The bit index.

Returns β€” ZYAN_STATUS_TRUE, if the bit is set or ZYAN_STATUS_FALSE, if not, Another zyan status code, if an error occurred.


⭐ ZYCORE_EXPORT ZyanStatus ZyanBitsetTestLSB (ZyanBitset * bitset)

Returns the value of the least significant bit. The little guy. The underdog. We stan 😭

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” ZYAN_STATUS_TRUE, if the bit is set or ZYAN_STATUS_FALSE, if not. Another zyan status code, if an error occurred.


🌈 ZYCORE_EXPORT ZyanStatus ZyanBitsetTestMSB (ZyanBitset * bitset)

Returns the value of the most significant bit. The big one. The main character. Obviously πŸ’–

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.

Returns β€” ZYAN_STATUS_TRUE, if the bit is set or ZYAN_STATUS_FALSE, if not. Another zyan status code, if an error occurred.


🧚 ZYCORE_EXPORT ZyanStatus ZyanBitsetToggle (ZyanBitset * bitset, ZyanUSize index)

Toggles the bit at index of the given ZyanBitset instance. Flip it and reverse it, one bit at a time ✨

Parameters:

  • bitset β€” A pointer to the ZyanBitset instance.
  • index β€” The bit index.

Returns β€” A zyan status code.


πŸ’œ ZYCORE_EXPORT ZyanStatus ZyanBitsetXOR (ZyanBitset * destination, const ZyanBitset * source)

Performs a logical XOR operation on the given ZyanBitset instances. Different = true, same = false, the pickiest of the bit ops, honestly iconic πŸ”₯

Parameters:

  • destination β€” A pointer to the ZyanBitset instance that is used as the first input and as the destination.
  • source β€” A pointer to the ZyanBitset instance that is used as the second input.

Returns β€” A zyan status code.

And one last time, bestie, don't let it slide: If the destination bitmask contains more bits than the source one, the state of the remaining bits will be undefined πŸ’€

✨ AUTHOR ✨

  • Author β€” Generated automatically by Doxygen for Zycore from the source code. πŸ‘‘

No cap, nobody sat down and hand-typed this bad boy β€” Doxygen cooked. It read the Zycore source code and spat out every single word you just read, all by itself, no human ghostwriter, no notes. So if you're out here wanting to @ someone about a typo… it's the robot's fault, bestie 😭 be nice to the robot πŸ’–


okay that's a wrap on the whole page, bestie!! πŸŽ€ you just made it through include/Zycore/Bitset.h(3) β€” every typedef, every function, every last bit (pun fully intended πŸ’…) β€” and that's genuinely iconic of you. go forth and manipulate some bits responsibly, mwah 🫢

this little number comes to you courtesy of Zycore, at Version 1.5.2.0, living in the manual as include/Zycore/Bitset.h(3) ✨ slay, periodt, no cap, and bye πŸ‘‹πŸ’œ

πŸ“¦ where this page comes from