removed useless interface
This commit is contained in:
parent
7b363a0219
commit
eec57ec719
|
|
@ -1,11 +1,9 @@
|
|||
import { IBitmap } from "./types";
|
||||
|
||||
const computeBitsArrayLength = (x: number): number => Math.ceil(x / 8);
|
||||
const getBitPositionIndex = (x: number): number => Math.floor(x / 8);
|
||||
const getBitPosition = (x: number): number => x % 8;
|
||||
const getMask = (bitIdx: number): number => 0b00000001 << bitIdx;
|
||||
|
||||
export class Bitmap implements IBitmap {
|
||||
export class Bitmap {
|
||||
private bits: Uint8Array;
|
||||
|
||||
constructor(x = 32) {
|
||||
|
|
@ -64,7 +62,7 @@ export class Bitmap implements IBitmap {
|
|||
return count;
|
||||
}
|
||||
|
||||
public and(bitmap: IBitmap): IBitmap {
|
||||
public and(bitmap: Bitmap): Bitmap {
|
||||
const otherBits = (bitmap as Bitmap).bits;
|
||||
const result = this.clone() as Bitmap;
|
||||
const minlen = Math.min(this.bits.length, otherBits.length);
|
||||
|
|
@ -76,7 +74,7 @@ export class Bitmap implements IBitmap {
|
|||
return result;
|
||||
}
|
||||
|
||||
public andNot(bitmap: IBitmap): IBitmap {
|
||||
public andNot(bitmap: Bitmap): Bitmap {
|
||||
const otherBits = (bitmap as Bitmap).bits;
|
||||
const result = this.clone() as Bitmap;
|
||||
const minlen = Math.min(this.bits.length, otherBits.length);
|
||||
|
|
@ -88,7 +86,7 @@ export class Bitmap implements IBitmap {
|
|||
return result;
|
||||
}
|
||||
|
||||
public or(bitmap: IBitmap): IBitmap {
|
||||
public or(bitmap: Bitmap): Bitmap {
|
||||
const otherBits = (bitmap as Bitmap).bits;
|
||||
const result = this.clone() as Bitmap;
|
||||
const minlen = Math.min(this.bits.length, otherBits.length);
|
||||
|
|
@ -100,7 +98,7 @@ export class Bitmap implements IBitmap {
|
|||
return result;
|
||||
}
|
||||
|
||||
public xor(bitmap: IBitmap): IBitmap {
|
||||
public xor(bitmap: Bitmap): Bitmap {
|
||||
const otherBits = (bitmap as Bitmap).bits;
|
||||
const result = this.clone() as Bitmap;
|
||||
const minlen = Math.min(this.bits.length, otherBits.length);
|
||||
|
|
@ -143,7 +141,7 @@ export class Bitmap implements IBitmap {
|
|||
}
|
||||
}
|
||||
|
||||
public clone(): IBitmap {
|
||||
public clone(): Bitmap {
|
||||
const clonedBitmap = new Bitmap(this.bits.length * 8);
|
||||
clonedBitmap.bits.set(this.bits);
|
||||
return clonedBitmap;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
export { Bitmap } from "./bitmap";
|
||||
export type { IBitmap } from "./types";
|
||||
|
|
|
|||
37
src/types.ts
37
src/types.ts
|
|
@ -1,37 +0,0 @@
|
|||
export interface IBitmap {
|
||||
grow(x: number): void;
|
||||
|
||||
set(x: number): void;
|
||||
|
||||
remove(x: number): void;
|
||||
|
||||
contains(x: number): boolean;
|
||||
|
||||
count(): number;
|
||||
|
||||
and(bitmap: IBitmap): IBitmap;
|
||||
|
||||
andNot(bitmap: IBitmap): IBitmap;
|
||||
|
||||
or(bitmap: IBitmap): IBitmap;
|
||||
|
||||
xor(bitmap: IBitmap): IBitmap;
|
||||
|
||||
range(fn: (x: number) => boolean | void): void;
|
||||
|
||||
filter(fn: (x: number) => boolean): void;
|
||||
|
||||
clear(): void;
|
||||
|
||||
clone(): IBitmap;
|
||||
|
||||
min(): number;
|
||||
|
||||
max(): number;
|
||||
|
||||
minZero(): number;
|
||||
|
||||
maxZero(): number;
|
||||
|
||||
[Symbol.iterator](): Iterator<number>;
|
||||
}
|
||||
Loading…
Reference in New Issue