Tabnine Logo
ArrayList.newCapacity
Code IndexAdd Tabnine to your IDE (free)

How to use
newCapacity
method
in
java.util.ArrayList

Best Java code snippets using java.util.ArrayList.newCapacity (Showing top 20 results out of 315)

origin: robovm/robovm

/**
 * Adds the objects in the specified collection to this {@code ArrayList}.
 *
 * @param collection
 *            the collection of objects.
 * @return {@code true} if this {@code ArrayList} is modified, {@code false}
 *         otherwise.
 */
@Override public boolean addAll(Collection<? extends E> collection) {
  Object[] newPart = collection.toArray();
  int newPartSize = newPart.length;
  if (newPartSize == 0) {
    return false;
  }
  Object[] a = array;
  int s = size;
  int newSize = s + newPartSize; // If add overflows, arraycopy will fail
  if (newSize > a.length) {
    int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
    Object[] newArray = new Object[newCapacity];
    System.arraycopy(a, 0, newArray, 0, s);
    array = a = newArray;
  }
  System.arraycopy(newPart, 0, a, s, newPartSize);
  size = newSize;
  modCount++;
  return true;
}
origin: robovm/robovm

} else {
  Object[] newArray = new Object[newCapacity(s)];
  System.arraycopy(a, 0, newArray, 0, index);
  System.arraycopy(a, index, newArray, index + 1, s - index);
origin: robovm/robovm

   System.arraycopy(a, index, a, index + newPartSize, s - index);
} else {
  int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
  Object[] newArray = new Object[newCapacity];
  System.arraycopy(a, 0, newArray, 0, index);
origin: MobiVM/robovm

/**
 * Adds the objects in the specified collection to this {@code ArrayList}.
 *
 * @param collection
 *            the collection of objects.
 * @return {@code true} if this {@code ArrayList} is modified, {@code false}
 *         otherwise.
 */
@Override public boolean addAll(Collection<? extends E> collection) {
  Object[] newPart = collection.toArray();
  int newPartSize = newPart.length;
  if (newPartSize == 0) {
    return false;
  }
  Object[] a = array;
  int s = size;
  int newSize = s + newPartSize; // If add overflows, arraycopy will fail
  if (newSize > a.length) {
    int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
    Object[] newArray = new Object[newCapacity];
    System.arraycopy(a, 0, newArray, 0, s);
    array = a = newArray;
  }
  System.arraycopy(newPart, 0, a, s, newPartSize);
  size = newSize;
  modCount++;
  return true;
}
origin: ibinti/bugvm

/**
 * Adds the objects in the specified collection to this {@code ArrayList}.
 *
 * @param collection
 *            the collection of objects.
 * @return {@code true} if this {@code ArrayList} is modified, {@code false}
 *         otherwise.
 */
@Override public boolean addAll(Collection<? extends E> collection) {
  Object[] newPart = collection.toArray();
  int newPartSize = newPart.length;
  if (newPartSize == 0) {
    return false;
  }
  Object[] a = array;
  int s = size;
  int newSize = s + newPartSize; // If add overflows, arraycopy will fail
  if (newSize > a.length) {
    int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
    Object[] newArray = new Object[newCapacity];
    System.arraycopy(a, 0, newArray, 0, s);
    array = a = newArray;
  }
  System.arraycopy(newPart, 0, a, s, newPartSize);
  size = newSize;
  modCount++;
  return true;
}
origin: com.bugvm/bugvm-rt

/**
 * Adds the objects in the specified collection to this {@code ArrayList}.
 *
 * @param collection
 *            the collection of objects.
 * @return {@code true} if this {@code ArrayList} is modified, {@code false}
 *         otherwise.
 */
@Override public boolean addAll(Collection<? extends E> collection) {
  Object[] newPart = collection.toArray();
  int newPartSize = newPart.length;
  if (newPartSize == 0) {
    return false;
  }
  Object[] a = array;
  int s = size;
  int newSize = s + newPartSize; // If add overflows, arraycopy will fail
  if (newSize > a.length) {
    int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
    Object[] newArray = new Object[newCapacity];
    System.arraycopy(a, 0, newArray, 0, s);
    array = a = newArray;
  }
  System.arraycopy(newPart, 0, a, s, newPartSize);
  size = newSize;
  modCount++;
  return true;
}
origin: com.mobidevelop.robovm/robovm-rt

/**
 * Adds the objects in the specified collection to this {@code ArrayList}.
 *
 * @param collection
 *            the collection of objects.
 * @return {@code true} if this {@code ArrayList} is modified, {@code false}
 *         otherwise.
 */
@Override public boolean addAll(Collection<? extends E> collection) {
  Object[] newPart = collection.toArray();
  int newPartSize = newPart.length;
  if (newPartSize == 0) {
    return false;
  }
  Object[] a = array;
  int s = size;
  int newSize = s + newPartSize; // If add overflows, arraycopy will fail
  if (newSize > a.length) {
    int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
    Object[] newArray = new Object[newCapacity];
    System.arraycopy(a, 0, newArray, 0, s);
    array = a = newArray;
  }
  System.arraycopy(newPart, 0, a, s, newPartSize);
  size = newSize;
  modCount++;
  return true;
}
origin: com.gluonhq/robovm-rt

/**
 * Adds the objects in the specified collection to this {@code ArrayList}.
 *
 * @param collection
 *            the collection of objects.
 * @return {@code true} if this {@code ArrayList} is modified, {@code false}
 *         otherwise.
 */
@Override public boolean addAll(Collection<? extends E> collection) {
  Object[] newPart = collection.toArray();
  int newPartSize = newPart.length;
  if (newPartSize == 0) {
    return false;
  }
  Object[] a = array;
  int s = size;
  int newSize = s + newPartSize; // If add overflows, arraycopy will fail
  if (newSize > a.length) {
    int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
    Object[] newArray = new Object[newCapacity];
    System.arraycopy(a, 0, newArray, 0, s);
    array = a = newArray;
  }
  System.arraycopy(newPart, 0, a, s, newPartSize);
  size = newSize;
  modCount++;
  return true;
}
origin: FlexoVM/flexovm

/**
 * Adds the objects in the specified collection to this {@code ArrayList}.
 *
 * @param collection
 *            the collection of objects.
 * @return {@code true} if this {@code ArrayList} is modified, {@code false}
 *         otherwise.
 */
@Override public boolean addAll(Collection<? extends E> collection) {
  Object[] newPart = collection.toArray();
  int newPartSize = newPart.length;
  if (newPartSize == 0) {
    return false;
  }
  Object[] a = array;
  int s = size;
  int newSize = s + newPartSize; // If add overflows, arraycopy will fail
  if (newSize > a.length) {
    int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
    Object[] newArray = new Object[newCapacity];
    System.arraycopy(a, 0, newArray, 0, s);
    array = a = newArray;
  }
  System.arraycopy(newPart, 0, a, s, newPartSize);
  size = newSize;
  modCount++;
  return true;
}
origin: MobiVM/robovm

} else {
  Object[] newArray = new Object[newCapacity(s)];
  System.arraycopy(a, 0, newArray, 0, index);
  System.arraycopy(a, index, newArray, index + 1, s - index);
origin: ibinti/bugvm

} else {
  Object[] newArray = new Object[newCapacity(s)];
  System.arraycopy(a, 0, newArray, 0, index);
  System.arraycopy(a, index, newArray, index + 1, s - index);
origin: com.bugvm/bugvm-rt

} else {
  Object[] newArray = new Object[newCapacity(s)];
  System.arraycopy(a, 0, newArray, 0, index);
  System.arraycopy(a, index, newArray, index + 1, s - index);
origin: com.mobidevelop.robovm/robovm-rt

} else {
  Object[] newArray = new Object[newCapacity(s)];
  System.arraycopy(a, 0, newArray, 0, index);
  System.arraycopy(a, index, newArray, index + 1, s - index);
origin: com.gluonhq/robovm-rt

} else {
  Object[] newArray = new Object[newCapacity(s)];
  System.arraycopy(a, 0, newArray, 0, index);
  System.arraycopy(a, index, newArray, index + 1, s - index);
origin: FlexoVM/flexovm

} else {
  Object[] newArray = new Object[newCapacity(s)];
  System.arraycopy(a, 0, newArray, 0, index);
  System.arraycopy(a, index, newArray, index + 1, s - index);
origin: MobiVM/robovm

   System.arraycopy(a, index, a, index + newPartSize, s - index);
} else {
  int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
  Object[] newArray = new Object[newCapacity];
  System.arraycopy(a, 0, newArray, 0, index);
origin: com.mobidevelop.robovm/robovm-rt

   System.arraycopy(a, index, a, index + newPartSize, s - index);
} else {
  int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
  Object[] newArray = new Object[newCapacity];
  System.arraycopy(a, 0, newArray, 0, index);
origin: ibinti/bugvm

   System.arraycopy(a, index, a, index + newPartSize, s - index);
} else {
  int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
  Object[] newArray = new Object[newCapacity];
  System.arraycopy(a, 0, newArray, 0, index);
origin: com.bugvm/bugvm-rt

   System.arraycopy(a, index, a, index + newPartSize, s - index);
} else {
  int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
  Object[] newArray = new Object[newCapacity];
  System.arraycopy(a, 0, newArray, 0, index);
origin: com.gluonhq/robovm-rt

   System.arraycopy(a, index, a, index + newPartSize, s - index);
} else {
  int newCapacity = newCapacity(newSize - 1);  // ~33% growth room
  Object[] newArray = new Object[newCapacity];
  System.arraycopy(a, 0, newArray, 0, index);
java.utilArrayListnewCapacity

Javadoc

This method controls the growth of ArrayList capacities. It represents a time-space tradeoff: we don't want to grow lists too frequently (which wastes time and fragments storage), but we don't want to waste too much space in unused excess capacity. NOTE: This method is inlined into #add(Object) for performance. If you change the method, change it there too!

Popular methods of ArrayList

  • <init>
  • add
  • size
    Returns the number of elements in this ArrayList.
  • get
    Returns the element at the specified position in this list.
  • toArray
    Returns an array containing all of the elements in this list in proper sequence (from first to last
  • addAll
    Adds the objects in the specified collection to this ArrayList.
  • remove
    Removes the first occurrence of the specified element from this list, if it is present. If the list
  • clear
    Removes all elements from this ArrayList, leaving it empty.
  • isEmpty
    Returns true if this list contains no elements.
  • iterator
    Returns an iterator over the elements in this list in proper sequence.The returned iterator is fail-
  • contains
    Searches this ArrayList for the specified object.
  • set
    Replaces the element at the specified position in this list with the specified element.
  • contains,
  • set,
  • indexOf,
  • clone,
  • subList,
  • stream,
  • ensureCapacity,
  • trimToSize,
  • removeAll,
  • toString

Popular in Java

  • Start an intent from android
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getExternalFilesDir (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now