From a348a7e84efbf971048359e4bdf17d6006a79b5f Mon Sep 17 00:00:00 2001 From: NicknEma <62065135+NicknEma@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:18:58 +0200 Subject: [PATCH] Create doc.odin Create a doc file with a brief of the package and an example program (copied from a discord message by laytan) --- core/container/intrusive/list/doc.odin | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 core/container/intrusive/list/doc.odin diff --git a/core/container/intrusive/list/doc.odin b/core/container/intrusive/list/doc.odin new file mode 100644 index 000000000..ff219e15f --- /dev/null +++ b/core/container/intrusive/list/doc.odin @@ -0,0 +1,39 @@ +/* +Package list implements an intrusive doubly-linked list. + +An intrusive container requires a `Node` to be embedded in your own structure, like this: + + My_String :: struct { + node: list.Node, + value: string, + } + +Here is a full example: + + package test + + import "core:fmt" + import "core:container/intrusive/list" + + main :: proc() { + l: list.List + + one := My_String{value="Hello"} + two := My_String{value="World"} + + list.push_back(&l, &one.node) + list.push_back(&l, &two.node) + + iter := list.iterator_head(l, My_String, "node") + for s in list.iterate_next(&iter) { + fmt.println(s.value) + } + } + + My_String :: struct { + node: list.Node, + value: string, + } + +*/ +package container_intrusive_list