fix bug for commit 5eae708 (#317)

pull/318/head
sjinzh 2 years ago committed by GitHub
parent ad8859502c
commit 6cd6d5589e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,7 +4,7 @@
const std = @import("std");
// Zig Version: 0.10.0
// Zig Version: 0.10.1
// Build Command: zig build
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});

@ -47,14 +47,14 @@ pub fn MyList(comptime T: type) type {
// 访
pub fn get(self: *Self, index: usize) T {
//
if (index < 0 || index >= self.size()) @panic("索引越界");
if (index < 0 or index >= self.size()) @panic("索引越界");
return self.nums[index];
}
//
pub fn set(self: *Self, index: usize, num: T) void {
//
if (index < 0 || index >= self.size()) @panic("索引越界");
if (index < 0 or index >= self.size()) @panic("索引越界");
self.nums[index] = num;
}
@ -69,7 +69,7 @@ pub fn MyList(comptime T: type) type {
//
pub fn insert(self: *Self, index: usize, num: T) !void {
if (index < 0 || index >= self.size()) @panic("索引越界");
if (index < 0 or index >= self.size()) @panic("索引越界");
//
if (self.size() == self.capacity()) try self.extendCapacity();
// i
@ -84,7 +84,7 @@ pub fn MyList(comptime T: type) type {
//
pub fn remove(self: *Self, index: usize) T {
if (index < 0 || index >= self.size()) @panic("索引越界");
if (index < 0 or index >= self.size()) @panic("索引越界");
var num = self.nums[index];
// i
var j = index;

@ -60,7 +60,7 @@ pub fn ArrayQueue(comptime T: type) type {
var rear = (self.front + self.queSize) % self.capacity();
// num
self.nums[rear] = num;
self.queSize++;
self.queSize += 1;
}
//
@ -68,7 +68,7 @@ pub fn ArrayQueue(comptime T: type) type {
var num = self.peek();
//
self.front = (self.front + 1) % self.capacity();
self.queSize--;
self.queSize -= 1;
return num;
}

Loading…
Cancel
Save