本文整理汇总了Java中java.util.ListIterator.nextIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ListIterator.nextIndex方法的具体用法?Java ListIterator.nextIndex怎么用?Java ListIterator.nextIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ListIterator
的用法示例。
在下文中一共展示了ListIterator.nextIndex方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: contains
import java.util.ListIterator; //导入方法依赖的package包/类
@Override
public boolean contains(@Nullable Object o) {
if (!(o instanceof List)) {
return false;
}
List<?> list = (List<?>) o;
if (list.size() != axes.size()) {
return false;
}
ListIterator<?> itr = list.listIterator();
while (itr.hasNext()) {
int index = itr.nextIndex();
if (!axes.get(index).contains(itr.next())) {
return false;
}
}
return true;
}
示例2: removeMultiplePeaks
import java.util.ListIterator; //导入方法依赖的package包/类
public PeakList removeMultiplePeaks() {
// TODO (LS) :
ListIterator<Peak> peakListIterator = this.pList.listIterator();
while (peakListIterator.hasNext()) {
int index = peakListIterator.nextIndex();
Peak currentPeak = peakListIterator.next();
for (int j = 0; j < index; ++j) {
if (currentPeak.equalsPeak(this.pList.get(j))) {
peakListIterator.remove();
break; // TODO why break ?
}
}
}
return this;
}
示例3: lastIndexOfKey
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public int lastIndexOfKey(K key)
{
ListIterator<Map.Entry<K,V>> i = entryListIterator(size());
if (key == null)
{
while (i.hasPrevious())
{
if (i.previous() == null) return i.nextIndex();
}
}
else
{
while (i.hasPrevious())
{
if (key.equals(i.previous())) return i.nextIndex();
}
}
return -1;
}
示例4: threadSafeRemove
import java.util.ListIterator; //导入方法依赖的package包/类
public synchronized void threadSafeRemove(@NonNull final IThreadSafeConditions<T> conditions) {
if (conditions == null) {
throw new IllegalArgumentException("conditions cannot be null");
}
/*
* Remove everything except PivotsRV
*
* Use iterator to avoid ConcurrentModificationException
*/
ListIterator<T> iterator = getList().listIterator();
final Stack<Integer> positions = new Stack<>();
int position;
T item;
while (iterator.hasNext()) {
position = iterator.nextIndex();
item = iterator.next();
if (conditions.removeIf(item)) {
iterator.remove();
positions.push(position);
}
}
conditions.onItemsRemoved(positions);
}
示例5: generate
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Generate separate index files, for each Unicode character, listing all
* the members starting with the particular unicode character.
*
* @param configuration the configuration for this doclet
* @param indexbuilder IndexBuilder built by {@link IndexBuilder}
* @throws DocFileIOException if there is a problem generating the index files
*/
public static void generate(HtmlConfiguration configuration,
IndexBuilder indexbuilder) throws DocFileIOException {
DocPath path = DocPaths.INDEX_FILES;
Set<Character> keys = new TreeSet<>(indexbuilder.getIndexMap().keySet());
keys.addAll(configuration.tagSearchIndexKeys);
ListIterator<Character> li = new ArrayList<>(keys).listIterator();
int prev;
int next;
while (li.hasNext()) {
prev = (li.hasPrevious()) ? li.previousIndex() + 1 : -1;
Object ch = li.next();
next = (li.hasNext()) ? li.nextIndex() + 1 : -1;
DocPath filename = DocPaths.indexN(li.nextIndex());
SplitIndexWriter indexgen = new SplitIndexWriter(configuration,
path.resolve(filename),
indexbuilder, keys, prev, next);
indexgen.generateIndexFile((Character) ch);
if (!li.hasNext()) {
indexgen.createSearchIndexFiles();
}
}
}
示例6: lastIndexOfImpl
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* An implementation of {@link List#lastIndexOf(Object)}.
*/
static int lastIndexOfImpl(List<?> list, @Nullable Object element) {
ListIterator<?> listIterator = list.listIterator(list.size());
while (listIterator.hasPrevious()) {
if (Objects.equal(element, listIterator.previous())) {
return listIterator.nextIndex();
}
}
return -1;
}
示例7: toString
import java.util.ListIterator; //导入方法依赖的package包/类
private <T> void toString(List<T> resources, StringBuilder sb) {
ListIterator<T> i = resources.listIterator();
while (i.hasNext()) {
if (i.nextIndex() != 0) {
sb.append(", ");
}
sb.append(i.next());
}
}
示例8: lastIndexOfImpl
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* An implementation of {@link List#lastIndexOf(Object)}.
*/
static int lastIndexOfImpl(List<?> list, @Nullable Object element) {
if (list instanceof RandomAccess) {
return lastIndexOfRandomAccess(list, element);
} else {
ListIterator<?> listIterator = list.listIterator(list.size());
while (listIterator.hasPrevious()) {
if (Objects.equal(element, listIterator.previous())) {
return listIterator.nextIndex();
}
}
return -1;
}
}
示例9: _scanQueue
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Run through the queue to see if we got a possible match of:
* [0] stx, [1 - (n-1)] Integers within time frame, [n]
* @return the count of key events we can dump out to the user
*/
private int _scanQueue()
{
StringBuilder barcode = new StringBuilder();
ListIterator<KeyEvent> iter = queue.listIterator();
KeyEvent first = iter.next();
if ((first.getID() != KeyEvent.KEY_TYPED) || (first.getKeyChar() != config.stx))
return 1;
while (iter.hasNext())
{
KeyEvent ke = iter.next();
if (ke.getID() != KeyEvent.KEY_TYPED) // only look at TYPED events
continue;
Character c = ke.getKeyChar();
if (c == config.stx) // a second stx char, clear buffer before this
return iter.nextIndex()-1;
if (c == config.etx) {
queue.clear();
log.log(Level.FINE, "Scanned barcode {0}", barcode);
Messenger.sendEvent(MT.BARCODE_SCANNED, barcode.toString());
return iter.nextIndex(); // time to dump
}
barcode.append(c);
if (barcode.length() > 20) {
log.log(Level.FINE, "Barcode too long, ignoring");
return iter.nextIndex(); // time to dump
}
}
return 0;
}
示例10: toString
import java.util.ListIterator; //导入方法依赖的package包/类
private void toString(List resources, StringBuffer sb) {
ListIterator i = resources.listIterator();
while (i.hasNext()) {
if (i.nextIndex() != 0) {
sb.append(", ");
}
sb.append(i.next());
}
}
示例11: nextIndex
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Returns the index of the next element.
*
* @return the index of the next element
*/
public int nextIndex() {
if (iterator instanceof ListIterator) {
final ListIterator<?> li = (ListIterator<?>) iterator;
return li.nextIndex();
}
return currentIndex;
}
示例12: decodeMap
import java.util.ListIterator; //导入方法依赖的package包/类
private Map<Executable, State> decodeMap(List<String> lines) {
if (lines == null || lines.size() == 0) {
throw new Error("TESTBUG: unexpected lines list");
}
Map<Executable, State> stateMap = new HashMap<>();
int startIndex = 0;
ListIterator<String> iterator = lines.listIterator();
while (iterator.hasNext()) {
int index = iterator.nextIndex();
String next = iterator.next();
switch (next) {
case "{" :
startIndex = index;
break;
case "}" :
// method name goes after {
Executable executable = METHODS_NAMES.get(lines.get(
++startIndex));
// state description starts after method
State state = State.fromString(lines.subList(++startIndex,
index).toArray(new String[index - startIndex]));
stateMap.put(executable, state);
break;
}
}
return stateMap;
}