removed: out of array range check

pull/136/head
danielsss 2 years ago
parent 1ef6cd0987
commit 6eec01d594
No known key found for this signature in database
GPG Key ID: 2A5967D8F31A22D2

@ -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…
Cancel
Save