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

How to use
remove
method
in
java.util.ArrayList

Best Java code snippets using java.util.ArrayList.remove (Showing top 20 results out of 29,610)

Refine searchRefine arrow

  • ArrayList.size
  • ArrayList.get
  • ArrayList.add
  • ArrayList.<init>
  • PrintStream.println
canonical example by Tabnine

private void usingArrayList() {
 ArrayList<String> list = new ArrayList<>(Arrays.asList("cat", "cow", "dog"));
 list.add("fish");
 int size = list.size(); // size = 4
 list.set(size - 1, "horse"); // replacing the last element to "horse"
 String removed = list.remove(1); // removed = "cow"
 String second = list.get(1); // second = "dog"
}
origin: apache/incubator-dubbo

State popStack() {
  return _stateStack.remove(_stateStack.size() - 1);
}
origin: facebook/stetho

public synchronized boolean unregister(PathMatcher path, HttpHandler handler) {
 int index = mPathMatchers.indexOf(path);
 if (index >= 0) {
  if (handler == mHttpHandlers.get(index)) {
   mPathMatchers.remove(index);
   mHttpHandlers.remove(index);
   return true;
  }
 }
 return false;
}
origin: ksoichiro/Android-ObservableScrollView

private void removeFixedViewInfo(View v, ArrayList<FixedViewInfo> where) {
  int len = where.size();
  for (int i = 0; i < len; ++i) {
    FixedViewInfo info = where.get(i);
    if (info.view == v) {
      where.remove(i);
      break;
    }
  }
}
origin: alibaba/jstorm

private ArrayList<Integer> rotating_random_range(int amt) {
  ArrayList<Integer> range = new ArrayList<>();
  for (int i = 0; i < amt; i++) {
    range.add(i);
  }
  ArrayList<Integer> rtn = new ArrayList<>();
  for (int i = 0; i < amt; i++) {
    int index = (int) (Math.random() * range.size());
    rtn.add(range.remove(index));
  }
  return rtn;
}
origin: spotbugs/spotbugs

  /** Concurrent modification bug */

  public static void main(String[] args) {
    ArrayList<String> namesList = new ArrayList<String>();

    namesList.add("Kelly");
    namesList.add("John");
    namesList.add("Peter");
    namesList.add("Rose");


    for (Iterator<String> i = namesList.iterator(); i.hasNext(); ) {
      String name = i.next();
      if (name.equals("Peter")) {
        namesList.remove(name);
      } else {
        System.out.println(name);
      }
    }
  }
}
origin: robolectric/robolectric

@Implementation(minSdk = LOLLIPOP)
protected void addAction(AccessibilityAction action) {
 if (action == null) {
  return;
 }
 if (actionsArray == null) {
  actionsArray = new ArrayList<>();
 }
 actionsArray.remove(action);
 actionsArray.add(action);
}
origin: ankidroid/Anki-Android

  @Override
  public String[] transform(String[] fields) {
    ArrayList<String> fl = new ArrayList<>(Arrays.asList(fields));
    fl.remove(idx);
    return fl.toArray(new String[fl.size()]);
  }
}
origin: plantuml/plantuml

  System.out.println("******* Distinct shapes found using AbstractionGrid *******");
  Iterator dit = boundarySetsStep1.iterator();
  while (dit.hasNext()) {
    set.printAsGrid();
  System.out.println("******* Same set of shapes after processing them by filling *******");
ArrayList boundarySetsStep2 = new ArrayList();
Iterator boundarySetIt = boundarySetsStep1.iterator();
while (boundarySetIt.hasNext()) {
          System.out.println("-----------------------------------");
ArrayList open = new ArrayList();
ArrayList closed = new ArrayList();
if(mixed.size() > 0 && closed.size() > 0) {
      boundarySetsStep2.remove(set);
      boundarySetsStep2.addAll(set.breakIntoDistinctBoundaries(workGrid));
  while(sets.hasNext()){
    CellSet set = (CellSet) sets.next();
    boundarySetsStep2.remove(set);
    boundarySetsStep2.addAll(set.breakTrulyMixedBoundaries(workGrid));
origin: apache/hbase

@Override
public synchronized E remove(int index) {
 ArrayList<E> newList = new ArrayList<>(list);
 // Removals in ArrayList won't break sorting
 E result = newList.remove(index);
 list = Collections.unmodifiableList(newList);
 return result;
}
origin: apache/hbase

 @Override
 public void remove() {
  if (!this.nextWasCalled) {
   throw new IllegalStateException("No element to remove");
  }
  this.nextWasCalled = false;
  List<HStoreFile> src = components.get(currentComponent);
  if (src instanceof ImmutableList<?>) {
   src = new ArrayList<>(src);
   components.set(currentComponent, src);
  }
  src.remove(indexWithinComponent);
  --size;
  --indexWithinComponent;
  if (src.isEmpty()) {
   components.remove(currentComponent); // indexWithinComponent is already -1 here.
  }
 }
}
origin: deathmarine/Luyten

public static void add(String path) {
  if (paths.contains(path)) {
    paths.remove(path);
    paths.add(path);
    return;
  }
  
  if (paths.size() >= 10) paths.remove(0);
  paths.add(path);
  
  save();
}
 
origin: TeamNewPipe/NewPipe

private void manageObservers(Handler handler, boolean add) {
  synchronized (mEchoObservers) {
    if (add) {
      mEchoObservers.add(handler);
    } else {
      mEchoObservers.remove(handler);
    }
  }
}
origin: google/ExoPlayer

/**
 * Adds a new weighted value.
 *
 * @param weight The weight of the new observation.
 * @param value The value of the new observation.
 */
public void addSample(int weight, float value) {
 ensureSortedByIndex();
 Sample newSample = recycledSampleCount > 0 ? recycledSamples[--recycledSampleCount]
   : new Sample();
 newSample.index = nextSampleIndex++;
 newSample.weight = weight;
 newSample.value = value;
 samples.add(newSample);
 totalWeight += weight;
 while (totalWeight > maxWeight) {
  int excessWeight = totalWeight - maxWeight;
  Sample oldestSample = samples.get(0);
  if (oldestSample.weight <= excessWeight) {
   totalWeight -= oldestSample.weight;
   samples.remove(0);
   if (recycledSampleCount < MAX_RECYCLED_SAMPLES) {
    recycledSamples[recycledSampleCount++] = oldestSample;
   }
  } else {
   oldestSample.weight -= excessWeight;
   totalWeight -= excessWeight;
  }
 }
}
origin: commons-collections/commons-collections

/**
 * Removes a collection from the those being decorated in this composite.
 *
 * @param coll  collection to be removed
 */
public void removeComposited(Collection coll) {
  ArrayList list = new ArrayList(this.all.length);
  list.addAll(Arrays.asList(this.all));
  list.remove(coll);
  this.all = (Collection[]) list.toArray(new Collection[list.size()]);
}

origin: marytts/marytts

public void run() {
  String maryBase = System.getProperty("mary.base");
  System.out.println("Installing " + name + "-" + version + " in " + maryBase + "...");
  ArrayList<String> files = new ArrayList<String>();
  try {
    ZipFile zipfile = new ZipFile(archiveFile);
    while (entries.hasMoreElements()) {
      ZipEntry entry = entries.nextElement();
      files.add(entry.getName()); // add to installed filelist; rely on uninstaller retaining shared files
      File newFile = new File(maryBase + "/" + entry.getName());
      if (entry.isDirectory()) {
        System.err.println("Extracting directory: " + entry.getName());
        newFile.mkdir();
      } else {
              files.remove(entry.getName());
            System.err.println("NOT overwriting existing newer file: " + entry.getName());
            continue;
origin: stackoverflow.com

 ArrayList<String> list = new ArrayList<String>();     
JSONArray jsonArray = (JSONArray)jsonObject; 
int len = jsonArray.length();
if (jsonArray != null) { 
  for (int i=0;i<len;i++){ 
  list.add(jsonArray.get(i).toString());
  } 
}
//Remove the element from arraylist
list.remove(position);
//Recreate JSON Array
JSONArray jsArray = new JSONArray(list);
origin: EsotericSoftware/kryonet

void removeConnection (Connection connection) {
  ArrayList<Connection> temp = new ArrayList(Arrays.asList(connections));
  temp.remove(connection);
  connections = temp.toArray(new Connection[temp.size()]);
  pendingConnections.remove(connection.id);
}
origin: facebook/stetho

private static <T> boolean removeFromWeakList(ArrayList<WeakReference<T>> haystack, T needle) {
 for (int i = 0, N = haystack.size(); i < N; i++) {
  T hay = haystack.get(i).get();
  if (hay == needle) {
   haystack.remove(i);
   return true;
  }
 }
 return false;
}
origin: apache/hbase

@Override
public synchronized boolean remove(Object o) {
 ArrayList<E> newList = new ArrayList<>(list);
 // Removals in ArrayList won't break sorting
 boolean changed = newList.remove(o);
 list = Collections.unmodifiableList(newList);
 return changed;
}
java.utilArrayListremove

Javadoc

Removes the object at the specified location from this list.

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.
  • 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.
  • indexOf
    Returns the index of the first occurrence of the specified element in this list, or -1 if this list
  • 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 PhpStorm plugins
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