summaryrefslogtreecommitdiff
path: root/src/bitset.h
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-09-13 16:10:57 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-09-13 16:10:57 +0400
commit11048808cbe3dc77bb2bee6d2643a33a45574509 (patch)
tree0896fe3a242366161b2e5328827bdf66a193a824 /src/bitset.h
parent5438fe938f6a15f4eadcc0bb2fd09a02130aafb4 (diff)
Added bitset
Diffstat (limited to 'src/bitset.h')
-rw-r--r--src/bitset.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/bitset.h b/src/bitset.h
new file mode 100644
index 0000000..0c5092d
--- /dev/null
+++ b/src/bitset.h
@@ -0,0 +1,44 @@
+#ifndef bitset_h_INCLUDED
+#define bitset_h_INCLUDED
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef BITSET_BYTES
+#define BITSET_BYTES 4
+#endif
+
+typedef struct
+{
+ int size;
+ char *arena;
+} bitarena_t;
+
+typedef char* bitset_t;
+
+void
+bitarena_init(bitarena_t *arena, int size);
+
+bitset_t
+bitarena_at(bitarena_t *arena, int idx);
+
+bitset_t
+bitset_and(bitset_t b1, bitset_t b2);
+
+int
+bitset_isZero(bitset_t bitset);
+
+void
+bitset_set(bitset_t bitset, int position);
+
+void
+bitset_unset(bitset_t bitset, int position);
+
+int
+bitset_equals(bitset_t b1, bitset_t b2);
+
+void
+bitset_print(bitset_t bitset);
+
+#endif // bitset_h_INCLUDED