6.4. kink/BIN_HASHER

6.4.1. bin_hasher型

bin_hasherは、概念的には、不変のタプル (Hash_algorithm, Accumulated_bin) である。hashメソッドにTail_binが与えられると、Hash_algorithmによる (Accumulated_bin + Tail_bin) のハッシュ値を計算する。

Accumulated_binそのものを戻すメソッドはない。したがって実装は、Accumulated_binそれ自体のかわりに、Accumulated_binから計算された、圧縮された状態を保持しても良い。

例

6.4.1.1. Hasher.hash(...[Tail_bin=BIN.of()])

hashは、 (Accumulated_bin + Tail_bin) のハッシュ値を計算して、binを戻す。

事前条件

Tail_binはbin値でなければならない。

6.4.1.2. Hasher + Bin

`+` 演算子、つまりop_addメソッドは、 (Hash_algorithm, Accumulated_bin + Bin) の新しいbin_hasher値を戻す。

事前条件

Binはbin値でなければならない。

6.4.2. BIN_HASHER.for(Hash_algorithm ...[$config={}])

forは、 (Hash_algorithm, BIN.of()) のbin_hasher値を作る。

コンフィグメソッド:

• C.on_success($success): default = VAL.identity

• C.on_error($error): default = 例外を投げる関数

bin_hasherが作られたら、forは、bin_hasherを引数として$successを末尾呼び出しする。

Hash_algorithmがサポートされていなければ、forは、引数なしで$errorを末尾呼び出しする。

事前条件

Hash_algorithmはstr値でなければならない。

$successはbin_hasherを取る関数でなければならない。

$errorはサンクでなければならない。

6.4.3. BIN_HASHER.is?(Val)

is?は、Valがbin_hasherであるかどうかを戻す。