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

Method get

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

Source from the content-addressed store, hash-verified

4267 /// if the key is `null` and the comparator cannot handle
4268 /// `null`.
4269 @SuppressWarnings("unchecked")
4270 @Override
4271 public V get(Object key) {
4272 java.lang.Comparable<K> object = comparator == null ? toComparable((K) key)
4273 : null;
4274 K keyK = (K) key;
4275 Node<K, V> node = root;
4276 while (node != null) {
4277 K[] keys = node.keys;
4278 int left_idx = node.left_idx;
4279 int result = cmp(object, keyK, keys[left_idx]);
4280 if (result < 0) {
4281 node = node.left;
4282 } else if (result == 0) {
4283 return node.values[left_idx];
4284 } else {
4285 int right_idx = node.right_idx;
4286 if (left_idx != right_idx) {
4287 result = cmp(object, keyK, keys[right_idx]);
4288 }
4289 if (result > 0) {
4290 node = node.right;
4291 } else if (result == 0) {
4292 return node.values[right_idx];
4293 } else { /* search in node */
4294 int low = left_idx + 1, mid = 0, high = right_idx - 1;
4295 while (low <= high) {
4296 mid = (low + high) >>> 1;
4297 result = cmp(object, keyK, keys[mid]);
4298 if (result > 0) {
4299 low = mid + 1;
4300 } else if (result == 0) {
4301 return node.values[mid];
4302 } else {
4303 high = mid - 1;
4304 }
4305 }
4306 return null;
4307 }
4308 }
4309 }
4310 return null;
4311 }
4312
4313 /// Returns a set of the keys contained in this map. The set is backed by
4314 /// this map so changes to one are reflected by the other. The set does not

Callers 1

containsMethod · 0.95

Calls 2

toComparableMethod · 0.95
cmpMethod · 0.95

Tested by

no test coverage detected