java.util.LinkedList#indexOf ( )源码实例Demo

下面列出了java.util.LinkedList#indexOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: imsdk-android   文件: ViewPool.java
public static void recycleView(View v) {
    Class type = v.getClass();
    if (v != null && type != null) {
        LinkedList<View> recycleQueue = recycleMap.get(type);
        LinkedList<View> usingList = usingMap.get(type);
        if (recycleQueue == null) {
            recycleQueue = new LinkedList<>();
            recycleMap.put(type, recycleQueue);
        }
        if (usingList == null) {
            usingList = new LinkedList<>();
            usingMap.put(type, usingList);
        }
        int index = usingList.indexOf(v);
        if (index != -1) {
            Object o = v.getTag(TAG_VIEW_CANNOT_RECYCLE);
            if (o == null) {
                recycleQueue.add(v);
                usingList.remove(v);
            }
        }
    }
}
 
源代码2 项目: NettyChat   文件: CEventCenter.java
/**
 * 注册监听器
 * @param listener
 *                  监听器
 * @param topics
 *                  主题(一个服务可以发布多个主题事件)
 */
public static void registerEventListener(I_CEventListener listener, String[] topics) {
    if(null == listener || null == topics) {
        return;
    }

    synchronized (mListenerLock) {
        for(String topic : topics) {
            if(TextUtils.isEmpty(topic)) {
                continue;
            }
            Object obj = mListenerMap.get(topic);
            if(null == obj) {
                // 还没有监听器,直接放到Map集合
                mListenerMap.put(topic, listener);
            }else if(obj instanceof I_CEventListener) {
                // 有一个监听器
                I_CEventListener oldListener = (I_CEventListener) obj;
                if(listener == oldListener) {
                    // 去重
                    continue;
                }
                LinkedList<I_CEventListener> list = new LinkedList<I_CEventListener>();
                list.add(oldListener);
                list.add(listener);
                mListenerMap.put(topic, list);
            }else if(obj instanceof List) {
                // 有多个监听器
                LinkedList<I_CEventListener> listenerList = (LinkedList<I_CEventListener>) obj;
                if(listenerList.indexOf(listener) >= 0) {
                    // 去重
                    continue;
                }
                listenerList.add(listener);
            }
        }
    }
}
 
源代码3 项目: CEventCenter   文件: CEventCenter.java
/**
 * 注册监听器
 *
 * @param listener 监听器
 * @param topics   多个主题
 */
public static void registerEventListener(I_CEventListener listener, String[] topics) {
    if (null == listener || null == topics) {
        return;
    }

    synchronized (LISTENER_LOCK) {
        for (String topic : topics) {
            if (TextUtils.isEmpty(topic)) {
                continue;
            }

            Object obj = LISTENER_MAP.get(topic);
            if (null == obj) {
                // 还没有监听器,直接放到Map集合
                LISTENER_MAP.put(topic, listener);
            } else if (obj instanceof I_CEventListener) {
                // 有一个监听器
                I_CEventListener oldListener = (I_CEventListener) obj;
                if (listener == oldListener) {
                    // 去重
                    continue;
                }
                LinkedList<I_CEventListener> list = new LinkedList<>();
                list.add(oldListener);
                list.add(listener);
                LISTENER_MAP.put(topic, list);
            } else if (obj instanceof List) {
                // 有多个监听器
                LinkedList<I_CEventListener> listeners = (LinkedList<I_CEventListener>) obj;
                if (listeners.indexOf(listener) >= 0) {
                    // 去重
                    continue;
                }
                listeners.add(listener);
            }
        }
    }
}
 
源代码4 项目: MHViewer   文件: DownloadManager.java
public void deleteDownload(String gid) {
    stopDownloadInternal(gid);
    DownloadInfo info = mAllInfoMap.get(gid);
    if (info != null) {
        // Remove from DB
        EhDB.removeDownloadInfo(info.gid);

        // Remove all list and map
        mAllInfoList.remove(info);
        mAllInfoMap.remove(info.gid);

        // Remove label list
        LinkedList<DownloadInfo> list = getInfoListForLabel(info.label);
        if (list != null) {
            int index = list.indexOf(info);
            if (index >= 0) {
                list.remove(info);
                // Update listener
                for (DownloadInfoListener l: mDownloadInfoListeners) {
                    l.onRemove(info, list, index);
                }
            }
        }

        // Ensure download
        ensureDownload();
    }
}
 
