下面列出了java.util.LinkedList#contains ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* @return true if 2 or more people have same IP
*/
public boolean hasSameIPPlayers() {
LinkedList<String> ipList = new LinkedList<String>();
if (startPlayers >= 2) {
for (NetPlayerInfo pInfo : playerSeatNowPlaying) {
if ((pInfo != null) && (pInfo.strRealIP.length() > 0)) {
if (ipList.contains(pInfo.strRealIP)) {
return true;
} else {
ipList.add(pInfo.strRealIP);
}
}
}
}
return false;
}
/**
* @return true if it's a team game
*/
public boolean isTeamGame() {
LinkedList<String> teamList = new LinkedList<String>();
if (startPlayers >= 2) {
for (NetPlayerInfo pInfo : playerSeatNowPlaying) {
if ((pInfo != null) && (pInfo.strTeam.length() > 0)) {
if (teamList.contains(pInfo.strTeam)) {
return true;
} else {
teamList.add(pInfo.strTeam);
}
}
}
}
return false;
}
private void forceChunks(IChickenChunkLoader loader, int dim, Collection<ChunkCoordIntPair> chunks) {
for (ChunkCoordIntPair coord : chunks) {
DimChunkCoord dimCoord = new DimChunkCoord(dim, coord);
LinkedList<IChickenChunkLoader> loaders = forcedChunksByChunk.get(dimCoord);
if (loaders == null)
forcedChunksByChunk.put(dimCoord, loaders = new LinkedList<IChickenChunkLoader>());
if (loaders.isEmpty()) {
timedUnloadQueue.remove(dimCoord);
addChunk(dimCoord);
}
if (!loaders.contains(loader))
loaders.add(loader);
}
forcedChunksByLoader.get(loader).addAll(chunks);
setDirty();
}
/**
* Surviving teamcountReturns(No teamPlayerAs well1Team and onecountObtained)
* @return Surviving teamcount
*/
private int getNumberOfTeamsAlive() {
LinkedList<String> listTeamName = new LinkedList<String>();
int noTeamCount = 0;
for(int i = 0; i < MAX_PLAYERS; i++) {
if(isPlayerExist[i] && !isDead[i] && owner.engine[i].gameActive) {
if(playerTeams[i].length() > 0) {
if(!listTeamName.contains(playerTeams[i])) {
listTeamName.add(playerTeams[i]);
}
} else {
noTeamCount++;
}
}
}
return noTeamCount + listTeamName.size();
}
public InfoMap put(int index, Info info) {
for (String cppName : info.cppNames != null ? info.cppNames : new String[] { null }) {
String[] keys = { normalize(cppName, false, false),
normalize(cppName, false, true) };
for (String key : keys) {
LinkedList<Info> infoList = super.get(key);
if (infoList == null) {
super.put(key, infoList = new LinkedList<Info>());
}
if (!infoList.contains(info)) {
switch (index) {
case -1: infoList.add(info); break;
case 0: infoList.addFirst(info); break;
default: infoList.add(index, info); break;
}
}
}
}
return this;
}
private Field[] getAccessibleFields(Class<?> clazz) {
if (!this.cachedFields.containsKey(clazz)) {
if (clazz == Integer.class) {
try {
throw new NullPointerException();
} catch (Exception e) {
e.printStackTrace();
}
}
LinkedList<Field> fields = new LinkedList<Field>();
if (clazz != null) {
if (clazz.getSuperclass() != null && clazz.getSuperclass() != Object.class) {
Field[] superFields = getAccessibleFields(clazz.getSuperclass());
for (Field superField : superFields) {
if (!fields.contains(superField) && !superField.isAnnotationPresent(Ignore.class)) {
fields.add(superField);
}
}
}
for (Field field : clazz.getDeclaredFields()) {
if (!fields.contains(field) && !field.isAnnotationPresent(Ignore.class) && !Modifier.isStatic(field.getModifiers())) {
field.setAccessible(true);
fields.add(field);
}
}
}
this.cachedFields.put(clazz, fields.toArray(new Field[fields.size()]));
}
return this.cachedFields.get(clazz);
}
private LinkedList<String> stringToList(String str) {
LinkedList<String> ll = new LinkedList<>();
// comma and space are valid delimites
StringTokenizer st = new StringTokenizer(str, ", ");
while (st.hasMoreTokens()) {
String s = st.nextToken();
if (!ll.contains(s)) {
ll.add(s);
}
}
return ll;
}
/**
* Checks if a Server is compatible
*
* @param server Server name to check
* @return Compatible Status
*/
public boolean isCompatible(String server) {
LinkedList<String> lowercaseIncompatibilities = new LinkedList<String>();
for (String key : getIncompatibilities()) {
lowercaseIncompatibilities.add(key.toLowerCase());
}
return lowercaseIncompatibilities.contains(server.toLowerCase());
}
public void addRouteHistory(RouteHistoryModel history) throws JSONException {
LinkedList<RouteHistoryModel> historyList = getRouteHistory();
if (null == historyList) {
historyList = new LinkedList<>();
}
if (historyList.contains(history)) {
historyList.remove(history);
}
historyList.addFirst(history);
setRouteHistory(historyList);
}
protected List<QueryImpl> collectDependingQueries(LinkedList<QueryImpl> accumulator) {
if (usedQueries == null) {
return accumulator;
}
for (QueryImpl query : usedQueries) {
if (!accumulator.contains(query)) {
accumulator.offerFirst(query);
query.collectDependingQueries(accumulator);
}
}
return accumulator;
}
/**
* Checks if a Server is compatible
*
* @param server Server name to check
* @return Compatible Status
*/
public boolean isCompatible(String server) {
LinkedList<String> lowercaseIncompatibilities = new LinkedList<String>();
for (String key : getIncompatibilities()) {
lowercaseIncompatibilities.add(key.toLowerCase());
}
return lowercaseIncompatibilities.contains(server.toLowerCase());
}
/**
* @param from Source, inclusive.
* @param to Sink, inclusive.
* @return The subpath.
* @throws Exception No subpath found; most probably an input parameter problem.
*/
public Path getSubPath(Server from, Server to) throws Exception {
// All other sanity check should have been passed when this object was created
if (!path_servers.contains(from)) {
throw new Exception("Cannot create a subpath if source is not in it.");
}
if (!path_servers.contains(to)) {
throw new Exception("Cannot create a subpath if sink is not in it.");
}
if (from == to) {
return new Path(new LinkedList<Server>(Collections.singleton(from)), new LinkedList<Turn>());
}
int from_index = path_servers.indexOf(from);
int to_index = path_servers.indexOf(to);
if (from_index >= to_index) {
throw new Exception("Cannot create sub-path from " + from.toString() + " to " + to.toString());
}
// subList: 'from' is inclusive but 'to' is exclusive
LinkedList<Server> subpath_servers = new LinkedList<Server>(path_servers.subList(from_index, to_index));
subpath_servers.add(to);
List<Turn> subpath_turns = new LinkedList<Turn>();
if (subpath_servers.size() > 1) {
for (Turn l : path_turns) {
Server src_l = l.getSource();
Server snk_l = l.getDest();
if (subpath_servers.contains(src_l) && subpath_servers.contains(snk_l)) {
subpath_turns.add(l);
}
}
}
return new Path(subpath_servers, subpath_turns);
}
private LinkedList<String> stringToList(String str) {
LinkedList<String> ll = new LinkedList<>();
// comma and space are valid delimites
StringTokenizer st = new StringTokenizer(str, ", ");
while (st.hasMoreTokens()) {
String s = st.nextToken();
if (!ll.contains(s)) {
ll.add(s);
}
}
return ll;
}
public static void main (String [] abc) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s;
while (!(s=br.readLine()).equals("0")) {
int n=Integer.parseInt(s);
while (!(s=br.readLine()).equals("0")) {
LinkedList<Integer> incomingTrain=new LinkedList<>();
for (int i=1;i<=n;i++) incomingTrain.add(i);
Stack<Integer> stationTrain=new Stack<>();
StringTokenizer st=new StringTokenizer(s);
boolean fail=false;
while (st.hasMoreTokens()) {
int queue=Integer.parseInt(st.nextToken());
if (incomingTrain.contains(queue))
while (incomingTrain.contains(queue)) stationTrain.push(incomingTrain.removeFirst());
if (stationTrain.size()>0 && stationTrain.peek()==queue) stationTrain.pop();
else {
fail=true;
break;
}
}
if (fail) System.out.println("No");
else System.out.println("Yes");
}
System.out.println();
}
}
private String[] getHighlightSearchterms() {
// prepare array for search terms which might be highlighted
String[] sts = null;
// get search terms, if highlighting is requested
if (settingsObj.getHighlightSearchResults()) {
// get the selected index, i.e. the searchrequest we want to retrieve
int index = jComboBoxSearches.getSelectedIndex();
// get the related search terms
sts = searchrequest.getSearchTerms(index);
// check whether the search was a synonym-search. if yes, add synonyms to search terms
if (searchrequest.isSynonymSearch(index)) {
// create new linked list that will contain all highlight-terms, including
// the related synonyms of the highlight-terms
LinkedList<String> highlight = new LinkedList<>();
// go through all searchterms
for (String s : sts) {
// get the synonym-line for each search term
String[] synline = synonymsObj.getSynonymLineFromAny(s,false);
// if we have synonyms...
if (synline!=null) {
// add them to the linked list, if they are new
for (String sy : synline) {
if (!highlight.contains(sy)) highlight.add(sy);
}
}
// else simply add the search term to the linked list
else if (!highlight.contains(s)) {
highlight.add(s);
}
}
if (highlight.size()>0) sts = highlight.toArray(new String[highlight.size()]);
}
}
return sts;
}
public void getAttributeDescriptions(
ModelNode resourceAddress,
final FormAdapter form,
final AsyncCallback<List<FieldDesc>> callback)
{
final ModelNode operation = new ModelNode();
operation.get(OP).set(READ_RESOURCE_DESCRIPTION_OPERATION);
operation.get(ADDRESS).set(resourceAddress);
operation.get(RECURSIVE).set(true);
operation.get(LOCALE).set(getLocale());
// build field name list
List<String> formItemNames = form.getFormItemNames();
BeanMetaData beanMetaData = propertyMetaData.getBeanMetaData(form.getConversionType());
List<PropertyBinding> bindings = beanMetaData.getProperties();
final LinkedList<Lookup> fieldNames = new LinkedList<Lookup>();
for(String name : formItemNames)
{
for(PropertyBinding binding : bindings)
{
if(!binding.isKey() && binding.getJavaName().equals(name)) {
String[] splitDetypedNames = binding.getDetypedName().split("/");
// last one in the path is the attribute name
Lookup lookup = new Lookup(splitDetypedNames[splitDetypedNames.length - 1], binding.getJavaName());
if(!fieldNames.contains(lookup))
fieldNames.add(lookup);
}
}
}
dispatcher.execute(new DMRAction(operation), new DescriptionsCallback(fieldNames, callback));
}
/**
* Checks if iSCSI target is member of target group.
* @param targetGroupName iSCSI target group name
* @param targetName iSCSI target name
* @return true if target is member of iSCSI target group, else false
*/
boolean isTargetMemberOfTargetGroup(String targetGroupName, String targetName) {
ListOfStringsNmsResponse response = (ListOfStringsNmsResponse) client.execute(ListOfStringsNmsResponse.class, "stmf", "list_targetgroup_members", targetGroupName);
if (response == null) {
return false;
}
LinkedList<String> result = response.getResult();
return result != null && result.contains(targetName);
}
private void resolveDependencies(List<Package> packages, LinkedList<Package> resolved) {
if (packages.size() != resolved.size()) {
for (Package pack : packages) {
if (!resolved.contains(pack)
&& (!packages.contains(pack.getParent()) || resolved.contains(pack.getParent()))) {
resolved.add(pack);
}
}
resolveDependencies(packages, resolved);
}
}
private LinkedList<String> stringToList(String str) {
LinkedList<String> ll = new LinkedList<>();
// comma and space are valid delimites
StringTokenizer st = new StringTokenizer(str, ", ");
while (st.hasMoreTokens()) {
String s = st.nextToken();
if (!ll.contains(s)) {
ll.add(s);
}
}
return ll;
}
private void conditionallySelect(DataBeanSelector selector, LinkedList<DataBean> selected, DataBean bean) {
if (!selected.contains(bean) && selector.shouldSelect(bean)) {
selected.add(bean);
}
}