removed: out of array range check

This commit is contained in:
danielsss 2022-12-20 12:27:44 +11:00
parent 1ef6cd0987
commit 6eec01d594
No known key found for this signature in database
GPG Key ID: 2A5967D8F31A22D2
2 changed files with 0 additions and 14 deletions

View File

@ -24,7 +24,6 @@ class ArrayList {
/* 新增和删除 */ /* 新增和删除 */
public set(key: number, val: string | null) { public set(key: number, val: string | null) {
this.isOutOfRange(key);
if (val !== null) { if (val !== null) {
this.elements[key] = new Entry(key, val); this.elements[key] = new Entry(key, val);
} }
@ -65,12 +64,6 @@ class ArrayList {
} }
return arr; return arr;
} }
private isOutOfRange(key: number) {
if (key > this.elements.length - 1) {
throw new Error('Out of array range');
}
}
} }
/* 基于数组简易实现的哈希表 */ /* 基于数组简易实现的哈希表 */

View File

@ -536,7 +536,6 @@ $$
/* 新增和删除 */ /* 新增和删除 */
public set(key: number, val: string | null) { public set(key: number, val: string | null) {
this.isOutOfRange(key);
if (val !== null) { if (val !== null) {
this.elements[key] = new Entry(key, val); this.elements[key] = new Entry(key, val);
} }
@ -577,12 +576,6 @@ $$
} }
return arr; return arr;
} }
private isOutOfRange(key: number) {
if (key > this.elements.length - 1) {
throw new Error('Out of array range');
}
}
} }
``` ```