源代码5 项目: iceberg   文件: SchemaUpdate.java
@SuppressWarnings("checkstyle:IllegalType")
private static List<Types.NestedField> moveFields(List<Types.NestedField> fields,
                                                  Collection<Move> moves) {
  LinkedList<Types.NestedField> reordered = Lists.newLinkedList(fields);

  for (Move move : moves) {
    Types.NestedField toMove = Iterables.find(reordered, field -> field.fieldId() == move.fieldId());
    reordered.remove(toMove);

    switch (move.type()) {
      case FIRST:
        reordered.addFirst(toMove);
        break;

      case BEFORE:
        Types.NestedField before = Iterables.find(reordered, field -> field.fieldId() == move.referenceFieldId());
        int beforeIndex = reordered.indexOf(before);
        // insert the new node at the index of the existing node
        reordered.add(beforeIndex, toMove);
        break;

      case AFTER:
        Types.NestedField after = Iterables.find(reordered, field -> field.fieldId() == move.referenceFieldId());
        int afterIndex = reordered.indexOf(after);
        reordered.add(afterIndex + 1, toMove);
        break;

      default:
        throw new UnsupportedOperationException("Unknown move type: " + move.type());
    }
  }

  return reordered;
}
 
源代码6 项目: nullpomino   文件: LegacyNetVSBattleMode.java
/**
 * Update player names
 */
private void updatePlayerNames() {
	LinkedList<NetPlayerInfo> pList = netLobby.getSameRoomPlayerInfoList();
	LinkedList<String> teamList = new LinkedList<String>();

	for(int i = 0; i < MAX_PLAYERS; i++) {
		playerNames[i] = "";
		playerTeams[i] = "";
		playerTeamColors[i] = 0;
		playerGamesCount[i] = 0;
		playerWinCount[i] = 0;

		for(NetPlayerInfo pInfo: pList) {
			if((pInfo.seatID != -1) && (getPlayerIDbySeatID(pInfo.seatID) == i)) {
				playerNames[i] = pInfo.strName;
				playerTeams[i] = pInfo.strTeam;
				playerGamesCount[i] = pInfo.playCountNow;
				playerWinCount[i] = pInfo.winCountNow;

				// Set team color
				if(playerTeams[i].length() > 0) {
					if(!teamList.contains(playerTeams[i])) {
						teamList.add(playerTeams[i]);
						playerTeamColors[i] = teamList.size();
					} else {
						playerTeamColors[i] = teamList.indexOf(playerTeams[i]) + 1;
					}
				}
			}
		}
	}
}
 
源代码7 项目: Zettelkasten   文件: Tools.java
/**
 * This method extracts all author IDs of footnotes in a HTML formatted entry.
 * This method is used when displaying an entry in the main window, to
 * show all authors of an entry, including those authors which appear
 * in footnotes, but are not assigned as author value.
 * 
 * @param content the HTML-formatted content of an entry.
 * @return all author IDs inside footnotes
 */
public static LinkedList extractFootnotesFromContent(String content) {
    // now prepare a reference list from possible footnotes
    LinkedList<String> footnotes = new LinkedList<>();
    // position index for finding the footnotes
    int pos = 0;
    // do search as long as pos is not -1 (not-found)
    while (pos != -1) {
        // find the html-tag for the footnote
        pos = content.indexOf(Constants.footnoteHtmlTag, pos);
        // if we found something...
        if (pos != -1) {
            // find the closing quotes
            int end = content.indexOf("\"", pos + Constants.footnoteHtmlTag.length());
            // if we found that as well...
            if (end != -1) {
                // extract footnote-number
                String fn = content.substring(pos + Constants.footnoteHtmlTag.length(), end);
                // and add it to the linked list, if it doesn't already exist
                if (-1 == footnotes.indexOf(fn)) {
                    footnotes.add(fn);
                }
                // set pos to new position
                pos = end;
            } else {
                pos = pos + Constants.footnoteHtmlTag.length();
            }
        }
    }
    return footnotes;
}
 
