removed useless interface

This commit is contained in:
Eugene 2025-12-01 19:26:25 +03:00
parent 7b363a0219
commit eec57ec719
3 changed files with 6 additions and 46 deletions

View File

@ -1,11 +1,9 @@
import { IBitmap } from "./types";
const computeBitsArrayLength = (x: number): number => Math.ceil(x / 8); const computeBitsArrayLength = (x: number): number => Math.ceil(x / 8);
const getBitPositionIndex = (x: number): number => Math.floor(x / 8); const getBitPositionIndex = (x: number): number => Math.floor(x / 8);
const getBitPosition = (x: number): number => x % 8; const getBitPosition = (x: number): number => x % 8;
const getMask = (bitIdx: number): number => 0b00000001 << bitIdx; const getMask = (bitIdx: number): number => 0b00000001 << bitIdx;
export class Bitmap implements IBitmap { export class Bitmap {
private bits: Uint8Array; private bits: Uint8Array;
constructor(x = 32) { constructor(x = 32) {
@ -64,7 +62,7 @@ export class Bitmap implements IBitmap {
return count; return count;
} }
public and(bitmap: IBitmap): IBitmap { public and(bitmap: Bitmap): Bitmap {
const otherBits = (bitmap as Bitmap).bits; const otherBits = (bitmap as Bitmap).bits;
const result = this.clone() as Bitmap; const result = this.clone() as Bitmap;
const minlen = Math.min(this.bits.length, otherBits.length); const minlen = Math.min(this.bits.length, otherBits.length);
@ -76,7 +74,7 @@ export class Bitmap implements IBitmap {
return result; return result;
} }
public andNot(bitmap: IBitmap): IBitmap { public andNot(bitmap: Bitmap): Bitmap {
const otherBits = (bitmap as Bitmap).bits; const otherBits = (bitmap as Bitmap).bits;
const result = this.clone() as Bitmap; const result = this.clone() as Bitmap;
const minlen = Math.min(this.bits.length, otherBits.length); const minlen = Math.min(this.bits.length, otherBits.length);
@ -88,7 +86,7 @@ export class Bitmap implements IBitmap {
return result; return result;
} }
public or(bitmap: IBitmap): IBitmap { public or(bitmap: Bitmap): Bitmap {
const otherBits = (bitmap as Bitmap).bits; const otherBits = (bitmap as Bitmap).bits;
const result = this.clone() as Bitmap; const result = this.clone() as Bitmap;
const minlen = Math.min(this.bits.length, otherBits.length); const minlen = Math.min(this.bits.length, otherBits.length);
@ -100,7 +98,7 @@ export class Bitmap implements IBitmap {
return result; return result;
} }
public xor(bitmap: IBitmap): IBitmap { public xor(bitmap: Bitmap): Bitmap {
const otherBits = (bitmap as Bitmap).bits; const otherBits = (bitmap as Bitmap).bits;
const result = this.clone() as Bitmap; const result = this.clone() as Bitmap;
const minlen = Math.min(this.bits.length, otherBits.length); 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); const clonedBitmap = new Bitmap(this.bits.length * 8);
clonedBitmap.bits.set(this.bits); clonedBitmap.bits.set(this.bits);
return clonedBitmap; return clonedBitmap;

View File

@ -1,2 +1 @@
export { Bitmap } from "./bitmap"; export { Bitmap } from "./bitmap";
export type { IBitmap } from "./types";

View File

@ -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>;
}