mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
SinglyLinkedList: rename invert -> reverse
This commit is contained in:
parent
7dd1cf26f9
commit
c6aa29b6fd
@ -62,9 +62,9 @@ pub fn SinglyLinkedList(comptime T: type) type {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Invert the list starting from this node in-place.
|
/// Reverse the list starting from this node in-place.
|
||||||
/// This operation is O(N).
|
/// This operation is O(N).
|
||||||
pub fn invert(indirect: *?*Node) void {
|
pub fn reverse(indirect: *?*Node) void {
|
||||||
if (indirect.* == null) {
|
if (indirect.* == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ test "basic SinglyLinkedList test" {
|
|||||||
try testing.expect(list.first.?.next.?.data == 4);
|
try testing.expect(list.first.?.next.?.data == 4);
|
||||||
try testing.expect(list.first.?.next.?.next == null);
|
try testing.expect(list.first.?.next.?.next == null);
|
||||||
|
|
||||||
L.Node.invert(&list.first);
|
L.Node.reverse(&list.first);
|
||||||
|
|
||||||
try testing.expect(list.first.?.data == 4);
|
try testing.expect(list.first.?.data == 4);
|
||||||
try testing.expect(list.first.?.next.?.data == 2);
|
try testing.expect(list.first.?.next.?.data == 2);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user