-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kbonacci.ts
36 lines (29 loc) · 888 Bytes
/
kbonacci.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { SafeNumOps } from "../../ops/safeNumOps";
import { Generator } from "../gen/generator";
import { SumEncoding } from "../encoding/sum/sumEncoding";
import { PowerGen } from "../gen/powerGen";
export class Kbonacci implements Generator<number, number> {
private customs: number[];
private gen: PowerGen<number, number>;
constructor(K: number, customs?: number[], cached = true) {
const ops = new SafeNumOps();
const encoding = new SumEncoding(ops);
this.customs = customs ?? [];
this.gen = new PowerGen(K, { cached, customs, encoding, ops });
}
get K(): number {
return this.gen.K;
}
get(index: number): number {
return this.gen.get(index);
}
getCached(): boolean {
return this.gen.getCached();
}
getCustoms(): number[] {
return this.customs;
}
setCached(value: boolean): void {
this.gen.setCached(value);
}
}