Skip to content

Commit 4fde4fe

Browse files
authored
chore: Change to MapEntry (#206)
Co-authored-by: IcarusTheFly <[email protected]>
1 parent 9b28624 commit 4fde4fe

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

data_structures/map/hash_map.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Map } from "./map";
1515
*/
1616
export class HashMap<K, V> implements Map<K, V> {
1717
private size!: number;
18-
private buckets!: HashMapEntry<K, V>[][];
18+
private buckets!: MapEntry<K, V>[][];
1919
private readonly loadFactor = 0.75;
2020

2121
constructor() {
@@ -47,7 +47,7 @@ export class HashMap<K, V> implements Map<K, V> {
4747
const bucket = this.buckets[index];
4848

4949
if (bucket.length === 0) {
50-
bucket.push(new HashMapEntry(key, value));
50+
bucket.push(new MapEntry(key, value));
5151
this.size++;
5252
return;
5353
}
@@ -59,7 +59,7 @@ export class HashMap<K, V> implements Map<K, V> {
5959
}
6060
}
6161

62-
bucket.push(new HashMapEntry(key, value));
62+
bucket.push(new MapEntry(key, value));
6363
this.size++;
6464
}
6565

@@ -164,8 +164,8 @@ export class HashMap<K, V> implements Map<K, V> {
164164
*
165165
* @returns The entries.
166166
*/
167-
entries(): HashMapEntry<K, V>[] {
168-
const entries: HashMapEntry<K, V>[] = [];
167+
entries(): MapEntry<K, V>[] {
168+
const entries: MapEntry<K, V>[] = [];
169169
for (const bucket of this.buckets) {
170170
for (const entry of bucket) {
171171
entries.push(entry);
@@ -228,7 +228,7 @@ export class HashMap<K, V> implements Map<K, V> {
228228
* @param key The key.
229229
* @param value The value.
230230
*/
231-
export class HashMapEntry<K, V> {
231+
export class MapEntry<K, V> {
232232
key: K;
233233
value: V;
234234

data_structures/map/map.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HashMapEntry } from "./hash_map";
1+
import { MapEntry } from "./hash_map";
22

33
/**
44
* This interface is a representation of the Map data structure.
@@ -12,5 +12,5 @@ export interface Map<K, V> {
1212
clear(): void;
1313
keys(): K[];
1414
values(): V[];
15-
entries(): HashMapEntry<K, V>[];
15+
entries(): MapEntry<K, V>[];
1616
}

0 commit comments

Comments
 (0)