0
我有下面的類KeyObj
ConcurrentSkipListMap和多列比較
public class KeyObject {
private byte[] P1;
private byte[] P2;
private byte[] P3;
}
我希望把這個類的對象爲ConcurrentSkipListMap
我迷惑於如何使範圍查詢是有可能寫比較。即如果P1
被給出,則它返回我p2 and p3
。類似下面
KeyObject fromKey = new KeyObject(K1.P1, P2_MIN_VALUE, P3_MIN_VALUE);
KeyObject toKey = new KeyObject(K2.P1, P2_MAX_VALUE, P3_MAX_VALUE);
ConcurrentNavigableMap<KeyObject, Object> subview = table.submap(fromkey, toKey);
for (ConcurrentSkipListMap.Entry<KeyObject, Object> entry : subView.entrySet()) {
...
}
OR
KeyObject fromKey = new KeyObject(K1.P1, K1.P2, P3_MIN_VALUE);
KeyObject toKey = new KeyObject(K2.P2, K2.P2, P3_MAX_VALUE);
ConcurrentNavigableMap<KeyObject, Object> subview = table.submap(fromkey, toKey);
for (ConcurrentSkipListMap.Entry<KeyObject, Object> entry : subView.entrySet()) {
...
}