authorgravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2022-04-15 17:01:01-05:00
committergravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2022-04-15 17:01:01-05:00
log33952dad1259d9f4af09ebbad094c9b27d565525
treeca68091c1cf8a71c10d51edad69b2d42da31bd39
parent4d0303b99249adcc4acdd51fa9a10884f1e5ed61

treap: zig fmt


1 files changed, 9 insertions(+), 9 deletions(-)

lib/std/treap.zig+9-9
......@@ -8,7 +8,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
88 const Self = @This();
99
1010 // Allow for compareFn to be fn(anytype, anytype) anytype
11 // which allows the convenient use of std.math.order.
11 // which allows the convenient use of std.math.order.
1212 fn compare(a: Key, b: Key) Order {
1313 return compareFn(a, b);
1414 }
......@@ -30,9 +30,9 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
3030
3131 // Since we're using usize, decide the shifts by the integer's bit width.
3232 const shifts = switch (@bitSizeOf(usize)) {
33 64 => .{13, 7, 17},
34 32 => .{13, 17, 5},
35 16 => .{7, 9, 8},
33 64 => .{ 13, 7, 17 },
34 32 => .{ 13, 17, 5 },
35 16 => .{ 7, 9, 8 },
3636 else => @compileError("platform not supported"),
3737 };
3838
......@@ -42,7 +42,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
4242
4343 assert(self.xorshift != 0);
4444 return self.xorshift;
45 }
45 }
4646 };
4747
4848 /// A Node represents an item or point in the treap with a uniquely associated key.
......@@ -164,7 +164,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
164164
165165 return node;
166166 }
167
167
168168 fn insert(self: *Self, key: Key, parent: ?*Node, node: *Node) void {
169169 // generate a random priority & prepare the node to be inserted into the tree
170170 node.key = key;
......@@ -232,11 +232,11 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
232232 }
233233
234234 fn rotate(self: *Self, node: *Node, right: bool) void {
235 // if right, converts the following:
235 // if right, converts the following:
236236 // parent -> (node (target YY adjacent) XX)
237237 // parent -> (target YY (node adjacent XX))
238238 //
239 // if left (!right), converts the following:
239 // if left (!right), converts the following:
240240 // parent -> (node (target YY adjacent) XX)
241241 // parent -> (target YY (node adjacent XX))
242242 const parent = node.parent;
......@@ -389,7 +389,7 @@ test "std.Treap: insert, find, replace, remove" {
389389 try testing.expectEqual(entry.node, node);
390390 try testing.expectEqual(entry.node, treap.getEntryFor(key).node);
391391 try testing.expectEqual(entry.node, treap.getEntryForExisting(node).node);
392
392
393393 // remove the node again and make sure it was cleared after the insert
394394 entry.set(null);
395395 try testing.expectEqual(entry.node, null);