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

How to use
indexOf
method
in
java.util.ArrayList

Best Java code snippets using java.util.ArrayList.indexOf (Showing top 20 results out of 7,353)

Refine searchRefine arrow

  • ArrayList.add
  • ArrayList.get
  • ArrayList.size
  • ArrayList.remove
  • ArrayList.<init>
origin: zhihu/Matisse

  public int checkedNumOf(Item item) {
    int index = new ArrayList<>(mItems).indexOf(item);
    return index == -1 ? CheckView.UNCHECKED : index + 1;
  }
}
origin: stackoverflow.com

 ViewPager pager = /* get my ViewPager */;
// assume this actually has stuff in it
final ArrayList<String> titles = new ArrayList<String>();

FragmentManager fm = getSupportFragmentManager();
pager.setAdapter(new FragmentStatePagerAdapter(fm) {
  public int getCount() {
    return titles.size();
  }

  public Fragment getItem(int position) {
    MyFragment fragment = new MyFragment();
    fragment.setTitle(titles.get(position));
    return fragment;
  }

  public int getItemPosition(Object item) {
    MyFragment fragment = (MyFragment)item;
    String title = fragment.getTitle();
    int position = titles.indexOf(title);

    if (position >= 0) {
      return position;
    } else {
      return POSITION_NONE;
    }
  }
});
origin: pentaho/pentaho-kettle

@Override
public FileStream getStream( String filename ) {
 int index = namesList.indexOf( filename );
 return index == -1 ? null : streamsList.get( index );
}
origin: javax.portlet/portlet-api

  private void addToMap(Map<String, Method> map, String name, Method newMethod) {
   Method mapMethod = map.get(name);

   // Adds new method to map if method does not exist in map
   // or if class of new method is subclass of class of method in map.
    if ((mapMethod != null) && (newMethod != null)) {
     
     // get the class hierarchy. 
     ArrayList<Class<?>> classHierarchy = new ArrayList<Class<?>>();
     for (Class<?> cls=this.getClass(); cls != null; cls=cls.getSuperclass()) {
       classHierarchy.add(cls);
     }
     
     int classLevelMap = classHierarchy.indexOf(mapMethod.getDeclaringClass());
     int classLevelNew = classHierarchy.indexOf(newMethod.getDeclaringClass());
     if (classLevelMap <= classLevelNew) {
       return;
     }
    }
    map.put(name, newMethod);
  }
}
origin: TeamNewPipe/NewPipe

/**
 * Shuffles the current play queue.
 *
 * This method first backs up the existing play queue and item being played.
 * Then a newly shuffled play queue will be generated along with currently
 * playing item placed at the beginning of the queue.
 *
 * Will emit a {@link ReorderEvent} in any context.
 * */
public synchronized void shuffle() {
  if (backup == null) {
    backup = new ArrayList<>(streams);
  }
  final int originIndex = getIndex();
  final PlayQueueItem current = getItem();
  Collections.shuffle(streams);
  final int newIndex = streams.indexOf(current);
  if (newIndex != -1) {
    streams.add(0, streams.remove(newIndex));
  }
  queueIndex.set(0);
  broadcast(new ReorderEvent(originIndex, queueIndex.get()));
}
origin: apache/hive

/**
 * @return the partDescs for paths
 */
public List<PartitionDesc> getPartDescs(List<Path> paths) {
 List<PartitionDesc> parts = new ArrayList<PartitionDesc>(paths.size());
 for (Path path : paths) {
  parts.add(partDesc.get(partDir.indexOf(path.getParent())));
 }
 return parts;
}
origin: com.h2database/h2

/**
 * Add a SQL statement to the history.
 *
 * @param sql the SQL statement
 */
void addCommand(String sql) {
  if (sql == null) {
    return;
  }
  sql = sql.trim();
  if (sql.length() == 0) {
    return;
  }
  if (commandHistory.size() > MAX_HISTORY) {
    commandHistory.remove(0);
  }
  int idx = commandHistory.indexOf(sql);
  if (idx >= 0) {
    commandHistory.remove(idx);
  }
  commandHistory.add(sql);
  if (server.isCommandHistoryAllowed()) {
    server.saveCommandHistoryList(commandHistory);
  }
}
origin: crazycodeboy/TakePhoto

  /**
   * 为被裁切的图片设置已被裁切的标识
   *
   * @param uri 被裁切的图片
   * @return 该图片是否是最后一张
   */
  public Map setCropWithUri(Uri uri, boolean cropped) {
    if (!cropped) {
      hasFailed = true;
    }
    int index = outUris.indexOf(uri);
    tImages.get(index).setCropped(cropped);
    Map result = new HashMap();
    result.put("index", index);
    result.put("isLast", index == outUris.size() - 1 ? true : false);
    return result;
  }
}
origin: gzu-liyujiang/AndroidPicker

