silly-stuff/linked-list-odin/linked-list.odin

45 lines
1.0 KiB
Odin
Raw Permalink Normal View History

2024-10-03 02:57:16 +00:00
package main
import "core:fmt"
import ll "linked-list"
main :: proc() {
list := ll.init(f32)
list.data = 1
fmt.println(list)
defer ll.deinit(list)
ll.append_value(list, 5)
fmt.println("append 5", ll.to_string(list))
ll.append_value(list, 5)
fmt.println("append 5", ll.to_string(list))
ll.remove(&list, 5)
fmt.println("remove 5", ll.to_string(list))
ll.append_value(list, 5)
fmt.println("append 5", ll.to_string(list))
ll.remove_all(&list, 5)
fmt.println("remove_all 5", ll.to_string(list))
ll.prepend_value(&list, 101)
fmt.println("prepend 101", ll.to_string(list))
ll.remove(&list, 101)
fmt.println("remove 101", ll.to_string(list))
temp :: struct {
lol: i32,
yes: bool
}
struct_ll := ll.init(temp)
defer ll.deinit(struct_ll)
struct_ll.data = {lol=1}
fmt.println(ll.head(struct_ll))
fmt.println(ll.tail(struct_ll))
for i in 0..<100_000 {
ll.append_value(struct_ll, temp { lol = i32(i), yes = i % 2 == 0})
}
fmt.println(ll.to_string(struct_ll))
fmt.println(ll.tail(struct_ll))
}