Merge ec84f5b3efc3e2821b21433f3674fea4c7431901 into b70121d377cb6005eb65f12b098cd5decd905669

This commit is contained in:
Mingyue Li 2023-07-20 02:07:08 -07:00 committed by GitHub
commit 8e8ca668fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -213,6 +213,8 @@ public class BinarySearchOrderedST<Key extends Comparable<Key>, Value> implement
values[index] = value; values[index] = value;
return; return;
} }
// 如果插入后容量大于初始化容量,则放弃当前操作(或者其他实现)。
if (N >= keys.length) return;
// 否则在数组中插入新的节点,需要先将插入位置之后的元素都向后移动一个位置 // 否则在数组中插入新的节点,需要先将插入位置之后的元素都向后移动一个位置
for (int j = N; j > index; j--) { for (int j = N; j > index; j--) {
keys[j] = keys[j - 1]; keys[j] = keys[j - 1];