2539 |
|
if (lo == null) |
2540 |
|
return m.findFirst(); |
2541 |
|
else if (loInclusive) |
2542 |
< |
return m.findNear(lo, m.GT|m.EQ); |
2542 |
> |
return m.findNear(lo, GT|EQ); |
2543 |
|
else |
2544 |
< |
return m.findNear(lo, m.GT); |
2544 |
> |
return m.findNear(lo, GT); |
2545 |
|
} |
2546 |
|
|
2547 |
|
/** |
2552 |
|
if (hi == null) |
2553 |
|
return m.findLast(); |
2554 |
|
else if (hiInclusive) |
2555 |
< |
return m.findNear(hi, m.LT|m.EQ); |
2555 |
> |
return m.findNear(hi, LT|EQ); |
2556 |
|
else |
2557 |
< |
return m.findNear(hi, m.LT); |
2557 |
> |
return m.findNear(hi, LT); |
2558 |
|
} |
2559 |
|
|
2560 |
|
/** |
2636 |
|
*/ |
2637 |
|
private Map.Entry<K,V> getNearEntry(K key, int rel) { |
2638 |
|
if (isDescending) { // adjust relation for direction |
2639 |
< |
if ((rel & m.LT) == 0) |
2640 |
< |
rel |= m.LT; |
2639 |
> |
if ((rel & LT) == 0) |
2640 |
> |
rel |= LT; |
2641 |
|
else |
2642 |
< |
rel &= ~m.LT; |
2642 |
> |
rel &= ~LT; |
2643 |
|
} |
2644 |
|
if (tooLow(key)) |
2645 |
< |
return ((rel & m.LT) != 0) ? null : lowestEntry(); |
2645 |
> |
return ((rel & LT) != 0) ? null : lowestEntry(); |
2646 |
|
if (tooHigh(key)) |
2647 |
< |
return ((rel & m.LT) != 0) ? highestEntry() : null; |
2647 |
> |
return ((rel & LT) != 0) ? highestEntry() : null; |
2648 |
|
for (;;) { |
2649 |
|
Node<K,V> n = m.findNear(key, rel); |
2650 |
|
if (n == null || !inBounds(n.key)) |
2659 |
|
// Almost the same as getNearEntry, except for keys |
2660 |
|
private K getNearKey(K key, int rel) { |
2661 |
|
if (isDescending) { // adjust relation for direction |
2662 |
< |
if ((rel & m.LT) == 0) |
2663 |
< |
rel |= m.LT; |
2662 |
> |
if ((rel & LT) == 0) |
2663 |
> |
rel |= LT; |
2664 |
|
else |
2665 |
< |
rel &= ~m.LT; |
2665 |
> |
rel &= ~LT; |
2666 |
|
} |
2667 |
|
if (tooLow(key)) { |
2668 |
< |
if ((rel & m.LT) == 0) { |
2668 |
> |
if ((rel & LT) == 0) { |
2669 |
|
ConcurrentSkipListMap.Node<K,V> n = loNode(); |
2670 |
|
if (isBeforeEnd(n)) |
2671 |
|
return n.key; |
2673 |
|
return null; |
2674 |
|
} |
2675 |
|
if (tooHigh(key)) { |
2676 |
< |
if ((rel & m.LT) != 0) { |
2676 |
> |
if ((rel & LT) != 0) { |
2677 |
|
ConcurrentSkipListMap.Node<K,V> n = hiNode(); |
2678 |
|
if (n != null) { |
2679 |
|
K last = n.key; |
2872 |
|
/* ---------------- Relational methods -------------- */ |
2873 |
|
|
2874 |
|
public Map.Entry<K,V> ceilingEntry(K key) { |
2875 |
< |
return getNearEntry(key, (m.GT|m.EQ)); |
2875 |
> |
return getNearEntry(key, GT|EQ); |
2876 |
|
} |
2877 |
|
|
2878 |
|
public K ceilingKey(K key) { |
2879 |
< |
return getNearKey(key, (m.GT|m.EQ)); |
2879 |
> |
return getNearKey(key, GT|EQ); |
2880 |
|
} |
2881 |
|
|
2882 |
|
public Map.Entry<K,V> lowerEntry(K key) { |
2883 |
< |
return getNearEntry(key, (m.LT)); |
2883 |
> |
return getNearEntry(key, LT); |
2884 |
|
} |
2885 |
|
|
2886 |
|
public K lowerKey(K key) { |
2887 |
< |
return getNearKey(key, (m.LT)); |
2887 |
> |
return getNearKey(key, LT); |
2888 |
|
} |
2889 |
|
|
2890 |
|
public Map.Entry<K,V> floorEntry(K key) { |
2891 |
< |
return getNearEntry(key, (m.LT|m.EQ)); |
2891 |
> |
return getNearEntry(key, LT|EQ); |
2892 |
|
} |
2893 |
|
|
2894 |
|
public K floorKey(K key) { |
2895 |
< |
return getNearKey(key, (m.LT|m.EQ)); |
2895 |
> |
return getNearKey(key, LT|EQ); |
2896 |
|
} |
2897 |
|
|
2898 |
|
public Map.Entry<K,V> higherEntry(K key) { |
2899 |
< |
return getNearEntry(key, (m.GT)); |
2899 |
> |
return getNearEntry(key, GT); |
2900 |
|
} |
2901 |
|
|
2902 |
|
public K higherKey(K key) { |
2903 |
< |
return getNearKey(key, (m.GT)); |
2903 |
> |
return getNearKey(key, GT); |
2904 |
|
} |
2905 |
|
|
2906 |
|
public K firstKey() { |