MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / lastKey

Method lastKey

vm/JavaAPI/src/java/util/TreeMap.java:832–867  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

830 }
831
832 public K lastKey() {
833 if (backingMap.size > 0 && !(startKey.equals(endKey))) {
834 if (!hasEnd) {
835 Node<K, V> node = maximum(backingMap.root);
836 if (node != null
837 && checkLowerBound(node.keys[node.right_idx])) {
838 return node.keys[node.right_idx];
839 }
840 } else {
841 setLastKey();
842 if (lastKeyNode != null) {
843 java.lang.Comparable<K> object = backingMap.comparator == null ? toComparable((K) endKey)
844 : null;
845 if (backingMap.cmp(object, endKey, lastKeyNode.keys[lastKeyIndex]) != 0) {
846 return lastKeyNode.keys[lastKeyIndex];
847 } else {
848 // according to subMap, it excludes the last element
849 if (lastKeyIndex != lastKeyNode.left_idx) {
850 object = backingMap.comparator == null ? toComparable((K) startKey)
851 : null;
852 // check if the element is smaller than the startkey, there's no lastkey
853 if (backingMap.cmp(object, startKey, lastKeyNode.keys[lastKeyIndex-1]) <= 0){
854 return lastKeyNode.keys[lastKeyIndex - 1];
855 }
856 } else {
857 Node<K,V> last = lastKeyNode.prev;
858 if (last != null) {
859 return last.keys[last.right_idx];
860 }
861 }
862 }
863 }
864 }
865 }
866 throw new NoSuchElementException();
867 }
868
869 @Override
870 public V put(K key, V value) {

Callers

nothing calls this directly

Calls 6

checkLowerBoundMethod · 0.95
setLastKeyMethod · 0.95
equalsMethod · 0.65
maximumMethod · 0.45
toComparableMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected