Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.
967744
public static <T> ArrayList<T> sortThis(ArrayList<T> list, Comparator<? super T> comparator)
    {
        int size = list.size();
        if (ArrayListIterate.canAccessInternalArray(list))
        {
            Arrays.sort(ArrayListIterate.getInternalArray(list), 0, size, comparator);
        }
        else
        {
            Collections.sort(list, comparator);
        }
        return list;
    }
1374046
public static void shuffleArray(int[] ar)
    {
        Random rnd = new Random();
        for (int i = ar.length - 1; i > 0; i--)
        {
            int index = rnd.nextInt(i + 1);
            // Simple swap
            int a = ar[index];
            ar[index] = ar[i];
            ar[i] = a;
        }
    }
988946
@Override
    public ImmutableCollection<V> values() {
        Builder<V> builder = ImmutableList.builder();
        for (Cell<V> cell : cells()) {
            builder.add(cell.getValue());
        }
        return builder.build();
    }
498671
public static <E> ImmutableList<E> copyOf(E[] elements) {
    switch (elements.length) {
      case 0:
        return ImmutableList.of();
      case 1:
        return new SingletonImmutableList<E>(elements[0]);
      default:
        return new RegularImmutableList<E>(checkElementsNotNull(elements.clone()));
    }
  }
1264424
@SuppressWarnings("unchecked")
    @Override
    public final <AT> AT[] toArray(AT[] a) {
        this.readLock.lock();
        try {
            // Verify the array size
            if (a.length < this.size) {
                a =
                        (AT[])
                                java.lang.reflect.Array.newInstance(
                                        a.getClass().getComponentType(), this.size);
            }

            // Trick to avoid generics warning
            final Object[] result = a;

            // Copy over all elements
            int index = 0;
            for (final Queue<T> queue : this.keyedQueues.values()) {
                for (final T e : queue) {
                    result[index++] = e;
                }
            }

            // If array is too big set next element null
            if (a.length > this.size) {
                a[this.size] = null;
            }

            return a;
        } finally {
            this.readLock.unlock();
        }
    }
223141
public static <T> ArrayList<T> newArrayList(Iterable<T> elements) {
		return Lists.newArrayList(elements);
	}
73595
public static <T> ArrayList<T> newArrayList(Iterable<T> iterable) {
		return (ArrayList<T>) list(false, iterable);
	}
963198
public static <T> T[] concatAll(final T[] empty, Iterable<T[]> arrayList) {
        assert(empty.length == 0);
        if (arrayList.iterator().hasNext() == false) {
            return empty;
        }

        int len = 0;
        for (T[] subArray : arrayList) {
            len += subArray.length;
        }
        int pos = 0;
        T[] result = Arrays.copyOf(empty, len);
        for (T[] subArray : arrayList) {
            System.arraycopy(subArray, 0, result, pos, subArray.length);
            pos += subArray.length;
        }
        return result;
    }
1133394
function arraySpliceOut(mutate, at, arr) {
    var newLen = arr.length - 1;
    var i = 0;
    var g = 0;
    var out = arr;
    if (mutate) {
        i = g = at;
    } else {
        out = new Array(newLen);
        while (i < at) {
            out[g++] = arr[i++];
        }
    }
    ++i;
    while (i <= newLen) {
        out[g++] = arr[i++];
    }if (mutate) {
        out.length = newLen;
    }
    return out;
}
997681
@Nonnull
    public ImmutableList<T> toList() {
        return this.foldAbelian((v, acc) -> acc.cons(v), ImmutableList.empty());
    }
854097
@SuppressWarnings("unchecked")
    public T[] nextPermutationAsArray()
    {
        T[] permutation = (T[]) Array.newInstance(elements.getClass().getComponentType(),
                                                  permutationIndices.length);
        return nextPermutationAsArray(permutation);
    }
939439
public static <T> Mutator<T> mutate(T t) {
    Objects.requireNonNull(t);
    return new Mutator<>(t);
  }
104871
@Override
	protected MutatorResult<Chromosome<G>> mutate(
		final Chromosome<G> chromosome,
		final double p,
		final Random random
	) {
		final MutatorResult<Chromosome<G>> result;
		if (chromosome.length() > 1) {
			final MSeq<G> genes = chromosome.toSeq().copy();
			final int mutations = (int)indexes(random, genes.length(), p)
				.peek(i -> genes.swap(i, random.nextInt(genes.length())))
				.count();
			result = MutatorResult.of(
				chromosome.newInstance(genes.toISeq()),
				mutations
			);
		} else {
			result = MutatorResult.of(chromosome);
		}

		return result;
	}
412660
@NonNull
    @Override
    public MutableArray remove(int index) {
        synchronized (lock) {
            if (!internalArray.remove(index)) { throwRangeException(index); }
            return this;
        }
    }
721948
private MutateRowsRequest createRetryRequest(List<Integer> indiciesToRetry) {
    MutateRowsRequest.Builder updatedRequest = MutateRowsRequest.newBuilder()
        .setTableName(originalRequest.getTableName());
    mapToOriginalIndex = new int[indiciesToRetry.size()];
    for (int i = 0; i < indiciesToRetry.size(); i++) {
      mapToOriginalIndex[i] = indiciesToRetry.get(i);
      updatedRequest.addEntries(originalRequest.getEntries(indiciesToRetry.get(i)));
    }
    return updatedRequest.build();
  }
660583
private List<SimpleItem> generateUnsortedList() {
        ArrayList<SimpleItem> result = new ArrayList<>(26);

        for (int i = 0; i < 26; i++) {
            result.add(makeItem(i));
        }

        Collections.shuffle(result);

        return result;
    }
453123
static double[] sortAndRevert(final double[] array) {
		final int[] indexes = sort(array);

		// Copy the elements in reversed order.
		final double[] result = new double[array.length];
		for (int i = 0; i < result.length; ++i) {
			result[indexes[result.length - 1 - i]] = array[indexes[i]];
		}

		return result;
	}