java.util.LinkedList.indexOf()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中java.util.LinkedList.indexOf()方法的一些代码示例,展示了LinkedList.indexOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.indexOf()方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:indexOf

LinkedList.indexOf介绍

[英]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.
[中]返回此列表中指定元素第一次出现的索引,如果此列表不包含该元素,则返回-1。更正式地说,返回最低的索引i(o==null?get(i)==null:o.equals(get(i)),或者如果没有这样的索引,返回-1。

代码示例

代码示例来源:origin: hankcs/HanLP

@Override
public int indexOf(Object o)
{
  return pipeList.indexOf(o);
}

代码示例来源:origin: iSoron/uhabits

@Override
public synchronized int indexOf(@NonNull Habit h)
{
  return list.indexOf(h);
}

代码示例来源:origin: spotbugs/spotbugs

public void test2Bugs(LinkedList<CharSequence> list) {
  list.indexOf(Integer.valueOf(3));
}

代码示例来源:origin: spotbugs/spotbugs

public void test2NoBugs(LinkedList<CharSequence> list) {
  list.indexOf(new StringBuffer("Key"));
}

代码示例来源:origin: log4j/log4j

/**
 * Adds an object to the mru.
 */
protected void setMRU(Object o) {
 int index = _mruFileList.indexOf(o);
 if (index == -1) {
  _mruFileList.add(0, o);
  setMaxSize(_maxSize);
 } else {
  moveToTop(index);
 }
}

代码示例来源:origin: apache/incubator-gobblin

private String computePath(T node) {
  StringBuilder sb = new StringBuilder();
  for (T t : this.nodesList.subList(this.nodesList.indexOf(node), this.nodesList.size())) {
   sb.append(t).append(" -> ");
  }
  sb.append(node);
  return sb.toString();
 }
}

代码示例来源:origin: ReactiveX/RxNetty

private DetachedChannelPipeline _guardedAddAfter(String baseName, HandlerHolder toAdd) {
  synchronized (holdersInOrder) {
    HandlerHolder after = unguardedFindHandlerByName(baseName, false);
    final int indexOfAfter = holdersInOrder.indexOf(after);
    holdersInOrder.add(indexOfAfter + 1, toAdd);
  }
  return this;
}

代码示例来源:origin: ReactiveX/RxNetty

private DetachedChannelPipeline _guardedAddBefore(String baseName, HandlerHolder toAdd) {
  synchronized (holdersInOrder) {
    HandlerHolder before = unguardedFindHandlerByName(baseName, false);
    final int indexOfBefore = holdersInOrder.indexOf(before);
    holdersInOrder.add(indexOfBefore, toAdd);
  }
  return this;
}

代码示例来源:origin: Justson/AgentWeb

void removeTask(String path) {
  writeLock().lock();
  try {
    int position = -1;
    if ((position = mTasks.indexOf(path)) == -1) {
      return;
    }
    mTasks.remove(position);
    mTasks.remove(position - 1);
  } finally {
    writeLock().unlock();
  }
}

代码示例来源:origin: apache/geode

