package com.bbn.bue.common.collections;

import java.util.AbstractList;
import java.util.List;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Utilities for working with {@link java.util.List}s.
 */
public final class ListUtils {
  private ListUtils() {
    throw new UnsupportedOperationException();
  }

  /**
   * Returns an unmodifiable view of the concatenation of two lists.
   * This view will act like a {@link List} which has all of the items of
   * {@code first} followed by all of the items in {@code second}.
   */
  public static <E> List<E> concat(List<? extends E> first, List<? extends E> second) {
    return new ConcatenatedListView<E>(first, second);
  }

  /**
   * See {@link #concat(List, List)}.
   */
  private static final class ConcatenatedListView<E> extends AbstractList<E> {

    private final List<? extends E> list1;
    private final List<? extends E> list2;

    ConcatenatedListView(final List<? extends E> list1, final List<? extends E> list2) {
      // no defensive copies because this is a view
      this.list1 = checkNotNull(list1);
      this.list2 = checkNotNull(list2);
    }

    @Override
    public E get(final int index) {
      final boolean useFirstList = index < list1.size();
      final List<? extends E> list = useFirstList ? list1 : list2;
      final int modifiedIdx = useFirstList ? index : index - list1.size();
      return list.get(modifiedIdx);
    }

    @Override
    public int size() {
      return list1.size() + list2.size();
    }
  }
}

@@ -45,53 +45,225 @@
 ort 
-java.util.AbstractList;%0Aimport java.util.List
+com.google.common.collect.ImmutableList;%0Aimport com.google.common.collect.Lists;%0A%0Aimport java.util.AbstractList;%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.Random
 ;%0A%0Ai
@@ -859,32 +859,480 @@
 , second);%0A  %7D%0A%0A
+  /**%0A   * Returns a shuffled copy of the provided list.%0A   *%0A   * @param list the list to shuffle%0A   * @param seed the random seed to use when shuffling%0A   * @return a shuffled copy of the list%0A   */%0A  public static %3CE%3E ImmutableList%3CE%3E shuffledCopy(List%3C? extends E%3E list, int seed) %7B%0A    final ArrayList%3CE%3E shuffled = Lists.newArrayList(list);%0A    Collections.shuffle(shuffled, new Random(seed));%0A    return ImmutableList.copyOf(shuffled);%0A  %7D%0A%0A
   /**%0A   * See %7B

Add ListUtils.shuffledCopy