Java Collection Contain contains(Collection searchIn, Object[] find)

Here you can find the source of contains(Collection searchIn, Object[] find)

Description

contains

License

Open Source License

Declaration

public static boolean contains(Collection searchIn, Object[] find) 

Method Source Code


//package com.java2s;
import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static boolean contains(Collection searchIn, Object[] find) {
        for (Iterator iterator = searchIn.iterator(); iterator.hasNext();) {
            Object[] objects = (Object[]) iterator.next();
            if (arraysEquals(objects, find)) {
                return true;
            }//from  ww  w .  j  a  v a  2 s .c o m
        }
        return false;
    }

    private static boolean arraysEquals(Object[] mThis, Object[] mThat) {
        if (mThis.length == mThat.length) {
            for (int i = 0; i < mThis.length; i++) {
                if (!((mThis[i] == null) && (mThat[i] == null))) {
                    if ((mThis[i] == null) || (mThat[i] == null) || (!mThis[i].equals(mThat[i]))) {
                        return false;
                    }
                }
            }
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. contains( C collection, K key)
  2. contains(Collection c, Object o, Comparator comparator)
  3. contains(Collection coll, Object o, Comparator c)
  4. contains(Collection collection, Object object)
  5. contains(Collection objects, Object o)
  6. contains(Collection stringCollection, String value)
  7. contains(Collection collection, A value)
  8. contains(Collection objectArray, Object element)
  9. contains(Collection container, String strSearch)

  10. HOME | Copyright © www.java2s.com 2016