aboutsummaryrefslogtreecommitdiff
path: root/core/container/bit_array/doc.odin
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-04-27 14:37:15 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2022-04-27 14:37:15 +0200
commitc4e0d1efa1ec655bae9134b95a0fcd060cc7bbea (patch)
treec29bd0b78138e8d67aebe34ac689d13e32d9d15f /core/container/bit_array/doc.odin
parent6e61abc7d06f22129f93110a9f652c3eec21f0c6 (diff)
parent9349dfba8fec53f52f77a0c8928e115ec93ff447 (diff)
Merge branch 'master' into xml
Diffstat (limited to 'core/container/bit_array/doc.odin')
-rw-r--r--core/container/bit_array/doc.odin53
1 files changed, 53 insertions, 0 deletions
diff --git a/core/container/bit_array/doc.odin b/core/container/bit_array/doc.odin
new file mode 100644
index 000000000..52e252d8a
--- /dev/null
+++ b/core/container/bit_array/doc.odin
@@ -0,0 +1,53 @@
+package dynamic_bit_array
+
+/*
+ The Bit Array can be used in several ways:
+
+ -- By default you don't need to instantiate a Bit Array:
+
+ package test
+
+ import "core:fmt"
+ import "core:container/bit_array"
+
+ main :: proc() {
+ using bit_array
+
+ bits: Bit_Array
+
+ // returns `true`
+ fmt.println(set(&bits, 42))
+
+ // returns `false`, `false`, because this Bit Array wasn't created to allow negative indices.
+ was_set, was_retrieved := get(&bits, -1)
+ fmt.println(was_set, was_retrieved)
+ destroy(&bits)
+ }
+
+ -- A Bit Array can optionally allow for negative indices, if the mininum value was given during creation:
+
+ package test
+
+ import "core:fmt"
+ import "core:container/bit_array"
+
+ main :: proc() {
+ Foo :: enum int {
+ Negative_Test = -42,
+ Bar = 420,
+ Leaves = 69105,
+ }
+
+ using bit_array
+
+ bits := create(int(max(Foo)), int(min(Foo)))
+ defer destroy(bits)
+
+ fmt.printf("Set(Bar): %v\n", set(bits, Foo.Bar))
+ fmt.printf("Get(Bar): %v, %v\n", get(bits, Foo.Bar))
+ fmt.printf("Set(Negative_Test): %v\n", set(bits, Foo.Negative_Test))
+ fmt.printf("Get(Leaves): %v, %v\n", get(bits, Foo.Leaves))
+ fmt.printf("Get(Negative_Test): %v, %v\n", get(bits, Foo.Negative_Test))
+ fmt.printf("Freed.\n")
+ }
+*/ \ No newline at end of file