mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
fix(rtl): don't use init_nil()
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const rtl = @import("rtl");
|
|
||||||
const b = @import("base");
|
const b = @import("base");
|
||||||
const pl = b.pl;
|
const pl = b.pl;
|
||||||
const ke = b.ke;
|
const ke = b.ke;
|
||||||
@@ -11,7 +10,6 @@ var thread0: ke.Thread = undefined;
|
|||||||
var stack: [8192]u8 align(16) = undefined;
|
var stack: [8192]u8 align(16) = undefined;
|
||||||
|
|
||||||
pub fn init(boot_info: *pl.BootInfo) linksection(b.init) void {
|
pub fn init(boot_info: *pl.BootInfo) linksection(b.init) void {
|
||||||
rtl.init();
|
|
||||||
std.log.info("hello, world", .{});
|
std.log.info("hello, world", .{});
|
||||||
ki.impl.early_init();
|
ki.impl.early_init();
|
||||||
pl.early_init(boot_info);
|
pl.early_init(boot_info);
|
||||||
|
|||||||
+4
-14
@@ -7,20 +7,12 @@ pub const Node = struct {
|
|||||||
parent: TaggedPtr(Node),
|
parent: TaggedPtr(Node),
|
||||||
};
|
};
|
||||||
|
|
||||||
pub var nil = Node{
|
pub var nil: Node = .{
|
||||||
.left = undefined,
|
.left = &nil,
|
||||||
.right = undefined,
|
.right = &nil,
|
||||||
.parent = undefined,
|
.parent = .{ .value = 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Initialize the sentinel nil node. This should be called before using any BSTs.
|
|
||||||
pub fn init_nil() void {
|
|
||||||
nil.left = &nil;
|
|
||||||
nil.right = &nil;
|
|
||||||
nil.parent.set_ptr(&nil);
|
|
||||||
nil.parent.set_tag(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Base struct for binary search trees.
|
/// Base struct for binary search trees.
|
||||||
/// This should be used as a field in other types that are based on binary search trees, such as red-black trees or AVL trees.
|
/// This should be used as a field in other types that are based on binary search trees, such as red-black trees or AVL trees.
|
||||||
pub fn BST(comptime cmp: fn (*Node, *Node) std.math.Order) type {
|
pub fn BST(comptime cmp: fn (*Node, *Node) std.math.Order) type {
|
||||||
@@ -170,8 +162,6 @@ fn node_cmp(a: *Node, b: *Node) std.math.Order {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test BST {
|
test BST {
|
||||||
init_nil();
|
|
||||||
|
|
||||||
var tree: BST(node_cmp) = .init();
|
var tree: BST(node_cmp) = .init();
|
||||||
|
|
||||||
var nodes = [_]MyNode{
|
var nodes = [_]MyNode{
|
||||||
|
|||||||
@@ -307,7 +307,6 @@ fn check_invariants(tree: *RBTree(cmp_test_node)) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make_tree() RBTree(cmp_test_node) {
|
fn make_tree() RBTree(cmp_test_node) {
|
||||||
bst.init_nil();
|
|
||||||
return .init();
|
return .init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ pub const bst = @import("bst.zig");
|
|||||||
pub const BST = bst.BST;
|
pub const BST = bst.BST;
|
||||||
pub const RBTree = @import("rbtree.zig").RBTree;
|
pub const RBTree = @import("rbtree.zig").RBTree;
|
||||||
|
|
||||||
pub fn init() void {
|
|
||||||
bst.init_nil();
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
test {
|
||||||
std.testing.refAllDecls(@This());
|
std.testing.refAllDecls(@This());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user