LinkedList implemented
This commit is contained in:
parent
b7ee15f76a
commit
e91c744c16
@ -56,17 +56,18 @@ pub fn LinkedList() type {
|
|||||||
self.length += 1;
|
self.length += 1;
|
||||||
}
|
}
|
||||||
pub fn next(self: *Self) Point {
|
pub fn next(self: *Self) Point {
|
||||||
var current: ?*Node = undefined;
|
var elem: ?*Node = undefined;
|
||||||
if (self.current != null) {
|
|
||||||
current = self.current;
|
|
||||||
self.current = self.current.?.next;
|
|
||||||
} else {
|
|
||||||
current = self.head;
|
|
||||||
self.current = self.head;
|
|
||||||
}
|
|
||||||
|
|
||||||
return current.?.point;
|
if (self.current == null) {
|
||||||
|
elem = self.head;
|
||||||
|
self.current = self.head.?.next;
|
||||||
|
} else {
|
||||||
|
elem = self.current;
|
||||||
|
self.current = self.current.?.next;
|
||||||
|
}
|
||||||
|
return elem.?.point;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump(self: *Self) ![]Point {
|
pub fn dump(self: *Self) ![]Point {
|
||||||
const allocator = self.allocator;
|
const allocator = self.allocator;
|
||||||
var node = self.head;
|
var node = self.head;
|
||||||
@ -101,25 +102,10 @@ test "test linked list" {
|
|||||||
|
|
||||||
const points: []Point = try polygon.dump();
|
const points: []Point = try polygon.dump();
|
||||||
for (points) |point| {
|
for (points) |point| {
|
||||||
std.debug.print("x:{}\n", .{point.x});
|
std.debug.print("Point dump:{}\n", .{point});
|
||||||
std.debug.print("y:{}\n", .{point.y});
|
|
||||||
std.debug.print("z:{}\n", .{point.z});
|
|
||||||
}
|
}
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
std.debug.print("next:{}\n", .{polygon.next()});
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
std.debug.print("next:{}\n", .{polygon.next()});
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
std.debug.print("next:{}\n", .{polygon.next()});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pixel(buffer: []u8, w: Winsize, x: i64, y: i64, symbol: u21) !void {
|
pub fn pixel(buffer: []u8, w: Winsize, x: i64, y: i64, symbol: u21) !void {
|
||||||
|
Loading…
Reference in New Issue
Block a user