当前位置: 首页>>代码示例>>Java>>正文


Java ListIterator.previousIndex方法代码示例

本文整理汇总了Java中java.util.ListIterator.previousIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ListIterator.previousIndex方法的具体用法?Java ListIterator.previousIndex怎么用?Java ListIterator.previousIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ListIterator的用法示例。


在下文中一共展示了ListIterator.previousIndex方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPreviousIndex

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * Test of previousIndex method, of class TreeListIterator.
 */
@Test
public void testPreviousIndex() {
    ListIterator<TreeNode> treeListIterator1 = new TreeListIterator(tree1);
    int expResult = -1;
    int result = treeListIterator1.previousIndex();
    assertEquals("previousIndex method, of class TreeListIterator's expected result is worng.",
            expResult, result);

    for(int i = 0; i < 14; i++) {
        treeListIterator1.next();
    }
    expResult = 13;
    result = treeListIterator1.previousIndex();
    assertEquals("previousIndex method, of class TreeListIterator's expected result is worng.",
            expResult, result);
}
 
开发者ID:miyagilabs,项目名称:Blindfold,代码行数:20,代码来源:TreeListIteratorTest.java

示例2: findMinIndex

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * Finds minimum index in a list
 * @param xs
 * @return
 */
public static <T extends Comparable<T>> int findMinIndex(final List<T> xs) {
    int minIndex;
    if (xs.isEmpty()) {
        minIndex = -1;
    } else {
        final ListIterator<T> itr = xs.listIterator();
        T min = itr.next(); // first element as the current minimum
        minIndex = itr.previousIndex();
        while (itr.hasNext()) {
            final T curr = itr.next();
            if (curr.compareTo(min) < 0) {
                min = curr;
                minIndex = itr.previousIndex();
            }
        }
    }
    return minIndex;
}
 
开发者ID:enocholumide,项目名称:Laserscan-to-dxf,代码行数:24,代码来源:Toolset.java

示例3: indexOfKey

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public int indexOfKey(K key)
{
  ListIterator<Map.Entry<K,V>> i = entryListIterator();
  if (key == null)
  {
    while (i.hasNext())
    {
      if (i.next() == null) return i.previousIndex();
    }
  }
  else
  {
    while (i.hasNext())
    {
      if (key.equals(i.next())) return i.previousIndex();
    }
  }
  return -1;
}
 
开发者ID:cinnober,项目名称:ciguan,代码行数:23,代码来源:AbstractIndexedMap.java

示例4: install

import java.util.ListIterator; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, IOException {
    int extraSize = additionalClassPathEntries.size();
    Field pathField = MultiDex.findField(loader, "path");
    StringBuilder path = new StringBuilder((String) pathField.get(loader));
    String[] extraPaths = new String[extraSize];
    File[] extraFiles = new File[extraSize];
    ZipFile[] extraZips = new ZipFile[extraSize];
    DexFile[] extraDexs = new DexFile[extraSize];
    ListIterator<File> iterator = additionalClassPathEntries.listIterator();
    while (iterator.hasNext()) {
        File additionalEntry = (File) iterator.next();
        String entryPath = additionalEntry.getAbsolutePath();
        path.append(':').append(entryPath);
        int index = iterator.previousIndex();
        extraPaths[index] = entryPath;
        extraFiles[index] = additionalEntry;
        extraZips[index] = new ZipFile(additionalEntry);
        extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ".dex", 0);
    }
    pathField.set(loader, path.toString());
    MultiDex.expandFieldArray(loader, "mPaths", extraPaths);
    MultiDex.expandFieldArray(loader, "mFiles", extraFiles);
    MultiDex.expandFieldArray(loader, "mZips", extraZips);
    MultiDex.expandFieldArray(loader, "mDexs", extraDexs);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:MultiDex.java

示例5: install

import java.util.ListIterator; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, IOException {
    int extraSize = additionalClassPathEntries.size();
    Field pathField = MultiDex.findField(loader, "path");
    StringBuilder path = new StringBuilder((String) pathField.get(loader));
    String[] extraPaths = new String[extraSize];
    File[] extraFiles = new File[extraSize];
    ZipFile[] extraZips = new ZipFile[extraSize];
    DexFile[] extraDexs = new DexFile[extraSize];
    ListIterator<File> iterator = additionalClassPathEntries.listIterator();
    while (iterator.hasNext()) {
        File additionalEntry = (File) iterator.next();
        String entryPath = additionalEntry.getAbsolutePath();
        path.append(':').append(entryPath);
        int index = iterator.previousIndex();
        extraPaths[index] = entryPath;
        extraFiles[index] = additionalEntry;
        extraZips[index] = new ZipFile(additionalEntry);
        extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ShareConstants.DEX_SUFFIX, 0);
    }
    pathField.set(loader, path.toString());
    MultiDex.expandFieldArray(loader, "mPaths", extraPaths);
    MultiDex.expandFieldArray(loader, "mFiles", extraFiles);
    MultiDex.expandFieldArray(loader, "mZips", extraZips);
    MultiDex.expandFieldArray(loader, "mDexs", extraDexs);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:MultiDex.java

示例6: 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();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:SplitIndexWriter.java

示例7: indexOfImpl

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * An implementation of {@link List#indexOf(Object)}.
 */
static int indexOfImpl(List<?> list, @Nullable Object element) {
  ListIterator<?> listIterator = list.listIterator();
  while (listIterator.hasNext()) {
    if (Objects.equal(element, listIterator.next())) {
      return listIterator.previousIndex();
    }
  }
  return -1;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:13,代码来源:Lists.java

示例8: initializeLastIndex

import java.util.ListIterator; //导入方法依赖的package包/类
private void initializeLastIndex() {
	ListIterator<Option<T>> i = lazyList.listIterator();
	if (!initialized) {
		while (i.hasNext()) {
			if (!i.next().isEmpty()) {
				lastIndex = i.previousIndex();
			}
		}
	}
	initialized = true;
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-query,代码行数:12,代码来源:LastIterator.java

示例9: indexOfImpl

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * An implementation of {@link List#indexOf(Object)}.
 */
static int indexOfImpl(List<?> list, @Nullable Object element) {
  if (list instanceof RandomAccess) {
    return indexOfRandomAccess(list, element);
  } else {
    ListIterator<?> listIterator = list.listIterator();
    while (listIterator.hasNext()) {
      if (Objects.equal(element, listIterator.next())) {
        return listIterator.previousIndex();
      }
    }
    return -1;
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:Lists.java

示例10: getRowIndex

import java.util.ListIterator; //导入方法依赖的package包/类
@Override
public int getRowIndex() {
    if (cachedList != null) {
        ListIterator<T> it = cachedList.listIterator();
        while (it.hasNext()) {
            T t = it.next();
            if (getKey(t).equals(this.getRowKey())) {
                return it.previousIndex() + cachedRange.getFirstRow();
            }
        }
    }
    return -1;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:14,代码来源:RichLazyDataModel.java

示例11: previousIndex

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * Returns the index of the previous element.
 *
 * @return  the index of the previous element
 */
public int previousIndex() {
    if (iterator instanceof ListIterator) {
        final ListIterator<?> li = (ListIterator<?>) iterator;
        return li.previousIndex();
    }
    return currentIndex - 1;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:13,代码来源:ListIteratorWrapper.java

示例12: reset

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * Resets this iterator back to the position at which the iterator
 * was created.
 *
 * @since 3.2
 */
public void reset()  {
    if (iterator instanceof ListIterator) {
        final ListIterator<?> li = (ListIterator<?>) iterator;
        while (li.previousIndex() >= 0) {
            li.previous();
        }
        return;
    }
    currentIndex = 0;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:17,代码来源:ListIteratorWrapper.java

示例13: install

import java.util.ListIterator; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries,
                            File optimizedDirectory) throws IllegalArgumentException,
        IllegalAccessException, NoSuchFieldException, IOException {
    int extraSize = additionalClassPathEntries.size();
    Field pathField = ShareReflectUtil.findField((Object) loader, "path");
    StringBuilder path = new StringBuilder((String) pathField.get(loader));
    String[] extraPaths = new String[extraSize];
    File[] extraFiles = new File[extraSize];
    ZipFile[] extraZips = new ZipFile[extraSize];
    DexFile[] extraDexs = new DexFile[extraSize];
    ListIterator<File> iterator = additionalClassPathEntries.listIterator();
    while (iterator.hasNext()) {
        File additionalEntry = (File) iterator.next();
        String entryPath = additionalEntry.getAbsolutePath();
        path.append(':').append(entryPath);
        int index = iterator.previousIndex();
        extraPaths[index] = entryPath;
        extraFiles[index] = additionalEntry;
        extraZips[index] = new ZipFile(additionalEntry);
        extraDexs[index] = DexFile.loadDex(entryPath, SharePatchFileUtil.optimizedPathFor
                (additionalEntry, optimizedDirectory), 0);
    }
    pathField.set(loader, path.toString());
    ShareReflectUtil.expandFieldArray(loader, "mPaths", extraPaths);
    ShareReflectUtil.expandFieldArray(loader, "mFiles", extraFiles);
    ShareReflectUtil.expandFieldArray(loader, "mZips", extraZips);
    try {
        ShareReflectUtil.expandFieldArray(loader, "mDexs", extraDexs);
    } catch (Exception e) {
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:32,代码来源:SystemClassLoaderAdder.java

示例14: executeSql

import java.util.ListIterator; //导入方法依赖的package包/类
/**
 * Executes the passed sql in the passed context.
 *
 * @param ctx       the <code>MigrationContext> to execute the SQL in
 * @param sqlToExec the SQL to execute
 * @throws MigrationException thrown if there is an error when executing the SQL
 */
private void executeSql(MigrationContext ctx, String sqlToExec)
        throws MigrationException
{
    JdbcMigrationContext context = (JdbcMigrationContext) ctx;

    Connection conn = null;
    Statement stmt = null;
    String sqlStatement = "";
    ListIterator listIterator = null;
    try
    {
        conn = context.getConnection();

        // cleaning the slate before we execute the patch.
        // This was inspired by a Sybase ASE server that did not allow
        // ALTER TABLE statements in multi-statement transactions.  Instead of putting
        // a if(sybase) conditional, we decided to clean the slate for everyone.
        context.commit();

        List sqlStatements = getSqlStatements(context, sqlToExec);
        for (listIterator = sqlStatements.listIterator(); listIterator.hasNext();)
        {
            sqlStatement = (String) listIterator.next();
            log.debug(getName() + ": Attempting to execute: " + sqlStatement);

            stmt = conn.createStatement();

            // handle sybase special case with illegal commands in multi
            // command transactions
            if (isSybase(context)
                    && SybaseUtil.containsIllegalMultiStatementTransactionCommand(sqlStatement))
            {
                log.warn("Committing current transaction since patch " + getName()
                        + " contains commands that are not allowed in multi statement"
                        + " transactions.  If the patch contains errors, this patch may"
                        + " not be rolled back cleanly.");
                context.commit();
                stmt.execute(sqlStatement);
                context.commit();
            }
            else // regular case
            {
                stmt.execute(sqlStatement);
            }

            SqlUtil.close(null, stmt, null);
        }

        context.commit();
    }
    catch (Exception e)
    {
        String message = getName() + ": Error running SQL at statement number "
                + listIterator.previousIndex() + " \"" + sqlStatement + "\"";
        log.error(message, e);

        if (e instanceof SQLException)
        {
            if (((SQLException) e).getNextException() != null)
            {
                log.error("Chained SQL Exception", ((SQLException) e).getNextException());
            }
        }

        context.rollback();
        throw new MigrationException(message, e);
    }
    finally
    {
        SqlUtil.close(null, stmt, null);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:80,代码来源:SqlScriptMigrationTask.java


注:本文中的java.util.ListIterator.previousIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。