Example #1
0
 @Override
 public ImmutableList<E> subList(int fromIndex, int toIndex) {
   Preconditions.checkPositionIndexes(fromIndex, toIndex, size);
   return (fromIndex == toIndex)
       ? ImmutableList.<E>of()
       : new RegularImmutableList<E>(array, offset + fromIndex, toIndex - fromIndex);
 }
Example #2
0
 private static <E> ImmutableList<E> copyOfInternal(ArrayList<? extends E> list) {
   return (list.isEmpty())
       ? ImmutableList.<E>of()
       : new RegularImmutableList<E>(nullChecked(list.toArray()));
 }
Example #3
0
 private static <E> ImmutableList<E> copyOfInternal(Collection<? extends E> collection) {
   int size = collection.size();
   return (size == 0)
       ? ImmutableList.<E>of()
       : ImmutableList.<E>createFromIterable(collection, size);
 }
Example #4
0
 /**
  * Returns an immutable list containing the given elements, in order.
  *
  * @throws NullPointerException if any of {@code elements} is null
  */
 public static <E> ImmutableList<E> of(E... elements) {
   return (elements.length == 0)
       ? ImmutableList.<E>of()
       : new RegularImmutableList<E>(copyIntoArray(elements));
 }