mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 21:16:28 +08:00
removed: out of array range check
This commit is contained in:
parent
1ef6cd0987
commit
6eec01d594
2 changed files with 0 additions and 14 deletions
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 基于数组简易实现的哈希表 */
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue