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

How to use
clear
method
in
java.util.ArrayList

Best Java code snippets using java.util.ArrayList.clear (Showing top 20 results out of 27,765)

Refine searchRefine arrow

  • ArrayList.add
  • ArrayList.size
  • ArrayList.get
  • ArrayList.<init>
  • ArrayList.addAll
  • PrintStream.println
origin: netty/netty

@SuppressWarnings("unchecked")
public <E> ArrayList<E> arrayList(int minCapacity) {
  ArrayList<E> list = (ArrayList<E>) arrayList;
  if (list == null) {
    arrayList = new ArrayList<Object>(minCapacity);
    return (ArrayList<E>) arrayList;
  }
  list.clear();
  list.ensureCapacity(minCapacity);
  return list;
}
origin: google/ExoPlayer

private void updateSampleStreams(SampleStream[] streams) {
 hlsSampleStreams.clear();
 for (SampleStream stream : streams) {
  if (stream != null) {
   hlsSampleStreams.add((HlsSampleStream) stream);
  }
 }
}
origin: google/ExoPlayer

/**
 * Returns the {@link DataSpec} instances passed to {@link #open(DataSpec)} since the last call to
 * this method.
 */
public final DataSpec[] getAndClearOpenedDataSpecs() {
 DataSpec[] dataSpecs = new DataSpec[openedDataSpecs.size()];
 openedDataSpecs.toArray(dataSpecs);
 openedDataSpecs.clear();
 return dataSpecs;
}
origin: stanfordnlp/CoreNLP

private int[][][][] createPartialDataForLOP(int lopIter, int[][][][] data) {
 ArrayList<Integer> newFeatureList = new ArrayList<>(1000);
 Set<Integer> featureIndicesSet = featureIndicesSetArray.get(lopIter);
 int[][][][] newData = new int[data.length][][][];
 for (int i = 0; i < data.length; i++) {
  newData[i] = new int[data[i].length][][];
  for (int j = 0; j < data[i].length; j++) {
   newData[i][j] = new int[data[i][j].length][];
   for (int k = 0; k < data[i][j].length; k++) {
    int[] oldFeatures = data[i][j][k];
    newFeatureList.clear();
    for (int oldFeatureIndex : oldFeatures) {
     if (featureIndicesSet.contains(oldFeatureIndex)) {
      newFeatureList.add(oldFeatureIndex);
     }
    }
    newData[i][j][k] = new int[newFeatureList.size()];
    for (int l = 0; l < newFeatureList.size(); ++l) {
     newData[i][j][k][l] = newFeatureList.get(l);
    }
   }
  }
 }
 return newData;
}
origin: apache/hbase

private void cancelAllChores(final boolean mayInterruptIfRunning) {
 ArrayList<ScheduledChore> choresToCancel = new ArrayList<>(scheduledChores.keySet().size());
 // Build list of chores to cancel so we can iterate through a set that won't change
 // as chores are cancelled. If we tried to cancel each chore while iterating through
 // keySet the results would be undefined because the keySet would be changing
 for (ScheduledChore chore : scheduledChores.keySet()) {
  choresToCancel.add(chore);
 }
 for (ScheduledChore chore : choresToCancel) {
  cancelChore(chore, mayInterruptIfRunning);
 }
 choresToCancel.clear();
}
origin: com.h2database/h2

private void applyOffset() {
  if (offset <= 0) {
    return;
  }
  if (external == null) {
    if (offset >= rows.size()) {
      rows.clear();
      rowCount = 0;
    } else {
      // avoid copying the whole array for each row
      int remove = Math.min(offset, rows.size());
      rows = new ArrayList<>(rows.subList(remove, rows.size()));
      rowCount -= remove;
    }
  } else {
    if (offset >= rowCount) {
      rowCount = 0;
    } else {
      diskOffset = offset;
      rowCount -= offset;
    }
  }
  distinctRows = null;
}
origin: novoda/android-demos

public void setInitalPositionMultiPoints(MotionEvent event) {
  touchPoints.clear();
  int pointerIndex = 0;
  for (int index = 0; index < event.getPointerCount(); ++index) {
    pointerIndex = event.getPointerId(index);
    touchPoints.add(new PointF(event.getX(pointerIndex), event.getY(pointerIndex)));
  }
  double r = Math.atan2(touchPoints.get(1).x - touchPoints.get(1 - 1).x,
      touchPoints.get(1).y - touchPoints.get(1 - 1).y);
  old_degrees = -(int) Math.toDegrees(r);
}
origin: apache/hbase

