aboutsummaryrefslogtreecommitdiff
path: root/std/array_list.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-06-18 14:51:23 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-06-18 14:51:23 -0400
commitc757984879687e465c6470fc1347cf0f14e46dcc (patch)
tree9827a65bfcc0041a279d8a75b567cba83f9c5b16 /std/array_list.zig
parent84a700f97240eb2d4c65554d9be43bae9fa6d4ae (diff)
parent1ca90b585692c9611c64412844d2f3a7b3e11340 (diff)
downloadzig-c757984879687e465c6470fc1347cf0f14e46dcc.tar.gz
zig-c757984879687e465c6470fc1347cf0f14e46dcc.zip
Merge remote-tracking branch 'origin/master' into llvm7
Diffstat (limited to 'std/array_list.zig')
-rw-r--r--std/array_list.zig34
1 files changed, 17 insertions, 17 deletions
diff --git a/std/array_list.zig b/std/array_list.zig
index 1a235d28a3..b71f5be6ab 100644
--- a/std/array_list.zig
+++ b/std/array_list.zig
@@ -29,36 +29,36 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
};
}
- pub fn deinit(self: *const Self) void {
+ pub fn deinit(self: Self) void {
self.allocator.free(self.items);
}
- pub fn toSlice(self: *const Self) []align(A) T {
+ pub fn toSlice(self: Self) []align(A) T {
return self.items[0..self.len];
}
- pub fn toSliceConst(self: *const Self) []align(A) const T {
+ pub fn toSliceConst(self: Self) []align(A) const T {
return self.items[0..self.len];
}
- pub fn at(self: *const Self, n: usize) T {
+ pub fn at(self: Self, n: usize) T {
return self.toSliceConst()[n];
}
/// Sets the value at index `i`, or returns `error.OutOfBounds` if
/// the index is not in range.
- pub fn setOrError(self: *const Self, i: usize, item: *const T) !void {
+ pub fn setOrError(self: Self, i: usize, item: T) !void {
if (i >= self.len) return error.OutOfBounds;
- self.items[i] = item.*;
+ self.items[i] = item;
}
/// Sets the value at index `i`, asserting that the value is in range.
- pub fn set(self: *const Self, i: usize, item: *const T) void {
+ pub fn set(self: *Self, i: usize, item: T) void {
assert(i < self.len);
- self.items[i] = item.*;
+ self.items[i] = item;
}
- pub fn count(self: *const Self) usize {
+ pub fn count(self: Self) usize {
return self.len;
}
@@ -81,12 +81,12 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
return result;
}
- pub fn insert(self: *Self, n: usize, item: *const T) !void {
+ pub fn insert(self: *Self, n: usize, item: T) !void {
try self.ensureCapacity(self.len + 1);
self.len += 1;
mem.copy(T, self.items[n + 1 .. self.len], self.items[n .. self.len - 1]);
- self.items[n] = item.*;
+ self.items[n] = item;
}
pub fn insertSlice(self: *Self, n: usize, items: []align(A) const T) !void {
@@ -97,9 +97,9 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
mem.copy(T, self.items[n .. n + items.len], items);
}
- pub fn append(self: *Self, item: *const T) !void {
+ pub fn append(self: *Self, item: T) !void {
const new_item_ptr = try self.addOne();
- new_item_ptr.* = item.*;
+ new_item_ptr.* = item;
}
pub fn appendSlice(self: *Self, items: []align(A) const T) !void {
@@ -185,23 +185,23 @@ test "basic ArrayList test" {
{
var i: usize = 0;
while (i < 10) : (i += 1) {
- list.append(i32(i + 1)) catch unreachable;
+ list.append(@intCast(i32, i + 1)) catch unreachable;
}
}
{
var i: usize = 0;
while (i < 10) : (i += 1) {
- assert(list.items[i] == i32(i + 1));
+ assert(list.items[i] == @intCast(i32, i + 1));
}
}
for (list.toSlice()) |v, i| {
- assert(v == i32(i + 1));
+ assert(v == @intCast(i32, i + 1));
}
for (list.toSliceConst()) |v, i| {
- assert(v == i32(i + 1));
+ assert(v == @intCast(i32, i + 1));
}
assert(list.pop() == 10);