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

Method findCeilingEntry

Ports/CLDC11/src/java/util/TreeMap.java:3964–4026  ·  view source on GitHub ↗
(K key)

Source from the content-addressed store, hash-verified

3962 }
3963
3964 TreeMap.Entry<K, V> findCeilingEntry(K key) {
3965 if (root == null) {
3966 return null;
3967 }
3968 java.lang.Comparable<K> object = comparator == null ? toComparable((K) key)
3969 : null;
3970 K keyK = (K) key;
3971 Node<K, V> node = root;
3972 Node<K, V> foundNode = null;
3973 int foundIndex = 0;
3974 while (node != null) {
3975 K[] keys = node.keys;
3976 int left_idx = node.left_idx;
3977 int right_idx = node.right_idx;
3978 int result = cmp(object, keyK, keys[left_idx]);
3979 if (result < 0) {
3980 foundNode = node;
3981 foundIndex = left_idx;
3982 node = node.left;
3983 } else if (result == 0) {
3984 foundNode = node;
3985 foundIndex = left_idx;
3986 break;
3987 } else {
3988 if (left_idx != right_idx) {
3989 result = cmp(object, key, keys[right_idx]);
3990 }
3991 if (result > 0) {
3992 node = node.right;
3993 } else { /* search in node */
3994 foundNode = node;
3995 foundIndex = right_idx;
3996 if (result == 0) {
3997 break;
3998 }
3999 int low = left_idx + 1, mid = 0, high = right_idx - 1;
4000 while (low <= high && result != 0) {
4001 mid = (low + high) >> 1;
4002 result = cmp(object, key, keys[mid]);
4003 if (result <= 0) {
4004 foundNode = node;
4005 foundIndex = mid;
4006 high = mid - 1;
4007 }else {
4008 low = mid + 1;
4009 }
4010 if (result == 0 || (low == high && high == mid)){
4011 break;
4012 }
4013 }
4014 break;
4015 }
4016 }
4017 }
4018 if (foundNode != null
4019 && cmp(object,keyK, foundNode.keys[foundIndex]) > 0) {
4020 foundNode = null;
4021 }

Callers 12

ceilingEntryMethod · 0.95
getBoundaryNodeMethod · 0.45
floorMethod · 0.45
floorMethod · 0.45
lowerMethod · 0.45
theSmallestEntryMethod · 0.45
findStartNodeMethod · 0.45
ceilingEntryMethod · 0.45
lastEntryMethod · 0.45
pollLastEntryMethod · 0.45
lowerEntryMethod · 0.45
floorEntryMethod · 0.45

Calls 3

toComparableMethod · 0.95
cmpMethod · 0.95
createEntryMethod · 0.95

Tested by

no test coverage detected