@Override
public synchronized Optional<CompactionContext> selectCompaction() {
 CompactionContext ctx = new TestCompactionContext(new ArrayList<>(notCompacting));
 compacting.addAll(notCompacting);
 notCompacting.clear();
 try {
  ctx.select(null, false, false, false);
 } catch (IOException ex) {
  fail("Shouldn't happen");
 }
 return Optional.of(ctx);
}
origin: apache/flink

  @Override
  public void reduce(Iterable<Tuple2<Long, Long>> values, Collector<Tuple2<Long, Long[]>> out) {
    neighbors.clear();
    Long id = 0L;
    for (Tuple2<Long, Long> n : values) {
      id = n.f0;
      neighbors.add(n.f1);
    }
    out.collect(new Tuple2<Long, Long[]>(id, neighbors.toArray(new Long[neighbors.size()])));
  }
}
origin: redisson/redisson

  @Override
  public void freeAll() {
    for (int i = 0; i < allocated.size(); i++) {
      MallocBytez mallocBytez = allocated.get(i);
      mallocBytez.free();
    }
    allocated.clear();
  }
}
origin: TeamNewPipe/NewPipe

public void setItems(List<SuggestionItem> items) {
  this.items.clear();
  if (showSuggestionHistory) {
    this.items.addAll(items);
  } else {
    // remove history items if history is disabled
    for (SuggestionItem item : items) {
      if (!item.fromHistory) {
        this.items.add(item);
      }
    }
  }
  notifyDataSetChanged();
}
origin: H07000223/FlycoTabLayout

public void setTabData(ArrayList<CustomTabEntity> tabEntitys) {
  if (tabEntitys == null || tabEntitys.size() == 0) {
    throw new IllegalStateException("TabEntitys can not be NULL or EMPTY !");
  }
  this.mTabEntitys.clear();
  this.mTabEntitys.addAll(tabEntitys);
  notifyDataSetChanged();
}
origin: aurelhubert/ahbottomnavigation

public DemoAdapter(ArrayList<String> dataset) {
  mDataset.clear();
  mDataset.addAll(dataset);
}
origin: hankcs/HanLP

void finish()
{
  flush(0);
  _units.set(0, _nodes.get(0).unit());
  _labels.set(0, _nodes.get(0).label);
  _nodes.clear();
  _table.clear();
  _nodeStack.clear();
  _recycleBin.clear();
  _isIntersections.build();
}
origin: ZieIony/Carbon

public ArrayList<MenuItem> getVisibleItems() {
  if (!mIsVisibleItemsStale) return mVisibleItems;
  // Refresh the visible items
  mVisibleItems.clear();
  final int itemsSize = mItems.size();
  MenuItem item;
  for (int i = 0; i < itemsSize; i++) {
    item = mItems.get(i);
    if (item.isVisible()) mVisibleItems.add(item);
  }
  mIsVisibleItemsStale = false;
  return mVisibleItems;
}
origin: spotbugs/spotbugs

@NoWarning("NP_")
public static void falsePositive_ifnonull(List lst) {
  final ArrayList sections = new ArrayList();
  for (Object o : lst) {
    if (sections != null)
      sections.add(o);
  }
  sections.clear();
}
origin: redisson/redisson

@SuppressWarnings("unchecked")
public <E> ArrayList<E> arrayList(int minCapacity) {
  ArrayList<E> list = (ArrayList<E>) arrayList;
  if (list == null) {
    arrayList = new ArrayList<Object>(minCapacity);
    return (ArrayList<E>) arrayList;
  }
  list.clear();
  list.ensureCapacity(minCapacity);
  return list;
}
origin: libgdx/libgdx

public GradientPanel (GradientColorValue value, String name, String description, boolean hideGradientEditor) {
  super(value, name, description);
  this.value = value;
  initializeComponents();
  if (hideGradientEditor) {
    gradientEditor.setVisible(false);
  }
  gradientEditor.percentages.clear();
  for (float percent : value.getTimeline())
    gradientEditor.percentages.add(percent);
  gradientEditor.colors.clear();
  float[] colors = value.getColors();
  for (int i = 0; i < colors.length;) {
    float r = colors[i++];
    float g = colors[i++];
    float b = colors[i++];
    gradientEditor.colors.add(new Color(r, g, b));
  }
  if (gradientEditor.colors.isEmpty() || gradientEditor.percentages.isEmpty()) {
    gradientEditor.percentages.clear();
    gradientEditor.percentages.add(0f);
    gradientEditor.percentages.add(1f);
    gradientEditor.colors.clear();
    gradientEditor.colors.add(Color.white);
  }
  setColor(gradientEditor.colors.get(0));
}
origin: apache/hbase

/**
 * Reads WALEdit from cells.
 * @param cellDecoder Cell decoder.
 * @param expectedCount Expected cell count.
 * @return Number of KVs read.
 */
public int readFromCells(Codec.Decoder cellDecoder, int expectedCount) throws IOException {
 cells.clear();
 cells.ensureCapacity(expectedCount);
 while (cells.size() < expectedCount && cellDecoder.advance()) {
  cells.add(cellDecoder.current());
 }
 return cells.size();
}
origin: jMonkeyEngine/jmonkeyengine

public void update() {
  synchronized (eventQueue){
    // flush events to listener
    for (int i = 0; i < eventQueue.size(); i++){
      listener.onKeyEvent(eventQueue.get(i));
    }
    eventQueue.clear();
  }
}
java.utilArrayListclear

Javadoc

Removes all elements from this ArrayList, leaving it empty.

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
  • 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
  • From CI to AI: The AI layer in your organization
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