private void initHourData() {
  hours.clear();
  int currentHour = 0;
  if (!resetWhileWheel) {
    if (timeMode == HOUR_24) {
      currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    } else {
      currentHour = Calendar.getInstance().get(Calendar.HOUR);
    }
  }
  for (int i = startHour; i <= endHour; i++) {
    String hour = DateUtils.fillZero(i);
    if (!resetWhileWheel) {
      if (i == currentHour) {
        selectedHour = hour;
      }
    }
    hours.add(hour);
  }
  if (hours.indexOf(selectedHour) == -1) {
    //当前设置的小时不在指定范围,则默认选中范围开始的小时
    selectedHour = hours.get(0);
  }
  if (!resetWhileWheel) {
    selectedMinute = DateUtils.fillZero(Calendar.getInstance().get(Calendar.MINUTE));
  }
}
origin: chat-sdk/chat-sdk-android

public void removePicture(User user, String url) {
  ArrayList<String> urls = fromUser(user);
  boolean isDefault = urls.indexOf(url) == 0;
  urls.remove(url);
  urls.add("");
  if (isDefault) {
    setDefaultPicture(user, urls.get(0), urls);
  }
  setPictures(user, urls);
}
origin: seven332/EhViewer

int index = mSceneTagList.indexOf(tag);
if (index < 0) {
  Log.e(TAG, "finishScene: Can't find the tag in tag list: " + tag);
if (mSceneTagList.size() == 1) {
if (index == mSceneTagList.size() - 1) {
  next = fragmentManager.findFragmentByTag(mSceneTagList.get(index - 1));
mSceneTagList.remove(index);
origin: Rajawali/Rajawali

/**
 * Adds a texture to this material. Throws and error if the maximum number of textures was reached.
 *
 * @param texture
 *
 * @throws TextureException
 */
public void addTexture(ATexture texture) throws TextureException {
  if (mTextureList.indexOf(texture) > -1) return;
  if (mTextureList.size() + 1 > mMaxTextures) {
    throw new TextureException("Maximum number of textures for this material has been reached. Maximum number of textures is " + mMaxTextures + ".");
  }
  mTextureList.add(texture);
  TextureManager.getInstance().addTexture(texture);
  texture.registerMaterial(this);
  mIsDirty = true;
}
origin: lingochamp/okdownload

public Builder bindSetTask(@NonNull DownloadTask task) {
  final int index = boundTaskList.indexOf(task);
  if (index >= 0) {
    // replace
    boundTaskList.set(index, task);
  } else {
    boundTaskList.add(task);
  }
  return this;
}
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: cmusphinx/sphinx4

assert graph != null : "Graph not defined";
assert ((!isFinalNode(node)) && (!isInitialNode(node)));
int nodePosition = nodes.indexOf(node);
nodes.remove(nodePosition);
int index;
for (graph.startNodeIterator(), index = nodePosition;
   graph.hasMoreNodes(); index++) {
  nodes.add(index, graph.nextNode());
origin: apache/geode

/**
 * Hint size is used for filter ordering. Smaller values have preference
 */
public int getHintSize(String indexName) {
 return -(hints.size() - hints.indexOf(indexName));
}
origin: smuyyh/BookReader

public void removeFooter(ItemView view) {
  int position = headers.size() + getCount() + footers.indexOf(view);
  footers.remove(view);
  notifyItemRemoved(position);
}
origin: lealone/Lealone

private static void remove(ArrayList<? extends DbObject> list, DbObject obj) {
  if (list != null) {
    int i = list.indexOf(obj);
    if (i >= 0) {
      list.remove(i);
    }
  }
}
origin: cmusphinx/sphinx4

/**
 * Copies a path
 */
private static void duplicatePath(int lastPathIndex, State fromState,
    State toState, ArrayList<ArrayList<State>> paths) {
  ArrayList<State> lastPath = paths.get(lastPathIndex);
  // copy the last path to a new one, from start to current state
  int fromIndex = lastPath.indexOf(fromState);
  int toIndex = lastPath.indexOf(toState);
  if (toIndex == -1) {
    toIndex = lastPath.size() - 1;
  }
  ArrayList<State> newPath = new ArrayList<State>(lastPath.subList(
      fromIndex, toIndex));
  paths.add(newPath);
}
origin: sannies/mp4parser

assert stsc != null;
if (stsc.getEntries().isEmpty()) {
  List<SampleToChunkBox.Entry> entries = new ArrayList<SampleToChunkBox.Entry>();
  stsc.setEntries(entries);
  entries.add(new SampleToChunkBox.Entry(chunkNumber, samples.size(), 1));
  if (ctts == null) {
    ctts = new CompositionTimeToSample();
    ctts.setEntries(new ArrayList<CompositionTimeToSample.Entry>());
    ArrayList<Box> bs = new ArrayList<Box>(stbl.getBoxes());
    bs.add(bs.indexOf(stts), ctts);
  if (stts.getEntries().isEmpty()) {
    ArrayList<TimeToSampleBox.Entry> entries = new ArrayList<TimeToSampleBox.Entry>(stts.getEntries());
    entries.add(new TimeToSampleBox.Entry(1, sample.getDuration()));
    stts.setEntries(entries);
  } else {
java.utilArrayListindexOf

Javadoc

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

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,
  • 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 12 Jupyter Notebook extensions
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