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

Method lastKey

Ports/CLDC11/src/java/util/TreeMap.java:828–863  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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