MCPcopy
hub / github.com/libgdx/libgdx / indexOf

Method indexOf

gdx/src/com/badlogic/gdx/utils/Queue.java:185–211  ·  view source on GitHub ↗

Returns the index of first occurrence of value in the queue, or -1 if no such value exists. @param identity If true, == comparison will be used. If false, .equals() comparison will be used. @return An index of first occurrence of value in queue or -1 if no such value exists

(T value, boolean identity)

Source from the content-addressed store, hash-verified

183 * @param identity If true, == comparison will be used. If false, .equals() comparison will be used.
184 * @return An index of first occurrence of value in queue or -1 if no such value exists */
185 public int indexOf (T value, boolean identity) {
186 if (size == 0) return -1;
187 T[] values = this.values;
188 final int head = this.head, tail = this.tail;
189 if (identity || value == null) {
190 if (head < tail) {
191 for (int i = head; i < tail; i++)
192 if (values[i] == value) return i - head;
193 } else {
194 for (int i = head, n = values.length; i < n; i++)
195 if (values[i] == value) return i - head;
196 for (int i = 0; i < tail; i++)
197 if (values[i] == value) return i + values.length - head;
198 }
199 } else {
200 if (head < tail) {
201 for (int i = head; i < tail; i++)
202 if (value.equals(values[i])) return i - head;
203 } else {
204 for (int i = head, n = values.length; i < n; i++)
205 if (value.equals(values[i])) return i - head;
206 for (int i = 0; i < tail; i++)
207 if (value.equals(values[i])) return i + values.length - head;
208 }
209 }
210 return -1;
211 }
212
213 /** Removes the first instance of the specified value in the queue.
214 * @param identity If true, == comparison will be used. If false, .equals() comparison will be used.

Callers 15

addFirstAndLastTestMethod · 0.95
removeLastTestMethod · 0.95
removeFirstTestMethod · 0.95
indexOfTestMethod · 0.95
removeValueMethod · 0.95
getEntriesAtMethod · 0.45
printMethod · 0.45
listFilesMethod · 0.45
encodeMethod · 0.45
countTokensMethod · 0.45
hasMoreTokensMethod · 0.45
nextTokenMethod · 0.45

Calls 1

equalsMethod · 0.45

Tested by 9

addFirstAndLastTestMethod · 0.76
removeLastTestMethod · 0.76
removeFirstTestMethod · 0.76
indexOfTestMethod · 0.76
keyDownMethod · 0.36
keyDownMethod · 0.36
keyDownMethod · 0.36
verifyCorrectnessMethod · 0.36
parseMethod · 0.36