Added... len... Yes
This commit is contained in:
parent
5ae089628b
commit
3c411f25b9
3 changed files with 30 additions and 6 deletions
|
|
@ -96,11 +96,11 @@ pub fn FixedSlotMap(
|
||||||
/// Skips slots that live on the free list ( `` tombstones `` )
|
/// Skips slots that live on the free list ( `` tombstones `` )
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
fn nextLive(
|
fn nextLive(
|
||||||
len: usize,
|
n: usize,
|
||||||
free_list: []const u32,
|
free_list: []const u32,
|
||||||
index: *usize,
|
index: *usize,
|
||||||
) ?usize {
|
) ?usize {
|
||||||
while (index.* < len) : (index.* += 1) {
|
while (index.* < n) : (index.* += 1) {
|
||||||
if (std.mem.indexOfScalar(u32, free_list, @intCast(index.*)) == null) {
|
if (std.mem.indexOfScalar(u32, free_list, @intCast(index.*)) == null) {
|
||||||
const i = index.*;
|
const i = index.*;
|
||||||
index.* += 1;
|
index.* += 1;
|
||||||
|
|
@ -207,6 +207,14 @@ pub fn FixedSlotMap(
|
||||||
return self.get(handle) != null;
|
return self.get(handle) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
/// Number of live entries
|
||||||
|
/// Removed (freed) slots are not counted
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
pub fn len(self: *Self) usize {
|
||||||
|
return self.values.items().len - self.free_list.items().len;
|
||||||
|
}
|
||||||
|
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn iterator(self: *Self) Iterator {
|
pub fn iterator(self: *Self) Iterator {
|
||||||
|
|
|
||||||
|
|
@ -116,11 +116,11 @@ pub fn KeyedSlotMap(
|
||||||
/// Skips slots that live on the free list ( `` tombstones `` rip-bozo 😭 )
|
/// Skips slots that live on the free list ( `` tombstones `` rip-bozo 😭 )
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
fn nextLive(
|
fn nextLive(
|
||||||
len: usize,
|
n: usize,
|
||||||
free_list: []const u32,
|
free_list: []const u32,
|
||||||
index: *usize,
|
index: *usize,
|
||||||
) ?usize {
|
) ?usize {
|
||||||
while (index.* < len) : (index.* += 1) {
|
while (index.* < n) : (index.* += 1) {
|
||||||
if (std.mem.indexOfScalar(u32, free_list, @intCast(index.*)) == null) {
|
if (std.mem.indexOfScalar(u32, free_list, @intCast(index.*)) == null) {
|
||||||
const i = index.*;
|
const i = index.*;
|
||||||
index.* += 1;
|
index.* += 1;
|
||||||
|
|
@ -267,6 +267,14 @@ pub fn KeyedSlotMap(
|
||||||
return @intCast(self.lookup.count());
|
return @intCast(self.lookup.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
/// Number of live entries
|
||||||
|
/// Removed (freed) slots are not counted
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
pub fn len(self: *const Self) usize {
|
||||||
|
return self.slot_map.values.items.len - self.slot_map.free_list.items.len;
|
||||||
|
}
|
||||||
|
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn iterator(self: *Self) Iterator {
|
pub fn iterator(self: *Self) Iterator {
|
||||||
|
|
|
||||||
|
|
@ -90,11 +90,11 @@ pub fn SlotMap(comptime T: type) type {
|
||||||
/// Skips slots that live on the free list ( `` tombstones `` )
|
/// Skips slots that live on the free list ( `` tombstones `` )
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
fn nextLive(
|
fn nextLive(
|
||||||
len: usize,
|
n: usize,
|
||||||
free_list: []const u32,
|
free_list: []const u32,
|
||||||
index: *usize,
|
index: *usize,
|
||||||
) ?usize {
|
) ?usize {
|
||||||
while (index.* < len) : (index.* += 1) {
|
while (index.* < n) : (index.* += 1) {
|
||||||
if (std.mem.indexOfScalar(u32, free_list, @intCast(index.*)) == null) {
|
if (std.mem.indexOfScalar(u32, free_list, @intCast(index.*)) == null) {
|
||||||
const i = index.*;
|
const i = index.*;
|
||||||
index.* += 1;
|
index.* += 1;
|
||||||
|
|
@ -207,6 +207,14 @@ pub fn SlotMap(comptime T: type) type {
|
||||||
return self.get(handle) != null;
|
return self.get(handle) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
/// Number of live entries
|
||||||
|
/// Removed (freed) slots are not counted
|
||||||
|
/// ----------------------------------------------------
|
||||||
|
pub fn len(self: *const Self) usize {
|
||||||
|
return self.values.items.len - self.free_list.items.len;
|
||||||
|
}
|
||||||
|
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
/// ----------------------------------------------------
|
/// ----------------------------------------------------
|
||||||
pub fn iterator(self: *Self) Iterator {
|
pub fn iterator(self: *Self) Iterator {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue