當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。