Deleting redundant hash table files for now.
I can bring them back from the commit history when I decide to explor again.
This commit is contained in:
parent
12aa6b4870
commit
77449819af
@ -1,27 +0,0 @@
|
||||
// Mask-Step-Index (MSI) Hash Table implementation.
|
||||
// See: https://nullprogram.com/blog/2022/08/08/
|
||||
package sectr
|
||||
// TODO(Ed) : This is a wip, I haven't gotten the nuance of this mess down pact.
|
||||
|
||||
// Compute a mask, then a step size, and finally an index.
|
||||
// The exponent parameter is a power-of-two exponent for the hash-table size.
|
||||
msi_hmap_lookup :: proc ( hash : u64, exponent, index : u32 ) -> (candidate_index : i32)
|
||||
{
|
||||
mask := u32(1 << (exponent)) - 1
|
||||
step := u32(hash >> (64 - exponent)) | 1
|
||||
candidate_index = i32( (index + step) & mask )
|
||||
return
|
||||
}
|
||||
|
||||
HMap_MSI :: struct ( $ Type : typeid, $ Size : u32 )
|
||||
where is_power_of_two( Size )
|
||||
{
|
||||
hashes : [ Size ]( ^ Type ),
|
||||
length : i32
|
||||
}
|
||||
|
||||
HMap_MSI_Dyn :: struct ( $ Type : typeid ) {
|
||||
hashes : Array( DLL_Node( ^ Type ) ),
|
||||
size : u64,
|
||||
length : i32,
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
// This was an attempt to learn Ryan's hash table implementation used with the UI module of the RAD Debugger.
|
||||
// Its not completed
|
||||
package sectr
|
||||
|
||||
HMapRJF :: struct ( $ Type : typeid ) {
|
||||
slots : Array ( DLL_NodeFL( Type ) ),
|
||||
size : u64,
|
||||
first_free : ^ Type,
|
||||
}
|
||||
|
||||
rjf_hmap_init :: proc( $ Type : typeid, allocator : Allocator, size : u64 ) -> ( HMapRJF( Type ), AllocatorError ) {
|
||||
result : HMapRJF( Type )
|
||||
alloc_error : AllocatorError
|
||||
|
||||
result.slots, alloc_error := array_init_reserve( Type, allocator, size )
|
||||
if alloc_error != AllocatorError.None {
|
||||
ensure( false, "Failed to allocate slots array" )
|
||||
return result, alloc_error
|
||||
}
|
||||
array_resize( & result.slots, size )
|
||||
|
||||
return result, AllocatorError.None
|
||||
}
|
||||
|
||||
rjf_hmap_slot_index :: #force_inline proc ( using self : HMapRJF( $ Type ), key : u64 ) -> u64 {
|
||||
return key % size
|
||||
}
|
||||
|
||||
rjf_hmap_get_slot :: #force_inline proc ( using self : HMapRJF ( $ Type ), key : u64 ) -> ^ DLL_NodeFL ( Type ) {
|
||||
slot_index := key % size
|
||||
return & slots[ slot_index ]
|
||||
}
|
||||
|
||||
rjf_hmap_insert :: proc ( using self : HMapRJF ( $ Type ), key : u64, value : ^ Type ) {
|
||||
slot_index := key % size
|
||||
slot := & slots[ slot_index ]
|
||||
|
||||
dll_insert_raw( nil, slot.first, slot.last, slot.last, value )
|
||||
}
|
Loading…
Reference in New Issue
Block a user