int indexOf = eventHistory.indexOf(memberId);
if (indexOf > -1) {

代码示例来源:origin: FudanNLP/fnlp

void getRightOOV(String string) {
  if(dict==null||dict.size()==0)
    return;
  TreeMap<String,String> set = new TreeMap<String,String>();
  for(int i=0;i<entityCs.size();i++){
    LinkedList<Entity>  cList =  entityCs.get(i);
    LinkedList<Entity>  pList =  entityPs.get(i);
    LinkedList<Entity>  cpList =  entityCinPs.get(i);
    for(Entity entity:cpList){
      String e = entity.getEntityStr();
      //				if(dict.contains(e))
      //					break;
      int idx = cList.indexOf(entity);
      String s= " ... ";
      if(idx!=-1){
        if(idx>0)
          s = cList.get(idx-1).getEntityStr() + s;
        if(idx<cList.size()-1)
          s = s+ cList.get(idx+1).getEntityStr();
      }
      adjust(set, s, 1);
    }    
  }
  List<Entry> sortedposFreq = MyCollection.sort(set);        
  MyCollection.write(sortedposFreq, string, true);
}

代码示例来源:origin: fesh0r/fernflower

int succ_entry_index = ndentrypoints.indexOf(nd.id);
if (succ_entry_index >=
  0) { // we are in a loop (e.g. continue in a finally block), drop all entry points in the list beginning with succ_entry_index

代码示例来源:origin: org.apache.spark/spark-core_2.10

private void advanceToNextPage() {
 synchronized (this) {
  int nextIdx = dataPages.indexOf(currentPage) + 1;
  if (destructive && currentPage != null) {
   dataPages.remove(currentPage);

代码示例来源:origin: org.apache.spark/spark-core_2.11

private void advanceToNextPage() {
 synchronized (this) {
  int nextIdx = dataPages.indexOf(currentPage) + 1;
  if (destructive && currentPage != null) {
   dataPages.remove(currentPage);
   freePage(currentPage);
   nextIdx --;
  }
  if (dataPages.size() > nextIdx) {
   currentPage = dataPages.get(nextIdx);
   pageBaseObject = currentPage.getBaseObject();
   offsetInPage = currentPage.getBaseOffset();
   recordsInPage = UnsafeAlignedOffset.getSize(pageBaseObject, offsetInPage);
   offsetInPage += UnsafeAlignedOffset.getUaoSize();
  } else {
   currentPage = null;
   if (reader != null) {
    handleFailedDelete();
   }
   try {
    Closeables.close(reader, /* swallowIOException = */ false);
    reader = spillWriters.getFirst().getReader(serializerManager);
    recordsInPage = -1;
   } catch (IOException e) {
    // Scala iterator does not handle exception
    Platform.throwException(e);
   }
  }
 }
}

代码示例来源:origin: org.apache.spark/spark-core

private void advanceToNextPage() {
 synchronized (this) {
  int nextIdx = dataPages.indexOf(currentPage) + 1;
  if (destructive && currentPage != null) {
   dataPages.remove(currentPage);
   freePage(currentPage);
   nextIdx --;
  }
  if (dataPages.size() > nextIdx) {
   currentPage = dataPages.get(nextIdx);
   pageBaseObject = currentPage.getBaseObject();
   offsetInPage = currentPage.getBaseOffset();
   recordsInPage = UnsafeAlignedOffset.getSize(pageBaseObject, offsetInPage);
   offsetInPage += UnsafeAlignedOffset.getUaoSize();
  } else {
   currentPage = null;
   if (reader != null) {
    handleFailedDelete();
   }
   try {
    Closeables.close(reader, /* swallowIOException = */ false);
    reader = spillWriters.getFirst().getReader(serializerManager);
    recordsInPage = -1;
   } catch (IOException e) {
    // Scala iterator does not handle exception
    Platform.throwException(e);
   }
  }
 }
}

代码示例来源:origin: seven332/EhViewer

public void deleteDownload(long gid) {
  stopDownloadInternal(gid);
  DownloadInfo info = mAllInfoMap.get(gid);
  if (info != null) {
    // Remove from DB
    EhDB.removeDownloadInfo(info.gid);
    // Remove all list and map
    mAllInfoList.remove(info);
    mAllInfoMap.remove(info.gid);
    // Remove label list
    LinkedList<DownloadInfo> list = getInfoListForLabel(info.label);
    if (list != null) {
      int index = list.indexOf(info);
      if (index >= 0) {
        list.remove(info);
        // Update listener
        for (DownloadInfoListener l: mDownloadInfoListeners) {
          l.onRemove(info, list, index);
        }
      }
    }
    // Ensure download
    ensureDownload();
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Return the precedence of the given property source, {@code -1} if not found.
 */
public int precedenceOf(PropertySource<?> propertySource) {
  return this.propertySourceList.indexOf(propertySource);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Assert that the named property source is present and return its index.
 * @param name the {@linkplain PropertySource#getName() name of the property source}
 * to find
 * @throws IllegalArgumentException if the named property source is not present
 */
private int assertPresentAndGetIndex(String name) {
  int index = this.propertySourceList.indexOf(PropertySource.named(name));
  Assert.isTrue(index >= 0, String.format(NON_EXISTENT_PROPERTY_SOURCE_MESSAGE, name));
  return index;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Remove and return the property source with the given name, {@code null} if not found.
 * @param name the name of the property source to find and remove
 */
public PropertySource<?> remove(String name) {
  logger.debug(String.format("Removing [%s] PropertySource", name));
  int index = this.propertySourceList.indexOf(PropertySource.named(name));
  return index == -1 ? null : this.propertySourceList.remove(index);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Adds an object to the mru.
 */
protected void setMRU(Object o) {
 int index = _mruFileList.indexOf(o);
 if (index == -1) {
  _mruFileList.add(0, o);
  setMaxSize(_maxSize);
 } else {
  moveToTop(index);
 }
}

相关文章

微信公众号

最新文章

更多