Returns an array containing only elements found in {@code first} and also in {@code
second}. The returned elements are in the same order as in {@code first}.
420560
public static String[] intersect(
      Comparator<? super String> comparator, String[] first, String[] second) {
    List<String> result = new ArrayList<>();
    for (String a : first) {
      for (String b : second) {
        if (comparator.compare(a, b) == 0) {
          result.add(a);
          break;
        }
      }
    }
    return result.toArray(new String[0]);
  }
743503
public static <T> boolean isEqual(final T first, final T second) {
        /* test to see if they are both null, or both reference the same object */
        if (first == second) return true;

        if (first == null && second != null) return false;

        return first.equals(second);
    }
627115
public static <E> Collection<E> difference(Set<E> first, Set<E> second, Function<E, Integer> hasher) {
        if (first == null || first.size() == 0) {
            return Collections.emptyList();
        }

        if (second == null || second.size() == 0) {
            return first;
        }

        Map<Integer, E> map = new HashMap();

        first.stream().forEach(e -> map.put(hasher.apply(e), e));
        second.stream().forEach(e -> map.remove(hasher.apply(e)));

        return Collections.unmodifiableCollection(map.values());
    }
1269914
function(first, second) {
			var start = 0;
			var max = 0;

			for (var i = 0; i < first.length; i++) {
				for (var j = 0; j < second.length; j++) {
					var x = 0;
					while (first[i + x] === second[j + x]) {
						x++;
						if ((i + x >= first.length) || (j + x >= second.length)) {
							break;
						}
					}
					if (x > max) {
						max = x;
						start = i;
					}
				}
			}

			return first.slice(start, start + max);
		}
920230
private static <T> List<T> intersect(T[] first, T[] second) {
    List<T> result = new ArrayList<>();
    for (T a : first) {
      for (T b : second) {
        if (a.equals(b)) {
          result.add(b);
          break;
        }
      }
    }
    return result;
  }
1281977
public static boolean containSameElementsSorted(short[]... arrs) {
		Validate.notNull(arrs);
		if (arrs.length == 1)
			return true;

		int firstSize = arrs[0].length;
		for (int i = 1; i < arrs.length; i++) {
			if (arrs[i].length != firstSize) {
				return false;
			}
		}

		for (int j = 0; j < firstSize; j++) {
			short firstValue = arrs[0][j];
			for (int k = 1; k < arrs.length; k++) {
				if (arrs[k][j] != firstValue)
					return false;
			}
		}
		return true;
	}
242579
@SuppressWarnings({"unchecked"})
    public static <T> T[] arrayOf(T[] firstElements, T lastElement) {
        checkArgNotNull(firstElements, "firstElements");
        Class elementType = firstElements.getClass().getComponentType();
        T[] array = (T[]) Array.newInstance(elementType, firstElements.length + 1);
        System.arraycopy(firstElements, 0, array, 0, firstElements.length);
        array[firstElements.length] = lastElement;
        return array;
    }
476862
public static Restriction and(Restriction r1, Restriction r2) {
        return new And(Arrays.asList(r1, r2));
    }
747035
public int compare(final T first, final T second) {
    if (first.equals(second)) return 0;
    else return first.size() - second.size();
  }
897342
public int[] next()
    {
        boolean hasNewPerm = false;

        escape:while( level >= 0) {
//            boolean foundZero = false;
            for( int i = iter[level]; i < data.length; i = iter[level] ) {
                iter[level]++;

                if( data[i] == -1 ) {
                    level++;
                    data[i] = level-1;

                    if( level >= data.length ) {
                        // a new permutation has been created return the results.
                        hasNewPerm = true;
                        System.arraycopy(data,0,ret,0,ret.length);
                        level = level-1;
                        data[i] = -1;
                        break escape;
                    } else {
                        valk[level] = i;
                    }
                }
            }

            data[valk[level]] = -1;
            iter[level] = 0;
            level = level-1;

        }

        if( hasNewPerm )
            return ret;
        return null;
    }
141504
public static <T> Predicate<T> and(Predicate<T> first, Predicate<T> second) {
        dbc.precondition(first != null, "first predicate is null");
        dbc.precondition(second != null, "second predicate is null");
        return Logic.Unary.and(Iterations.iterable(first, second));
    }
506304
@Override
    public int first() {
        fCachedBreakPositions = null;
        fDictionaryCharCount = 0;
        fPositionInCache = 0;
        fLastRuleStatusIndex  = 0;
        fLastStatusIndexValid = true;
        if (fText == null) {
            return BreakIterator.DONE;
        }
        fText.first();
        return fText.getIndex();
    }
50350
public Object nextElement() 
    {
        if (_array == null)
        {
            return null;
        }
        else
        {
            synchronized(this){
                if (_index < _array.length)
                {
                    Object obj = _array[_index];
                    _index++;
                    return obj;
                }
                else
                {
                    return null;
                }
            }
        }
    }
1363987
public boolean inOrder() {
        SortedSet<Integer> prev = null;
        for (SortedSet<Integer> cell : cells) {
            if (prev == null) {
                prev = cell;
            } else {
                int first = cell.first();
                int last = cell.last();
                if (first > prev.first() && last > prev.last()) {
                    prev = cell;
                } else {
                    return false;
                }
            }
        }
        return true;
    }
808862
@SuppressWarnings({"unchecked"})
    public static <T> T[] arrayOf(T firstElement, T... moreElements) {
        checkArgNotNull(moreElements, "moreElements");
        Class elementType = moreElements.getClass().getComponentType();
        T[] array = (T[]) Array.newInstance(elementType, moreElements.length + 1);
        array[0] = firstElement;
        System.arraycopy(moreElements, 0, array, 1, moreElements.length);
        return array;
    }
1089385
public List<B> getOutcomesByProbability(A first) {
    if (counts.containsKey(first)) {
      Map<B, Double> sortedMap = MapUtils.reverse(MapUtils.sortByValue(counts.get(first)));
      return Lists.newArrayList(sortedMap.keySet());
    }
    return Collections.emptyList();
  }
192749
public static <T> Collection<T> intersect(Collection<T> first,
                                              Collection<T> second) {
        E.checkNotNull(first, "first");
        E.checkNotNull(second, "second");

        HashSet<T> results = null;
        if (first instanceof HashSet) {
            @SuppressWarnings("unchecked")
            HashSet<T> clone = (HashSet<T>) ((HashSet<T>) first).clone();
            results = clone;
        } else {
            results = new HashSet<>(first);
        }
        results.retainAll(second);
        return results;
    }