@rimbu/hashed
Version:
Immutable HashMap and HashSet implementations for TypeScript
50 lines (49 loc) • 1.85 kB
text/typescript
import { TraverseState } from '@rimbu/common';
import { List } from '@rimbu/list';
type GenBlockBuilderEntry<E> = BlockBuilderBase<E> | CollisionBuilderBase<E>;
/**
* Base class for mutable builders that construct hash blocks for hashed collections.
* @typeparam E - the entry type stored in the block
*/
export declare abstract class BlockBuilderBase<E> {
abstract source?: undefined | GenSource<E>;
abstract _entries?: undefined | E[];
abstract _entrySets?: undefined | GenBlockBuilderEntry<E>[];
abstract get size(): number;
get isEmpty(): boolean;
forEach(f: (entry: E, index: number, halt: () => void) => void, options?: {
state?: TraverseState;
}): void;
}
/**
* Base class for mutable builders that handle hash collisions in hashed collections.
* @typeparam E - the entry type contained in the collision bucket
*/
export declare abstract class CollisionBuilderBase<E> {
abstract source?: undefined | {
size: number;
entries: List.NonEmpty<E>;
forEach(f: (entry: E, index: number, halt: () => void) => void, options?: {
state?: TraverseState;
}): void;
};
abstract _entries?: List.Builder<E> | undefined;
get size(): number;
get entries(): List.Builder<E>;
forEach(f: (entry: E, index: number, halt: () => void) => void, options?: {
state?: TraverseState;
}): void;
}
/**
* Generic source interface that represents a read-only view over block entries
* and collision entry sets used by block builders.
* @typeparam E - the entry type contained in the source
*/
export interface GenSource<E> {
entries: readonly E[] | null;
entrySets: readonly GenBlockBuilderEntry<E>[] | null;
forEach(f: (entry: E, index: number, halt: () => void) => void, options?: {
state?: TraverseState;
}): void;
}
export {};