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

Method findHigherEntry

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

Source from the content-addressed store, hash-verified

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

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