ona/source/coral/table.zig

65 lines
1.2 KiB
Zig
Executable File

const io = @import("./io.zig");
const math = @import("./math.zig");
pub fn Hashed(comptime key: Key, comptime Element: type) type {
const Entry = struct {
key: key.Element,
value: Element,
};
return struct {
entries: []?Entry = &.{},
const Self = @This();
pub fn assign(self: *Self, allocator: io.Allocator, key_element: key.Element, value_element: Element) io.AllocationError!void {
// TODO: Implement.
_ = self;
_ = allocator;
_ = key_element;
_ = value_element;
}
pub fn clear(self: *Self) void {
// TODO: Implement.
_ = self;
}
pub fn deinit(self: *Self, allocator: io.MemoryAllocator) void {
// TODO: Implement.
_ = self;
_ = allocator;
}
pub fn insert(self: *Self, key_element: key.Element, value_element: Element) io.AllocationError!bool {
// TODO: Implement.
_ = self;
_ = key_element;
_ = value_element;
}
pub fn lookup(self: Self, key_element: key.Element) ?Element {
// TODO: Implement.
_ = self;
_ = key_element;
return null;
}
};
}
pub const Key = struct {
Element: type,
};
pub fn unsigned_key(comptime bits: comptime_int) Key {
return .{
.Element = math.Unsigned(bits),
};
}
pub const string_key = Key{
.Element = []const u8,
};