Skip to content

Commit dad6edb

Browse files
authored
rename: iter -> iterator (#24)
Rename iter() methods to iterator(). Zig std lib also uses iterator(), which allows me to use different container types downstream.
1 parent 329dbba commit dad6edb

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

examples/pgaudit_zig/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ The `executorCheckPermsHook` function receives the list of tables (`rangeTable`)
258258

259259

260260
```zig
261-
var it = pgzx.PointerListOf(pg.RangeTblEntry).init(rangeTables).iter();
261+
var it = pgzx.PointerListOf(pg.RangeTblEntry).init(rangeTables).iterator();
262262
while (it.next()) |rte| {
263263
...
264264
}

examples/pgaudit_zig/src/main.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn executorCheckPermsHook(rangeTables: [*c]pg.List, rtePermInfos: [*c]pg.List, v
153153
var errctx = pgzx.err.Context.init();
154154
defer errctx.deinit();
155155
if (errctx.pg_try()) {
156-
var it = pgzx.PointerListOf(pg.RangeTblEntry).initFrom(rangeTables).iter();
156+
var it = pgzx.PointerListOf(pg.RangeTblEntry).initFrom(rangeTables).iterator();
157157
while (it.next()) |rte| {
158158
const relOid = rte.?.relid;
159159
const relNamespaceOid = pg.get_rel_namespace(relOid);

src/pgzx/collections/dlist.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn DList(comptime T: type, comptime node_field: std.meta.FieldEnum(T)) type
7575

7676
pub inline fn count(self: *const Self) usize {
7777
var n: usize = 0;
78-
var it = self.iter();
78+
var it = self.iterator();
7979
while (it.next() != null) : (n += 1) {}
8080
return n;
8181
}
@@ -140,7 +140,7 @@ pub fn DList(comptime T: type, comptime node_field: std.meta.FieldEnum(T)) type
140140
return descr.nodeParentPtr(c.dlist_prev_node(&self.list, descr.nodePtr(node)));
141141
}
142142

143-
pub inline fn iter(self: *const Self) Iterator {
143+
pub inline fn iterator(self: *const Self) Iterator {
144144
return Iterator.init(&self.list);
145145
}
146146

@@ -242,7 +242,7 @@ pub const TestSuite_DList = struct {
242242
var list = TList.init();
243243
try std.testing.expectEqual(true, list.isEmpty());
244244

245-
var it = list.iter();
245+
var it = list.iterator();
246246
while (it.next()) |n| {
247247
_ = n;
248248
std.log.info("iterating over empty list", .{});
@@ -279,7 +279,7 @@ pub const TestSuite_DList = struct {
279279
try std.testing.expectEqual(3, list.count());
280280

281281
var i: u32 = 0;
282-
var it = list.iter();
282+
var it = list.iterator();
283283
while (it.next()) |n| {
284284
i += 1;
285285
try std.testing.expect(i <= 3);
@@ -301,7 +301,7 @@ pub const TestSuite_DList = struct {
301301
try std.testing.expectEqual(3, list.count());
302302

303303
var i: u32 = 3;
304-
var it = list.iter();
304+
var it = list.iterator();
305305
while (it.next()) |n| {
306306
try std.testing.expect(i >= 1);
307307
try std.testing.expectEqual(i, n.value);

src/pgzx/collections/htab.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub fn HTab(comptime Context: type) type {
196196

197197
/// Initialize an iterator for the hash table.
198198
/// If the iterator was not full exhausted, it should be terminated with `term`.
199-
pub fn iter(self: Self) Iterator {
199+
pub fn iterator(self: Self) Iterator {
200200
return Iterator.init(self.htab);
201201
}
202202

@@ -564,7 +564,7 @@ pub const TestSuite_HTab = struct {
564564
try table.put(&k2, 25);
565565

566566
var count: u32 = 0;
567-
var iter = table.iter();
567+
var iter = table.iterator();
568568
while (iter.next()) |_| {
569569
count += 1;
570570
}

src/pgzx/collections/list.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub fn PointerListOf(comptime T: type) type {
106106
return c.list_length(self.list);
107107
}
108108

109-
pub fn iter(self: Self) Iterator {
109+
pub fn iterator(self: Self) Iterator {
110110
return Iterator.init(self.list);
111111
}
112112

@@ -242,7 +242,7 @@ pub const TestSuite_PointerList = struct {
242242
var list = PointerListOf(i32).init();
243243
defer list.deinit();
244244

245-
var it = list.iter();
245+
var it = list.iterator();
246246
try std.testing.expect(it.next() == null);
247247
}
248248

@@ -258,7 +258,7 @@ pub const TestSuite_PointerList = struct {
258258
list.append(@constCast(&elems[5]));
259259
defer list.deinit();
260260

261-
var it = list.iter();
261+
var it = list.iterator();
262262
var i: i32 = 1;
263263
while (it.next()) |elem| {
264264
try std.testing.expect(i <= 6);

src/pgzx/collections/slist.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn SList(comptime T: type, comptime node_field: std.meta.FieldEnum(T)) type
7575
return Self.optNodeParentPtr(node_ptr);
7676
}
7777

78-
pub inline fn iter(self: *Self) Iterator {
78+
pub inline fn iterator(self: *Self) Iterator {
7979
var i: c.slist_iter = undefined;
8080
i.cur = self.head.head.next;
8181
return .{ .iter = i };
@@ -128,7 +128,7 @@ pub const TestSuite_SList = struct {
128128
var list = MyList.init();
129129
try std.testing.expect(list.isEmpty());
130130

131-
var it = list.iter();
131+
var it = list.iterator();
132132
try std.testing.expect(it.next() == null);
133133

134134
try std.testing.expect(list.headNode() == null);
@@ -150,7 +150,7 @@ pub const TestSuite_SList = struct {
150150
list.pushHead(&values[0]);
151151

152152
var i: u32 = 1;
153-
var it = list.iter();
153+
var it = list.iterator();
154154
while (it.next()) |node| {
155155
try std.testing.expect(i <= 3);
156156
try std.testing.expect(node.*.value == i);
@@ -179,7 +179,7 @@ pub const TestSuite_SList = struct {
179179
_ = list.popHead();
180180

181181
var i: u32 = 2;
182-
var it = list.iter();
182+
var it = list.iterator();
183183
while (it.next()) |node| {
184184
try std.testing.expect(i <= 3);
185185
try std.testing.expect(node.*.value == i);
@@ -193,7 +193,7 @@ pub const TestSuite_SList = struct {
193193
_ = list.popHead();
194194
try std.testing.expect(list.isEmpty());
195195

196-
it = list.iter();
196+
it = list.iterator();
197197
try std.testing.expect(it.next() == null);
198198

199199
try std.testing.expect(list.headNode() == null);

0 commit comments

Comments
 (0)