mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-30 09:49:59 +02:00
refactor: check bucket []
This commit is contained in:
@@ -3,18 +3,20 @@ use <../../_impl/_find_eq.scad>;
|
||||
function _hashmap_put(buckets, b_numbers, key, value, eq, hash) =
|
||||
let(
|
||||
b_idx = hash(key) % b_numbers,
|
||||
bucket = buckets[b_idx],
|
||||
k_idx = _find_eq(bucket, key, eq)
|
||||
bucket = buckets[b_idx]
|
||||
)
|
||||
bucket == [] ? _put(buckets, b_numbers, bucket, key, value, b_idx) :
|
||||
let(k_idx = _find_eq(bucket, key, eq))
|
||||
k_idx != -1 ? _replace(buckets, b_numbers, bucket, key, value, b_idx, k_idx) :
|
||||
_put(buckets, b_numbers, bucket, key, value, b_idx);
|
||||
|
||||
|
||||
function _hashmap_put_by(buckets, b_numbers, key, value, eq, hash, f_eq) =
|
||||
let(
|
||||
b_idx = hash(key) % b_numbers,
|
||||
bucket = buckets[b_idx],
|
||||
k_idx = f_eq(bucket, key, eq)
|
||||
bucket = buckets[b_idx]
|
||||
)
|
||||
bucket == [] ? _put(buckets, b_numbers, bucket, key, value, b_idx) :
|
||||
let(k_idx = f_eq(bucket, key, eq))
|
||||
k_idx != -1 ? _replace(buckets, b_numbers, bucket, key, value, b_idx, k_idx) :
|
||||
_put(buckets, b_numbers, bucket, key, value, b_idx);
|
||||
|
||||
|
Reference in New Issue
Block a user