源代码8 项目: fnlp   文件: SeqEval.java
void getRightOOV(String string) {

		if(dict==null||dict.size()==0)
			return;

		TreeMap<String,String> set = new TreeMap<String,String>();
		for(int i=0;i<entityCs.size();i++){
			LinkedList<Entity>  cList =  entityCs.get(i);
			LinkedList<Entity>  pList =  entityPs.get(i);
			LinkedList<Entity>  cpList =  entityCinPs.get(i);

			for(Entity entity:cpList){
				String e = entity.getEntityStr();
				//				if(dict.contains(e))
				//					break;
				int idx = cList.indexOf(entity);
				String s= " ... ";
				if(idx!=-1){
					if(idx>0)
						s = cList.get(idx-1).getEntityStr() + s;
					if(idx<cList.size()-1)
						s = s+ cList.get(idx+1).getEntityStr();
				}
				adjust(set, s, 1);
			}	

		}
		List<Entry> sortedposFreq = MyCollection.sort(set);		
		MyCollection.write(sortedposFreq, string, true);

	}
 
源代码9 项目: Rel   文件: Core.java
public static void updateRecentlyUsedDatabaseList(String dbURL) {
	if (dbURL.startsWith("db:")) {
		File urlFileRef = new File(dbURL.substring(3));
		dbURL = "db:" + urlFileRef.getAbsolutePath();
	}
	LinkedList<String> recentlyUsed = new LinkedList<String>();
	recentlyUsed.addAll(Arrays.asList(Preferences.getPreferenceStringArray(recentlyUsedDatabaseListPreference)));
	int indexOfDBURL = recentlyUsed.indexOf(dbURL);
	if (indexOfDBURL >= 0)
		recentlyUsed.remove(dbURL);
	recentlyUsed.addFirst(dbURL);
	Preferences.setPreference(recentlyUsedDatabaseListPreference, recentlyUsed.toArray(new String[0]));
}
 
源代码10 项目: EhViewer   文件: DownloadManager.java
public void deleteDownload(long gid) {
    stopDownloadInternal(gid);
    DownloadInfo info = mAllInfoMap.get(gid);
    if (info != null) {
        // Remove from DB
        EhDB.removeDownloadInfo(info.gid);

        // Remove all list and map
        mAllInfoList.remove(info);
        mAllInfoMap.remove(info.gid);

        // Remove label list
        LinkedList<DownloadInfo> list = getInfoListForLabel(info.label);
        if (list != null) {
            int index = list.indexOf(info);
            if (index >= 0) {
                list.remove(info);
                // Update listener
                for (DownloadInfoListener l: mDownloadInfoListeners) {
                    l.onRemove(info, list, index);
                }
            }
        }

        // Ensure download
        ensureDownload();
    }
}
 
源代码11 项目: nullpomino   文件: NetDummyVSMode.java
/**
 * NET-VS: Update player variables
 */
@Override
protected void netUpdatePlayerExist() {
	netvsMySeatID = netLobby.netPlayerClient.getYourPlayerInfo().seatID;
	netvsNumPlayers = 0;
	netNumSpectators = 0;
	netPlayerName = netLobby.netPlayerClient.getPlayerName();
	netIsWatch = netvsIsWatch();

	for(int i = 0; i < NETVS_MAX_PLAYERS; i++) {
		netvsPlayerExist[i] = false;
		netvsPlayerReady[i] = false;
		netvsPlayerActive[i] = false;
		netvsPlayerSeatID[i] = -1;
		netvsPlayerUID[i] = -1;
		netvsPlayerWinCount[i] = 0;
		netvsPlayerPlayCount[i] = 0;
		netvsPlayerName[i] = "";
		netvsPlayerTeam[i] = "";
		owner.engine[i].framecolor = GameEngine.FRAME_COLOR_GRAY;
	}

	LinkedList<NetPlayerInfo> pList = netLobby.updateSameRoomPlayerInfoList();
	LinkedList<String> teamList = new LinkedList<String>();

	for(NetPlayerInfo pInfo: pList) {
		if(pInfo.roomID == netCurrentRoomInfo.roomID) {
			if(pInfo.seatID == -1) {
				netNumSpectators++;
			} else {
				netvsNumPlayers++;

				int playerID = netvsGetPlayerIDbySeatID(pInfo.seatID);
				netvsPlayerExist[playerID] = true;
				netvsPlayerReady[playerID] = pInfo.ready;
				netvsPlayerActive[playerID] = pInfo.playing;
				netvsPlayerSeatID[playerID] = pInfo.seatID;
				netvsPlayerUID[playerID] = pInfo.uid;
				netvsPlayerWinCount[playerID] = pInfo.winCountNow;
				netvsPlayerPlayCount[playerID] = pInfo.playCountNow;
				netvsPlayerName[playerID] = pInfo.strName;
				netvsPlayerTeam[playerID] = pInfo.strTeam;

				// Set frame color
				if(pInfo.seatID < NETVS_PLAYER_COLOR_FRAME.length) {
					owner.engine[playerID].framecolor = NETVS_PLAYER_COLOR_FRAME[pInfo.seatID];
				}

				// Set team color
				if(netvsPlayerTeam[playerID].length() > 0) {
					if(!teamList.contains(netvsPlayerTeam[playerID])) {
						teamList.add(netvsPlayerTeam[playerID]);
						netvsPlayerTeamColor[playerID] = teamList.size();
					} else {
						netvsPlayerTeamColor[playerID] = teamList.indexOf(netvsPlayerTeam[playerID]) + 1;
					}
				}
			}
		}
	}
}
 
