Java Array Search memchr(T[] ptr, T value)

Here you can find the source of memchr(T[] ptr, T value)

Description

memchr

License

Open Source License

Declaration

public static <T> int memchr(T[] ptr, T value) 

Method Source Code

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

public class Main {
    public static <T> int memchr(T[] ptr, T value) {
        for (int c = 0; c < ptr.length; c++) {
            if (value.equals(ptr[c]))
                return c;
            if (value.hashCode() == ptr[c].hashCode())
                return c;
        }/*from  w ww.jav a2  s .c  o  m*/
        return -1;
    }
}

Related

  1. isIn(String name, String[] array)
  2. isInArray(final T ch, final T[] a)
  3. isInArray(String needle, String[] haystack)
  4. memchr(boolean[] ary, int start, int len, boolean find)
  5. memchr(char[] haystack, int offset, char needle, int num)
  6. replaceAll(String text, char[] toSearch, char toReplace)
  7. search(double[] input, int[] bounds, double x)
  8. Search(int[] in, int val)
  9. searchFirst(String[] target, String key)