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()) {
...
}