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

Method containsKey

Ports/CLDC11/src/java/util/TreeMap.java:3788–3831  ·  view source on GitHub ↗
(Object key)

Source from the content-addressed store, hash-verified

3786 /// if the specified key is `null` and the comparator
3787 /// cannot handle `null` keys.
3788 @SuppressWarnings("unchecked")
3789 @Override
3790 public boolean containsKey(Object key) {
3791 java.lang.Comparable<K> object = comparator == null ? toComparable((K) key)
3792 : null;
3793 K keyK = (K) key;
3794 Node<K, V> node = root;
3795 while (node != null) {
3796 K[] keys = node.keys;
3797 int left_idx = node.left_idx;
3798 int result = object != null ? object.compareTo(keys[left_idx])
3799 : -comparator.compare(keys[left_idx], keyK);
3800 if (result < 0) {
3801 node = node.left;
3802 } else if (result == 0) {
3803 return true;
3804 } else {
3805 int right_idx = node.right_idx;
3806 if (left_idx != right_idx) {
3807 result = cmp(object, keyK, keys[right_idx]);
3808 }
3809 if (result > 0) {
3810 node = node.right;
3811 } else if (result == 0) {
3812 return true;
3813 } else { /* search in node */
3814 int low = left_idx + 1, mid = 0, high = right_idx - 1;
3815 while (low <= high) {
3816 mid = (low + high) >>> 1;
3817 result = cmp(object, keyK, keys[mid]);
3818 if (result > 0) {
3819 low = mid + 1;
3820 } else if (result == 0) {
3821 return true;
3822 } else {
3823 high = mid - 1;
3824 }
3825 }
3826 return false;
3827 }
3828 }
3829 }
3830 return false;
3831 }
3832
3833 /// Returns whether this map contains the specified value.
3834 ///

Callers 1

containsMethod · 0.95

Calls 4

toComparableMethod · 0.95
cmpMethod · 0.95
compareToMethod · 0.65
compareMethod · 0.65

Tested by

no test coverage detected