ona/source/coral/table.zig

65 lines
1.2 KiB
Zig
Raw Normal View History

2023-04-19 01:25:35 +02:00
const io = @import("./io.zig");
2023-05-06 03:47:52 +02:00
const math = @import("./math.zig");
2023-04-19 01:25:35 +02:00
pub fn Hashed(comptime key: Key, comptime Element: type) type {
const Entry = struct {
key: key.Element,
value: Element,
};
return struct {
2023-05-06 03:47:52 +02:00
entries: []?Entry = &.{},
2023-04-19 01:25:35 +02:00
const Self = @This();
2023-05-06 03:47:52 +02:00
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;
2023-04-19 01:25:35 +02:00
}
2023-05-06 03:47:52 +02:00
pub fn clear(self: *Self) void {
// TODO: Implement.
_ = self;
2023-04-19 01:25:35 +02:00
}
2023-05-06 03:47:52 +02:00
pub fn deinit(self: *Self, allocator: io.MemoryAllocator) void {
// TODO: Implement.
2023-04-19 01:25:35 +02:00
_ = self;
2023-05-06 03:47:52 +02:00
_ = allocator;
2023-04-19 01:25:35 +02:00
}
2023-05-06 03:47:52 +02:00
pub fn insert(self: *Self, key_element: key.Element, value_element: Element) io.AllocationError!bool {
// TODO: Implement.
2023-04-19 01:25:35 +02:00
_ = self;
_ = key_element;
_ = value_element;
}
2023-05-06 03:47:52 +02:00
pub fn lookup(self: Self, key_element: key.Element) ?Element {
// TODO: Implement.
2023-04-19 01:25:35 +02:00
_ = self;
_ = key_element;
return null;
}
};
}
pub const Key = struct {
Element: type,
};
2023-05-06 03:47:52 +02:00
pub fn unsigned_key(comptime bits: comptime_int) Key {
return .{
.Element = math.Unsigned(bits),
};
}
2023-04-19 01:25:35 +02:00
pub const string_key = Key{
.Element = []const u8,
};