diff --git a/src/bitmap.ts b/src/bitmap.ts index b13ba11..3dd6492 100644 --- a/src/bitmap.ts +++ b/src/bitmap.ts @@ -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; diff --git a/src/index.ts b/src/index.ts index c2ddfbb..b1a96d2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1 @@ export { Bitmap } from "./bitmap"; -export type { IBitmap } from "./types"; diff --git a/src/types.ts b/src/types.ts index 3fa9698..e69de29 100644 --- a/src/types.ts +++ b/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; -}