diff --git a/codes/typescript/chapter_hashing/array_hash_map.ts b/codes/typescript/chapter_hashing/array_hash_map.ts index d56fb8fd7..d5b5a9f80 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 091e1242f..2fed2facd 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'); - } - } } ```