Exemplo n.º 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);
 }
Exemplo n.º 2
0
 private static <E> ImmutableList<E> copyOfInternal(ArrayList<? extends E> list) {
   return (list.isEmpty())
       ? ImmutableList.<E>of()
       : new RegularImmutableList<E>(nullChecked(list.toArray()));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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));
 }