From 4fde4fe94679bdc1806bc4e9fab191fac04ff7b5 Mon Sep 17 00:00:00 2001 From: Omar Ferreiro <27824673+IcarusTheFly@users.noreply.github.com> Date: Fri, 20 Oct 2023 19:25:22 +0200 Subject: [PATCH] chore: Change to MapEntry (#206) Co-authored-by: IcarusTheFly --- data_structures/map/hash_map.ts | 12 ++++++------ data_structures/map/map.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data_structures/map/hash_map.ts b/data_structures/map/hash_map.ts index 3a57d759..900848a5 100644 --- a/data_structures/map/hash_map.ts +++ b/data_structures/map/hash_map.ts @@ -15,7 +15,7 @@ import { Map } from "./map"; */ export class HashMap implements Map { private size!: number; - private buckets!: HashMapEntry[][]; + private buckets!: MapEntry[][]; private readonly loadFactor = 0.75; constructor() { @@ -47,7 +47,7 @@ export class HashMap implements Map { const bucket = this.buckets[index]; if (bucket.length === 0) { - bucket.push(new HashMapEntry(key, value)); + bucket.push(new MapEntry(key, value)); this.size++; return; } @@ -59,7 +59,7 @@ export class HashMap implements Map { } } - bucket.push(new HashMapEntry(key, value)); + bucket.push(new MapEntry(key, value)); this.size++; } @@ -164,8 +164,8 @@ export class HashMap implements Map { * * @returns The entries. */ - entries(): HashMapEntry[] { - const entries: HashMapEntry[] = []; + entries(): MapEntry[] { + const entries: MapEntry[] = []; for (const bucket of this.buckets) { for (const entry of bucket) { entries.push(entry); @@ -228,7 +228,7 @@ export class HashMap implements Map { * @param key The key. * @param value The value. */ -export class HashMapEntry { +export class MapEntry { key: K; value: V; diff --git a/data_structures/map/map.ts b/data_structures/map/map.ts index 1e15c893..ff2a9fc3 100644 --- a/data_structures/map/map.ts +++ b/data_structures/map/map.ts @@ -1,4 +1,4 @@ -import { HashMapEntry } from "./hash_map"; +import { MapEntry } from "./hash_map"; /** * This interface is a representation of the Map data structure. @@ -12,5 +12,5 @@ export interface Map { clear(): void; keys(): K[]; values(): V[]; - entries(): HashMapEntry[]; + entries(): MapEntry[]; }