From 6eec01d594c6be44f1d0d7d57402bdf2fd1b94ad Mon Sep 17 00:00:00 2001 From: danielsss Date: Tue, 20 Dec 2022 12:27:44 +1100 Subject: [PATCH] removed: out of array range check --- codes/typescript/chapter_hashing/array_hash_map.ts | 7 ------- docs/chapter_hashing/hash_map.md | 7 ------- 2 files changed, 14 deletions(-) diff --git a/codes/typescript/chapter_hashing/array_hash_map.ts b/codes/typescript/chapter_hashing/array_hash_map.ts index d56fb8fd..d5b5a9f8 100644 --- a/codes/typescript/chapter_hashing/array_hash_map.ts +++ b/codes/typescript/chapter_hashing/array_hash_map.ts @@ -24,7 +24,6 @@ class ArrayList { /* 新增和删除 */ public set(key: number, val: string | null) { - this.isOutOfRange(key); if (val !== null) { this.elements[key] = new Entry(key, val); } @@ -65,12 +64,6 @@ class ArrayList { } return arr; } - - private isOutOfRange(key: number) { - if (key > this.elements.length - 1) { - throw new Error('Out of array range'); - } - } } /* 基于数组简易实现的哈希表 */ diff --git a/docs/chapter_hashing/hash_map.md b/docs/chapter_hashing/hash_map.md index 091e1242..2fed2fac 100644 --- a/docs/chapter_hashing/hash_map.md +++ b/docs/chapter_hashing/hash_map.md @@ -536,7 +536,6 @@ $$ /* 新增和删除 */ public set(key: number, val: string | null) { - this.isOutOfRange(key); if (val !== null) { this.elements[key] = new Entry(key, val); } @@ -577,12 +576,6 @@ $$ } return arr; } - - private isOutOfRange(key: number) { - if (key > this.elements.length - 1) { - throw new Error('Out of array range'); - } - } } ```