Check whether an array has duplicates.

@param arr {Array} The array.
@param fn {Function} Optional function to apply to each element.
3842
function hasDuplicates(arr, fn) {
  var obj = {};
  var i, l, elem;
  for (i = 0, l = arr.length; i < l; i++) {
    elem = arr[i];
    if (fn) {
      elem = fn(elem);
    }
    if (obj[elem]) {
      return true;
    }
    obj[elem] = true;
  }
  return false;
}
1025950
function clone(arr) {
              	var newArr = [];
              	for (var i=0; i<arr.length; i++) {
              		newArr.push(arr[i]);
              	}
              	return newArr;
              }
1106509
function first(arr, fn) {
  const l = arr.length;
  for (let i = 0; i < l; i += 1) {
    const res = fn(arr[i], i);
    if (res) {
      return res;
    }
  }

  return null;
}
220381
function unique(arr) {
    return arr.filter(function (value, idx, self) {
        return self.indexOf(value) === idx;
    });
}
1133524
def contains_duplicates(values: Iterable[Any]) -> bool:
    
    for v in Counter(values).values():
        if v > 1:
            return True
    return False
504182
function equalSimpleArrays(arr1, arr2) {

	if (arr1 && (arr1.length > 0))
		return (
			arr2 &&
				(arr2.length === arr1.length) &&
				arr2.every((v, i) => (v === arr1[i]))
		);

	return (!arr2 || (arr2.length === 0));
}
420451
def has_duplicate(x):
    
    if not isinstance(x, (np.ndarray, pd.Series)):
        x = np.asarray(x)
    return x.size != np.unique(x).size
817308
public static function unique($arr)
	{
		// filter out all duplicate values
		return array_filter(
			$arr,
			function ($item)
			{
				// contrary to popular belief, this is not as static as you think...
				static $vars = array();

				if (in_array($item, $vars, true))
				{
					// duplicate
					return false;
				}
				else
				{
					// record we've had this value
					$vars[] = $item;

					// unique
					return true;
				}
			}
		);
	}
335650
def has_duplicates(self):
        
        for n in getattr(self.__kcount, _iter_values)():
            if n != 1:
                return True

        def dict_recurse(obj):
            for v in getattr(obj, _iter_values)():
                if isinstance(v, VDFDict) and v.has_duplicates():
                    return True
                elif isinstance(v, dict):
                    return dict_recurse(v)
            return False

        return dict_recurse(self)
169818
function isFunctionArray( value ) {
	var len, i;
	if ( !isArray( value ) ) {
		return false;
	}
	len = value.length;
	if ( !len ) {
		return false;
	}
	for ( i = 0; i < len; i++ ) {
		if ( !isFunction( value[i] ) ) {
			return false;
		}
	}
	return true;
}
756360
function contains(array, value) {
    var result = false;
    each(array, function (item) {
        result = item === value;
        return !result;
    });

    return result;
}
631581
function unique( arr, sort, uniqueFn ){
	var rtn = [];

	if ( arr.length ){
		if ( sort ){
			// more efficient because I can presort
			if ( bmoor.isFunction(sort) ){
				arr = arr.slice(0).sort(sort);
			}

			let last;
			
			for( let i = 0, c = arr.length; i < c; i++ ){
				let d = arr[i],
					v = uniqueFn ? uniqueFn(d) : d;

				if ( v !== last ){
					last = v;
					rtn.push( d );
				}
			}
		}else if ( uniqueFn ){
			let hash = {};

			for( let i = 0, c = arr.length; i < c; i++ ){
				let d = arr[i],
					v = uniqueFn(d);

				if ( !hash[v] ){
					hash[v] = true;
					rtn.push( d );
				}
			}
		}else{
			// greedy and inefficient
			for( let i = 0, c = arr.length; i < c; i++ ){
			 	let d = arr[i];

			 	if ( rtn.indexOf(d) === -1 ){
			 		rtn.push( d );
			 	}
			}
		}
	}

	return rtn;
}
416309
private static @Nullable Integer findDuplicate(int[] array) {
    Set<Integer> seenElements = new LinkedHashSet<>();

    for (int element : array) {
      if (!seenElements.add(element)) {
        return element;
      }
    }

    return null;
  }
714016
function(arr,filterFunc) {
	
	if (arr.filter) { return arr.filter(filterFunc); }
	
	var i = 0,
		l = 0,
		r = [];
	
	for (i = 0, l = arr.length; i < l; i++) {
		if (filterFunc(arr[i])) {
			r.push(arr[i]);
		}
	}
	
	return r;
}
707336
function(fn) {
			var item = utils.find(this._list, function(item) {
				return item.fn === fn;
			});
			if (item) {
				this._list.splice(this._list.indexOf(item), 1);
			}
		}
303476
function unique( arr, sorted ) {
	if ( !Array.isArray( arr ) ) {
		throw new TypeError( 'unique()::invalid input argument. First argument must be an array.' );
	}
	if ( arguments.length > 1 && typeof sorted !== 'boolean' ) {
		throw new TypeError( 'unique()::invalid input argument. Second argument must be an array.' );
	}
	var len = arr.length,
		i, j,
		val;

	if ( !len ) {
		return;
	}
	if ( !sorted ) {
		arr.sort( ascending );
	}
	// Loop through the array, only incrementing a pointer when successive values are different. When a succeeding value is different, move the pointer and set the next value. In the trivial case where all array elements are unique, we incur a slight penalty in resetting the element value for each unique value. In other cases, we simply move a unique value to a new position in the array. The end result is a sorted array with unique values.
	for ( i = 1, j = 0; i < len; i++ ) {
		val = arr[ i ];
		if ( arr[ j ] !== val ) {
			j++;
			arr[ j ] = val;
		}
	}
	// Truncate the array:
	arr.length = j+1;
}
1208063
public static boolean haveEqualArrays(int[] arra, int[] arrb, int count) {

        if (count > arra.length || count > arrb.length) {
            return false;
        }

        for (int j = 0; j < count; j++) {
            if (arra[j] != arrb[j]) {
                return false;
            }
        }

        return true;
    }