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


Java ArrayList.listIterator方法代码示例

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


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

示例1: replaceReturn

import java.util.ArrayList; //导入方法依赖的package包/类
static List<Term> replaceReturn(List<Term> code, String replacement) {
  ArrayList<Term> result = new ArrayList<>(code);
  ListIterator<Term> it = result.listIterator();
  boolean wasReturn = false;
  while (it.hasNext()) {
    Term t = it.next();
    if (t.isWordOrNumber() && t.is("return")) {
      it.set(new Other(replacement));
      wasReturn = true;
    }
  }
  if (!wasReturn) {
    ListIterator<Term> revIt = Lists.reverse(result).listIterator();
    if (nextNonBlankIs(revIt, "}")) {
      nextNonBlankIs(revIt, ";");
      revIt.previous();
      revIt.add(new Delimiter(";"));
      revIt.add(new Other(replacement));
      revIt.add(new Whitespace("\n"));
    }
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:Code.java

示例2: initializeNoteNameRegex

import java.util.ArrayList; //导入方法依赖的package包/类
private static String initializeNoteNameRegex()
{
	// noteName is built using the keys from the noteNameOffsets hashmap
	// The reverserList is a bit ridiculous, but necessary to reverse the 
	// order of the the keys so that Do and Fa come before D and F.
	// (There is no .previous() method for a regular Iterator.)
	ArrayList< String > reverserList = new ArrayList< String >();
	Iterator< String > iterator = noteNameOffsets.keySet().iterator();
	while( iterator.hasNext() )
	{
		reverserList.add( iterator.next() );	
	}
	// so that Do comes before D and is found first.
	String nNR = "(";
	ListIterator< String > listIterator = reverserList.listIterator( reverserList.size() );
	while( listIterator.hasPrevious() )
	{
		nNR += listIterator.previous() + "|";
	}
	// remove last | or empty string is included
	nNR = nNR.substring( 0, nNR.length() - 1 );
	nNR += ")";
	return nNR;
}
 
开发者ID:JacobRoth,项目名称:romanov,代码行数:25,代码来源:Frequency.java

示例3: optimizeTasksLocked

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * App started in VA may be removed in OverView screen, then AMS.removeTask
 * will be invoked, all data struct about the task in AMS are released,
 * while the client's process is still alive. So remove related data in VA
 * as well. A new TaskRecord will be recreated in `onActivityCreated`
 */
private void optimizeTasksLocked() {
    // noinspection deprecation
    ArrayList<ActivityManager.RecentTaskInfo> recentTask = new ArrayList<>(mAM.getRecentTasks(Integer.MAX_VALUE,
            ActivityManager.RECENT_WITH_EXCLUDED | ActivityManager.RECENT_IGNORE_UNAVAILABLE));
    int N = mHistory.size();
    while (N-- > 0) {
        TaskRecord task = mHistory.valueAt(N);
        ListIterator<ActivityManager.RecentTaskInfo> iterator = recentTask.listIterator();
        boolean taskAlive = false;
        while (iterator.hasNext()) {
            ActivityManager.RecentTaskInfo info = iterator.next();
            if (info.id == task.taskId) {
                taskAlive = true;
                iterator.remove();
                break;
            }
        }
        if (!taskAlive) {
            mHistory.removeAt(N);
        }
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:29,代码来源:ActivityStack.java

示例4: main

import java.util.ArrayList; //导入方法依赖的package包/类
public static void main(java.lang.String[] args) {
	try {
		WebHitDataSet whDataSet = new WebHitDataSet();
		SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
		ArrayList results = whDataSet.getDataBySection(sdf.parse("01-Aug-2002"));
		Iterator iter = results.listIterator();
		while (iter.hasNext()) {
			WebHit wh = (WebHit)iter.next();
			System.out.println(wh.getSection() + " - " + wh.getHitCount());
		}
		System.out.println("Finished.");

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:WebHitDataSet.java

示例5: filterGender

import java.util.ArrayList; //导入方法依赖的package包/类
private ArrayList<SaiyVoice> filterGender(@NonNull final ArrayList<SaiyVoice> voiceArray) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "filterGender");
    }

    final Gender preferredGender = SPH.getDefaultTTSGender(mContext);
    final ArrayList<SaiyVoice> voiceArrayCopy = new ArrayList<>(voiceArray);

    final ListIterator<SaiyVoice> itr = voiceArrayCopy.listIterator();

    SaiyVoice v;
    while (itr.hasNext()) {
        v = itr.next();
        if (v.getGender() != preferredGender) {
            itr.remove();
        }
    }

    if (voiceArrayCopy.isEmpty()) {
        return filterLegacy(voiceArray);
    } else {
        return filterLegacy(voiceArrayCopy);
    }
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:25,代码来源:SaiyTextToSpeech.java

示例6: makeOptionsCompat

import java.util.ArrayList; //导入方法依赖的package包/类
public static ActivityOptionsCompat makeOptionsCompat(Activity fromActivity, Pair<View, String>... sharedElements) {
    ArrayList<Pair<View, String>> list = new ArrayList<>(Arrays.asList(sharedElements));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        list.add(Pair.create(fromActivity.findViewById(android.R.id.statusBarBackground), Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME));
        list.add(Pair.create(fromActivity.findViewById(android.R.id.navigationBarBackground), Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME));
    }

    //remove any views that are null
    for (ListIterator<Pair<View, String>> iter = list.listIterator(); iter.hasNext();) {
        Pair pair = iter.next();
        if (pair.first == null) iter.remove();
    }

    sharedElements = list.toArray(new Pair[list.size()]);
    return ActivityOptionsCompat.makeSceneTransitionAnimation(
            fromActivity,
            sharedElements
    );
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:21,代码来源:TransitionHelper.java

示例7: trimLeadingIndent

import java.util.ArrayList; //导入方法依赖的package包/类
static List<Term> trimLeadingIndent(List<Term> code) {
  ArrayList<Term> result = new ArrayList<>(code);
  ListIterator<Term> it = result.listIterator();
  while (it.hasNext()) {
    Term t = it.next();
    if (t.isWhitespace()) {
      String whitespace = t.toString();
      int indexOf = whitespace.indexOf('\n');
      if (indexOf >= 0) {
        it.set(new Whitespace(whitespace.substring(0, indexOf + 1)));
      }
    }
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Code.java

示例8: run

import java.util.ArrayList; //导入方法依赖的package包/类
public void run() throws Exception
{
	zipStream = new ZipOutputStream(targetStream);
	
	ArrayList<ResultWorksheet> resultWorksheets = new ArrayList<ResultWorksheet>();
	makeWorksheets(resultWorksheets);
	
	if (resultWorksheets.size() == 0)
		throw new Exception("Cannot create workbook without worksheets"); 
	
	createResultSheetContentsAndClearMatrices(resultWorksheets);
	
	ListIterator<ResultWorksheet> it = resultWorksheets.listIterator();
	while (it.hasNext())
	{
		ResultWorksheet resultWorksheet = it.next();
		save(resultWorksheet.document, "xl/" + resultWorksheet.filename);
	}
	
	makeWorkbookRels(resultWorksheets);
	save(resultWorkbookRels, "xl/_rels/workbook.xml.rels");
	
	makeWorkbookDefinition(resultWorksheets);
	save(resultWorkbookDefinition, "xl/workbook.xml");
	
	makeRelsContentTypes(resultWorksheets);
	save(resultContentTypes, "[Content_Types].xml");
	
	makeRelsBase();
	save(resultRelsBase, "_rels/.rels");
	
	makeStyles();
	save(styles, "xl/styles.xml");
	
	zipStream.close();
}
 
开发者ID:CenPC434,项目名称:java-tools,代码行数:37,代码来源:XLSXFileWriter.java

示例9: getBookSearchResultsContainer

import java.util.ArrayList; //导入方法依赖的package包/类
public BookSearchResultsContainer getBookSearchResultsContainer(int bookId) {
    BookDatabaseHelper bookDatabaseHelper = BookDatabaseHelper.getInstance(context, bookId);
    ArrayList<SearchResult> results = bookDatabaseHelper.search(searchString,searchOptions);

    BookPartsInfo bookPartsInfo=bookDatabaseHelper.getBookPartsInfo();

    ListIterator<SearchResult> searchResultIterator = results.listIterator();
    while (searchResultIterator.hasNext()) {
        SearchResult searchResult = searchResultIterator.next();
        if (!searchResult.isRequired()) {
            searchResultIterator.remove();
        }
    }
    return new BookSearchResultsContainer(isExpanded, bookId, bookDatabaseHelper.getBookName(),bookPartsInfo, results);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:16,代码来源:BookSearcher.java

示例10: replaceNeg

import java.util.ArrayList; //导入方法依赖的package包/类
public static ArrayList<Integer> replaceNeg(ArrayList<Integer> a) {
    ListIterator<Integer> iterator = a.listIterator();
    while (iterator.hasNext())
        if (iterator.next() < 0)
            iterator.set(0);
    return a;
}
 
开发者ID:ApolloZhu,项目名称:APCSAB,代码行数:8,代码来源:IteratorLab_shell.java

示例11: randomSynonym

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * 随机挑一个近义词
 * @param type 类型
 * @return
 */
public Synonym randomSynonym(Type type, String preWord)
{
    ArrayList<Synonym> synonymArrayList = new ArrayList<Synonym>(synonymList);
    ListIterator<Synonym> listIterator = synonymArrayList.listIterator();
    if (type != null) while (listIterator.hasNext())
    {
        Synonym synonym = listIterator.next();
        if (synonym.type != type || (preWord != null && CoreBiGramTableDictionary.getBiFrequency(preWord, synonym.realWord) == 0)) listIterator.remove();
    }
    if (synonymArrayList.size() == 0) return null;
    return synonymArrayList.get((int) (System.currentTimeMillis() % (long)synonymArrayList.size()));
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:18,代码来源:CommonSynonymDictionary.java

示例12: extractMainWords

import java.util.ArrayList; //导入方法依赖的package包/类
private ArrayList<String> extractMainWords(ArrayList<String> file) {
    List<String> commonWords = new ArrayList<>(Arrays.asList(common));
    ListIterator<String> iterator = file.listIterator();
    while (iterator.hasNext()) {
        iterator.set(iterator.next()
                .replaceAll("[^0-9][.]|[.][^0-9]|(?![.,])\\p{Punct}|\\,", "")
                .replace("\n", "")
                .replace("\r", "")
                .replaceAll("\\s+", " ")
                .toLowerCase());
    }
    for (int k = 0; k < file.size(); k++) {
        String[] words = file.get(k).split(" ");
        ArrayList<String> wordsList = new ArrayList<>(Arrays.asList(words));
        for (int i = 0; i < wordsList.size(); i++) {
            for (int j = 0; j < common.length; j++) {
                if (wordsList.contains(common[j])) {
                    wordsList.remove(common[j]);
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (String s : wordsList) {
            sb.append(s);
            sb.append(" ");
        }
        file.set(k, sb.toString());
    }
    return file;
}
 
开发者ID:jatanrathod,项目名称:Idea-Plagiarism,代码行数:31,代码来源:checkPlagiarism.java

示例13: filterLegacy

import java.util.ArrayList; //导入方法依赖的package包/类
private ArrayList<SaiyVoice> filterLegacy(@NonNull final ArrayList<SaiyVoice> voiceArray) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "filterLegacy");
    }

    if (isNetworkAllowed) {

        final ArrayList<SaiyVoice> voiceArrayCopy = new ArrayList<>(voiceArray);
        final ListIterator<SaiyVoice> itr = voiceArrayCopy.listIterator();

        SaiyVoice v;
        while (itr.hasNext()) {
            v = itr.next();
            if (v.getFeatures().contains(TTSDefaults.LEGACY_ENGINE_FIELD)) {
                itr.remove();
            }
        }

        if (voiceArrayCopy.isEmpty()) {
            return filterQuality(voiceArray);
        } else {
            return filterQuality(voiceArrayCopy);
        }
    }

    return filterQuality(voiceArray);
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:28,代码来源:SaiyTextToSpeech.java

示例14: segmentIterator

import java.util.ArrayList; //导入方法依赖的package包/类
public ListIterator<String> segmentIterator() {
    ArrayList<String> content = new ArrayList<String>(Arrays.asList(segments));
    return content.listIterator();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:5,代码来源:RelativePath.java

示例15: changeKeyboardLanguage

import java.util.ArrayList; //导入方法依赖的package包/类
public static void changeKeyboardLanguage(KeyboardSurface keyboardSurface, InputConnection inputConnection) {
    try {
        ArrayList<Integer> activatedLanguages = new ArrayList<>();

        //Add activated languages to the list
        if(isEnglishInputMethodActivated){
            activatedLanguages.add(ENGLISH_LANGUAGE_INPUT_METHOD);
        }

        if(isArabicInputMethodActivated){
            activatedLanguages.add(ARABIC_LANGUAGE_INPUT_METHOD);
        }

        if(isSpanishInputMethodActivated){
            activatedLanguages.add(SPANISH_LANGUAGE_INPUT_METHOD);
        }

        if(isFrenchInputMethodActivated){
            activatedLanguages.add(FRENCH_LANGUAGE_INPUT_METHOD);
        }

        //Check the next language
        int nextLang;
        Iterator activatedLanguagesIterator;
        if(activatedLanguages.indexOf(currentLanguage) < activatedLanguages.size() - 1){
            activatedLanguagesIterator = activatedLanguages.listIterator(activatedLanguages.indexOf(currentLanguage));
            activatedLanguagesIterator.next(); //For initialization to first position purpose
            //I don't need the current iterator, move to the next one
            nextLang = (int)activatedLanguagesIterator.next();
        } else{
            activatedLanguagesIterator = activatedLanguages.iterator();
            //I need the current iterator
            nextLang = (int)activatedLanguagesIterator.next();
        }

        //Change to the next language
        if(nextLang == ENGLISH_LANGUAGE_INPUT_METHOD){
            keyboardSurface.patternSurface = new EnglishSmallCharPattern(context);
        } else if(nextLang == ARABIC_LANGUAGE_INPUT_METHOD){
            keyboardSurface.patternSurface = new ArabicCharPattern(context);
        } else if(nextLang == SPANISH_LANGUAGE_INPUT_METHOD){
            keyboardSurface.patternSurface = new SpanishSmallCharPattern(context, inputConnection);
        } else if(nextLang == FRENCH_LANGUAGE_INPUT_METHOD){
            keyboardSurface.patternSurface = new FrenchSmallCharPattern(context);
        }

        //Speech current keyboard language
        speechCurrentKeyboardLanguage();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:MohammadAlBanna,项目名称:Swift-Braille-Soft-keyboard,代码行数:53,代码来源:Common.java


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