【发布时间】:2016-04-13 03:45:22
【问题描述】:
我需要帮助来了解如何解决这个问题...我需要从该列表中删除索引 r 处的键及其关联值。任何能指引我走向正确方向的东西都将不胜感激!在函数内部,我写了我认为会有所帮助但并没有真正帮助我的内容
public class SortedArrayST<Key extends Comparable<Key>, Value> {
private static final int MIN_SIZE = 2;
private Key[] keys; // the keys array
private Value[] vals; // the values array
private int N = 0; // size of the symbol table
public SortedArrayST(int size) {
keys = (Key[])(new Comparable[size]);
vals = (Value[])(new Object[size]);
}
public int size() {
return N;
}
private void remove(int r) {
if (keys == null) return;
for(int i = 0; i < size(); i++){
// iterate through the list
// if key is at index r and if key is at associated value
// remove from list
}
}
【问题讨论】:
-
你不能只使用一个映射而不是两个数组吗?
-
这个赋值的重点是使用两个数组:/我希望我们可以使用地图哈哈
标签: java data-structures symbol-table