Java List Contain contains(int[] list, int x)

Here you can find the source of contains(int[] list, int x)

Description

contains

License

Open Source License

Declaration

public static int contains(int[] list, int x) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;

public class Main {
    public static int contains(int[] list, int x) {
        int pos = -1;
        if (list.length > 10)
            pos = Arrays.binarySearch(list, x);
        else/*from  ww  w.  j av  a 2 s  .c o m*/
            for (int i = 0; i < list.length; i++)
                if (list[i] == x)
                    pos = i;
        return pos >= 0 ? pos : -1;
    }
}

Related

  1. contains(final List list, final String str)
  2. contains(final List requested, final List claimed)
  3. contains(final List list, T value)
  4. contains(final String text, final List tokens)
  5. contains(final String[] list, final String value)
  6. contains(int[] match, List container)
  7. contains(int[] subject, int[][] list)
  8. contains(List aList, Object anObj)
  9. contains(List list, Object obj)