源代码12 项目: spotbugs   文件: ListTests.java
public void test2NoBugs(LinkedList<CharSequence> list) {
    list.indexOf(new StringBuffer("Key"));
}
 
源代码13 项目: spotbugs   文件: ListTests.java
public void test2Bugs(LinkedList<CharSequence> list) {
    list.indexOf(Integer.valueOf(3));
}
 
源代码14 项目: Zettelkasten   文件: ExportTools.java
/**
 * This method creates a reference list in the export-format. This method is
 * used when exporting entries into html-format. The reference-list is
 * created from the used footnotes, i.e. each author-footnote in an entry is
 * added to the final reference-list. When exporting to HTML, the
 * authors-footnotes are linked with the author-value in the reference-list.
 *
 * @param dataObj
 * @param settingsObj
 * @param contentpage the complete html-page that is going to be exported,
 * so the author-footnotes can be extracted from this content.
 * @param footnotetag the footnote-tag, to identify where a footnote starts
 * @param footnoteclose the closing-tag of footnotes, so the author-number
 * within the footnote can be extracted
 * @param headeropen the header-tag, in case the title "reference list" is
 * surrounded by a header-tag
 * @param headerclose the header-tag, in case the title "reference list" is
 * surrounded by a header-tag
 * @param listtype whether the list is formatted in html or plain text. use
 * following constants:<br>
 * - CConstants.REFERENCE_LIST_TXT<br>
 * - CConstants.REFERENCE_LIST_HTML
 * @return a converted String containing the reference list with all
 * references (authors) that appeared as author-footnote in the export-file
 */
public static String createReferenceList(Daten dataObj, Settings settingsObj, String contentpage, String footnotetag, String footnoteclose, String headeropen, String headerclose, int listtype) {
    // now prepare a reference list from possible footnotes
    LinkedList<String> footnotes = new LinkedList<>();
    // position index for finding the footnotes
    int pos = 0;
    // get length of footnote-tag, so we know where to look for the author-number within the footnote
    int len = footnotetag.length();
    // do search as long as pos is not -1 (not-found)
    while (pos != -1) {
        // find the html-tag for the footnote
        pos = contentpage.indexOf(footnotetag, pos);
        // if we found something...
        if (pos != -1) {
            // find the closing quotes
            int end = contentpage.indexOf(footnoteclose, pos + len);
            // if we found that as well...
            if (end != -1) {
                // extract footnote-number
                String fn = contentpage.substring(pos + len, end);
                // and add it to the linked list, if it doesn't already exist
                if (-1 == footnotes.indexOf(fn)) {
                    footnotes.add(fn);
                }
                // set pos to new position
                pos = end;
            } else {
                pos = pos + len;
            }
        }
    }
    StringBuilder sb = new StringBuilder("");
    // now we have all footnotes, i.e. the author-index-numbers, in the linked
    // list. now we can create a reference list
    if (footnotes.size() > 0) {
        // first, init the list in html...
        sb.append(headeropen);
        // append a new headline with the bullet's name
        sb.append(resourceMap.getString("referenceListHeading"));
        sb.append(headerclose).append(System.lineSeparator());
        // iterator for the linked list
        Iterator<String> i = footnotes.iterator();
        // go through all footnotes
        while (i.hasNext()) {
            // get author-number-string
            String au = i.next();
            try {
                // convert string to int
                int aunr = Integer.parseInt(au);
                switch (listtype) {
                    case Constants.REFERENCE_LIST_TXT:
                        // prepare html-stuff for authors
                        sb.append("[").append(au).append("] ").append(dataObj.getAuthor(aunr)).append(System.lineSeparator());
                        break;
                    case Constants.REFERENCE_LIST_HTML:
                        // prepare html-stuff for authors
                        sb.append("<p class=\"reflist\"><b>[<a name=\"fn_").append(au).append("\">").append(au).append("</a>]</b> ");
                        sb.append(dataObj.getAuthor(aunr));
                        sb.append("</p>").append(System.lineSeparator());
                        break;
                }
            } catch (NumberFormatException e) {
                Constants.zknlogger.log(Level.WARNING, e.getLocalizedMessage());
            }
        }
    }
    return sb.toString();
}
 
