本文整理匯總了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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
}
示例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);
}
}
示例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
);
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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()));
}
示例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;
}
示例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);
}
示例14: segmentIterator
import java.util.ArrayList; //導入方法依賴的package包/類
public ListIterator<String> segmentIterator() {
ArrayList<String> content = new ArrayList<String>(Arrays.asList(segments));
return content.listIterator();
}
示例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();
}
}