Lines Matching refs:list

36  * list.
45 * A specification for which index to return if the list contains at least one element that
50 * Return the index of any list element that compares as equal to the key. No guarantees are
56 Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
61 * Return the index of the last list element that compares as equal to the key.
66 Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
70 int upper = list.size() - 1;
74 int c = comparator.compare(list.get(middle), key);
85 * Return the index of the first list element that compares as equal to the key.
90 Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
99 int c = comparator.compare(list.get(middle), key);
110 * Return the index of the first list element that compares as greater than the key, or {@code
111 * list.size()} if there is no such element.
116 Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
117 return LAST_PRESENT.resultIndex(comparator, key, list, foundIndex) + 1;
121 * Return the index of the last list element that compares as less than the key, or {@code -1}
127 Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) {
128 return FIRST_PRESENT.resultIndex(comparator, key, list, foundIndex) - 1;
132 Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex);
136 * A specification for which index to return if the list contains no elements that compare as
141 * Return the index of the next lower element in the list, or {@code -1} if there is no such
151 * Return the index of the next higher element in the list, or {@code list.size()} if there is
162 * which the key would be inserted into the list: the index of the next higher element in the
163 * list, or {@code list.size()} if there is no such element.
166 * list that compares as equal to the key.
183 * Searches the specified naturally ordered list for the specified object using the binary search
189 public static <E extends Comparable> int binarySearch(List<? extends E> list, E e,
193 list, checkNotNull(e), Ordering.natural(), presentBehavior, absentBehavior);
197 * Binary searches the list for the specified key, using the specified key function.
202 public static <E, K extends Comparable> int binarySearch(List<E> list,
206 list,
215 * Binary searches the list for the specified key, using the specified key function.
219 * {@link Lists#transform(List, Function) Lists.transform(list, keyFunction)}.
222 List<E> list,
229 Lists.transform(list, keyFunction), key, keyComparator, presentBehavior, absentBehavior);
233 * Searches the specified list for the specified object using the binary search algorithm. The
234 * list must be sorted into ascending order according to the specified comparator (as by the
238 * <p>If there are elements in the list which compare as equal to the key, the choice of
243 * access to each list element.
245 * @param list the list to be searched.
247 * @param comparator the comparator by which the list is ordered.
248 * @param presentBehavior the specification for what to do if at least one element of the list
250 * @param absentBehavior the specification for what to do if no elements of the list compare as
252 * @return the index determined by the {@code KeyPresentBehavior}, if the key is in the list;
255 public static <E> int binarySearch(List<? extends E> list, @Nullable E key,
259 checkNotNull(list);
262 if (!(list instanceof RandomAccess)) {
263 list = Lists.newArrayList(list);
268 int upper = list.size() - 1;
272 int c = comparator.compare(key, list.get(middle));
279 comparator, key, list.subList(lower, upper + 1), middle - lower);