Java Utililty Methods List IndexOf

List of utility methods to do List IndexOf

Description

The list of methods to do List IndexOf are organized into topic(s).

Method

intindexOf(final String regex, final List list)
Gets the index of the first occurrence of the given regex.
assert regex != null : "Regex cannot be null!";
assert list != null : "List cannot be null!";
for (int i = 0; i < list.size(); i++) {
    if (list.get(i).matches(regex)) {
        return i;
return -1;
...
intindexOf(int hash, List list)
Gets the index of the item occurrence matching the specified hashcode.
Iterator<?> iterator = list.iterator();
for (int i = 0; iterator.hasNext(); i++) {
    if (iterator.next().hashCode() == hash) {
        return i;
return -1;
intindexOf(int start, List datas, T target)
index Of
int index = -1;
for (int i = start; i < datas.size(); i++) {
    if (datas.get(i).equals(target)) {
        index = i;
        break;
return index;
...
intindexOf(List list, Object element, int begin, int end)
index Of
begin = Math.min(begin, list.size());
end = Math.min(end, list.size());
if (begin == 0 && end == list.size())
    return list.indexOf(element);
for (int i = begin; i < end; i++) {
    if (Objects.equals(element, list.get(i)))
        return i;
return -1;
intindexOf(List data, List token)
Return the index of first occuernce of token in data.
int result = -1;
if (data.size() > token.size()) {
    List<Byte> aux;
    for (int i = 0; i <= data.size() - token.size(); i++) {
        aux = data.subList(i, i + token.size());
        if (aux.equals(token))
            return i;
return result;
intindexOf(List source, List target)
index Of
return indexOf(source, target, 0);
intindexOf(List lines, String... conditions)
index Of
int i = 0;
for (String line : lines) {
    if (matchLine(line, conditions))
        return i;
    i++;
return -1;
intindexOf(List list, T string, int beginIndex)
A List#indexOf(Object) which begins the search at a particular index.
for (int i = beginIndex; i < list.size(); i++) {
    if (string.equals(list.get(i))) {
        return i;
return -1;
intindexOf(Object o, Collection list)
get an index of object in the collection.
int n = 1;
for (Object oo : list) {
    if (oo.equals(0)) {
        return n;
    n++;
return -1;
...
intindexOfFactory(List factories, Class classInstance)
Returns the index of the factory with the given class in the List .
int result = -1;
Iterator<?> iter = factories.iterator();
int i = 0;
while (result < 0 && iter.hasNext()) {
    if (classInstance.equals(iter.next().getClass())) {
        result = i;
    i++;
...