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

Method findHigherEntry

vm/JavaAPI/src/java/util/TreeMap.java:4141–4198  ·  view source on GitHub ↗
(K key)

Source from the content-addressed store, hash-verified

4139 }
4140
4141 TreeMap.Entry<K, V> findHigherEntry(K key) {
4142 if (root == null) {
4143 return null;
4144 }
4145 java.lang.Comparable<K> object = comparator == null ? toComparable((K) key)
4146 : null;
4147 K keyK = (K) key;
4148 Node<K, V> node = root;
4149 Node<K, V> foundNode = null;
4150 int foundIndex = 0;
4151 while (node != null) {
4152 K[] keys = node.keys;
4153 int right_idx = node.right_idx;
4154 int result = cmp(object, keyK, keys[right_idx]);
4155 if (result >= 0) {
4156 node = node.right;
4157 } else {
4158 foundNode = node;
4159 foundIndex = right_idx;
4160 int left_idx = node.left_idx;
4161 if (left_idx != right_idx) {
4162 result = cmp(object, key, keys[left_idx]);
4163 }
4164 if (result < 0) {
4165 foundNode = node;
4166 foundIndex = left_idx;
4167 node = node.left;
4168 } else { /* search in node */
4169 foundNode = node;
4170 foundIndex = right_idx;
4171 int low = left_idx + 1, mid = 0, high = right_idx - 1;
4172 while (low <= high) {
4173 mid = (low + high) >> 1;
4174 result = cmp(object, key, keys[mid]);
4175 if (result < 0) {
4176 foundNode = node;
4177 foundIndex = mid;
4178 high = mid - 1;
4179 }else {
4180 low = mid + 1;
4181 }
4182 if (low == high && high == mid){
4183 break;
4184 }
4185 }
4186 break;
4187 }
4188 }
4189 }
4190 if (foundNode != null
4191 && cmp(object,keyK, foundNode.keys[foundIndex]) >= 0) {
4192 foundNode = null;
4193 }
4194 if (foundNode != null){
4195 return createEntry(foundNode, foundIndex);
4196 }
4197 return null;
4198 }

Callers 14

higherEntryMethod · 0.95
getBoundaryNodeMethod · 0.45
floorMethod · 0.45
lowerMethod · 0.45
floorMethod · 0.45
lowerMethod · 0.45
theSmallestEntryMethod · 0.45
findStartNodeMethod · 0.45
valuesMethod · 0.45
higherEntryMethod · 0.45
lastEntryMethod · 0.45
pollLastEntryMethod · 0.45

Calls 3

toComparableMethod · 0.95
cmpMethod · 0.95
createEntryMethod · 0.95

Tested by

no test coverage detected