源代码15 项目: Zettelkasten   文件: ExportToHtmlTask.java
/**
 *
 * @param createTOC
 * @return
 */
private String createFootnotes(boolean createTOC) {
    // now prepare a reference list from possible footnotes
    LinkedList<String> footnotes = new LinkedList<>();
    // position index for finding the footnotes
    int pos = 0;
    // we need the content of the stringbuilder in a string that we can search through
    String dummysb = exportPage.toString();
    // do search as long as pos is not -1 (not-found)
    while (pos != -1) {
        // find the html-tag for the footnote
        pos = dummysb.indexOf(Constants.footnoteHtmlTag, pos);
        // if we found something...
        if (pos != -1) {
            // find the closing quotes
            int end = dummysb.indexOf("\"", pos + Constants.footnoteHtmlTag.length());
            // if we found that as well...
            if (end != -1) {
                // extract footnote-number
                String fn = dummysb.substring(pos + Constants.footnoteHtmlTag.length(), end);
                // and add it to the linked list, if it doesn't already exist
                if (-1 == footnotes.indexOf(fn)) {
                    footnotes.add(fn);
                }
                // set pos to new position
                pos = end;
            } else {
                pos = pos + Constants.footnoteHtmlTag.length();
            }
        }
    }
    // now we have all footnotes, i.e. the author-index-numbers, in the linked
    // list. now we can create a reference list
    if (footnotes.size() > 0) {
        // insert a paragraph for space
        exportPage.append("<p>&nbsp;</p>").append(System.lineSeparator());
        // first, init the list in html and add title "references"
        exportPage.append("<h1>").append(resourceMap.getString("referenceListHeading")).append("</h1>").append(System.lineSeparator());
        // open unordered list-tag
        exportPage.append("<ul>").append(System.lineSeparator());
        // iterator for the linked list
        Iterator<String> i = footnotes.iterator();
        while (i.hasNext()) {
            String au = i.next();
            try {
                int aunr = Integer.parseInt(au);
                exportPage.append("<li class=\"reflist\"><b>[<a name=\"fn_").append(au).append("\">").append(au).append("</a>]</b> ");
                exportPage.append(dataObj.getAuthor(aunr));
                exportPage.append("</li>").append(System.lineSeparator());
            } catch (NumberFormatException e) {
                Constants.zknlogger.log(Level.WARNING, e.getLocalizedMessage());
            }
        }
        // close unordered list-tag
        exportPage.append("</ul>").append(System.lineSeparator());
    }
    // add table of contents, if requested
    if (createTOC) {
        exportPage.insert(0, exportTableOfContent.toString() + "<br><p>&nbsp;</p><br>");
    }
    // and if so, insert style-definition
    exportPage.insert(0, HtmlUbbUtil.getHtmlHeaderForDesktopExport(settingsObj));
    // and close tags
    exportPage.append("</body></html>");
    // return result
    return exportPage.toString();
}
 
源代码16 项目: niftyeditor   文件: NiftyDDManager.java
private int findIndex(GElement dragged) {
    LinkedList<GElement> elements = dragged.getParent().getElements();
    return elements.indexOf(dragged);
}