btree/rangemap: rename .new to .init
This commit is contained in:
+6
-6
@@ -57,7 +57,7 @@ pub fn BTree(comptime N: type, comptime compare_fn: CompareFn(N), comptime deini
|
||||
left: ?*Node = null,
|
||||
right: ?*Node = null,
|
||||
|
||||
fn new(a: Allocator, key: N) Error!*Node {
|
||||
fn init(a: Allocator, key: N) Error!*Node {
|
||||
const node = try a.create(Node);
|
||||
node.* = .{
|
||||
.key = key,
|
||||
@@ -98,7 +98,7 @@ pub fn BTree(comptime N: type, comptime compare_fn: CompareFn(N), comptime deini
|
||||
}
|
||||
return .{ n, inserted };
|
||||
} else {
|
||||
const n = try Node.new(a, key);
|
||||
const n = try Node.init(a, key);
|
||||
return .{ n, n };
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ pub fn BTree(comptime N: type, comptime compare_fn: CompareFn(N), comptime deini
|
||||
}
|
||||
};
|
||||
|
||||
pub fn new(a: std.mem.Allocator) @This() {
|
||||
pub fn init(a: std.mem.Allocator) @This() {
|
||||
return .{ .gpa = a };
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ test "BTree insertion/removal" {
|
||||
}
|
||||
}.call;
|
||||
const Tree = BTree(u32, int_compare_fn, null);
|
||||
var tree = Tree.new(std.testing.allocator);
|
||||
var tree = Tree.init(std.testing.allocator);
|
||||
defer tree.deinit();
|
||||
|
||||
for (50..100) |i| {
|
||||
@@ -319,7 +319,7 @@ test "BTree removal by node" {
|
||||
}
|
||||
}.call;
|
||||
const Tree = BTree(u32, int_compare_fn, null);
|
||||
var tree = Tree.new(std.testing.allocator);
|
||||
var tree = Tree.init(std.testing.allocator);
|
||||
defer tree.deinit();
|
||||
|
||||
_ = try tree.insert(10);
|
||||
@@ -349,7 +349,7 @@ test "BTree iterator" {
|
||||
}
|
||||
}.call;
|
||||
const Tree = BTree(u32, int_compare_fn, null);
|
||||
var tree = Tree.new(std.testing.allocator);
|
||||
var tree = Tree.init(std.testing.allocator);
|
||||
defer tree.deinit();
|
||||
|
||||
for (50..100) |i| {
|
||||
|
||||
@@ -46,8 +46,8 @@ pub fn RangeMap(comptime K: type, comptime V: type, comptime deinit_fn: ?fn (*V)
|
||||
|
||||
btree: Tree,
|
||||
|
||||
pub fn new(gpa: Allocator) @This() {
|
||||
return .{ .btree = Tree.new(gpa) };
|
||||
pub fn init(gpa: Allocator) @This() {
|
||||
return .{ .btree = Tree.init(gpa) };
|
||||
}
|
||||
|
||||
pub fn deinit(self: *@This()) void {
|
||||
@@ -148,7 +148,7 @@ pub fn RangeMap(comptime K: type, comptime V: type, comptime deinit_fn: ?fn (*V)
|
||||
|
||||
test "Range map insertion" {
|
||||
const Map = RangeMap(u32, []const u8, null);
|
||||
var map = Map.new(std.testing.allocator);
|
||||
var map = Map.init(std.testing.allocator);
|
||||
defer map.deinit();
|
||||
|
||||
_ = try map.insert(10, 10, "Range 2");
|
||||
@@ -162,7 +162,7 @@ test "Range map insertion" {
|
||||
|
||||
test "Range map get scalar" {
|
||||
const Map = RangeMap(u32, []const u8, null);
|
||||
var map = Map.new(std.testing.allocator);
|
||||
var map = Map.init(std.testing.allocator);
|
||||
defer map.deinit();
|
||||
|
||||
_ = try map.insert(10, 10, "Range [10..20)");
|
||||
@@ -196,7 +196,7 @@ test "Range map get scalar" {
|
||||
|
||||
test "Range map split" {
|
||||
const Map = RangeMap(u32, []const u8, null);
|
||||
var map = Map.new(std.testing.allocator);
|
||||
var map = Map.init(std.testing.allocator);
|
||||
defer map.deinit();
|
||||
|
||||
_ = try map.insert(0x1000, 0x1000, "Range [0x1000..0x2000)");
|
||||
@@ -223,7 +223,7 @@ test "Range map split" {
|
||||
|
||||
test "Range map iterator" {
|
||||
const Map = RangeMap(u32, []const u8, null);
|
||||
var map = Map.new(std.testing.allocator);
|
||||
var map = Map.init(std.testing.allocator);
|
||||
defer map.deinit();
|
||||
|
||||
_ = try map.insert(0x1000, 0x1000, "Range [0x1000..0x2000)");
|
||||
|
||||
Reference in New Issue
Block a user