| ... | @@ -62,9 +62,9 @@ pub fn SinglyLinkedList(comptime T: type) type { | ... | @@ -62,9 +62,9 @@ pub fn SinglyLinkedList(comptime T: type) type { |
| 62 | return count; | 62 | return count; |
| 63 | } | 63 | } |
| 64 | | 64 | |
| 65 | /// Invert the list starting from this node in-place. | 65 | /// Reverse the list starting from this node in-place. |
| 66 | /// This operation is O(N). | 66 | /// This operation is O(N). |
| 67 | pub fn invert(indirect: *?*Node) void { | 67 | pub fn reverse(indirect: *?*Node) void { |
| 68 | if (indirect.* == null) { | 68 | if (indirect.* == null) { |
| 69 | return; | 69 | return; |
| 70 | } | 70 | } |
| ... | @@ -164,7 +164,7 @@ test "basic SinglyLinkedList test" { | ... | @@ -164,7 +164,7 @@ test "basic SinglyLinkedList test" { |
| 164 | try testing.expect(list.first.?.next.?.data == 4); | 164 | try testing.expect(list.first.?.next.?.data == 4); |
| 165 | try testing.expect(list.first.?.next.?.next == null); | 165 | try testing.expect(list.first.?.next.?.next == null); |
| 166 | | 166 | |
| 167 | L.Node.invert(&list.first); | 167 | L.Node.reverse(&list.first); |
| 168 | | 168 | |
| 169 | try testing.expect(list.first.?.data == 4); | 169 | try testing.expect(list.first.?.data == 4); |
| 170 | try testing.expect(list.first.?.next.?.data == 2); | 170 | try testing.expect(list.first.?.next.?.data == 2); |