const debug = @import("./debug.zig"); const io = @import("./io.zig"); // TODO: Finish implementing. pub fn Map(comptime Index: type, comptime Element: type) type { return struct { free_index: Index = 0, entries: []Entry = &.{}, const Entry = union (enum) { free_index: usize, element: Element, }; const Self = @This(); pub fn fetch(self: *Self, index: Index) *Element { const entry = &self.entries[index]; debug.assert(entry.* == .element); return &entry.element; } pub fn deinit(self: *Self, allocator: io.Allocator) void { io.deallocate(allocator, self.entries); } pub fn insert(self: *Self, allocator: io.Allocator, value: Element) io.AllocationError!Index { _ = self; _ = allocator; _ = value; return 0; } pub fn remove(self: *Self, index: Index) void { const entry = &self.entries[index]; debug.assert(entry.* == .element); } }; }