Queue utility function
package arc.struct;
+import arc.func.*;
import arc.util.*;
import java.util.*;
@@ -200,6 +201,22 @@ public class Queue<T> implements Iterable<T>{
return -1;
}
+ public int indexOf(Boolf<T> value){
+ if(size == 0) return -1;
+ T[] values = this.values;
+ final int head = this.head, tail = this.tail;
+ if(head < tail){
+ for(int i = head; i < tail; i++)
+ if(value.get(values[i])) return i - head;
+ }else{
+ for(int i = head, n = values.length; i < n; i++)
+ if(value.get(values[i])) return i - head;
+ for(int i = 0; i < tail; i++)
+ if(value.get(values[i])) return i + values.length - head;
+ }
+ return -1;
+ }
+
public boolean remove(T value){
return remove(value, false);
}
