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

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

源代码1 项目: nullpomino   文件: NetRoomInfo.java
/**
 * @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;
}
 
源代码2 项目: nullpomino   文件: NetRoomInfo.java
/**
 * @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;
}
 
源代码3 项目: ChickenChunks   文件: ChunkLoaderManager.java
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();
}
 
源代码4 项目: nullpomino   文件: LegacyNetVSBattleMode.java
/**
 * 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();
}
 
源代码5 项目: tapir   文件: InfoMap.java
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;
}
 
源代码6 项目: kson   文件: KsonContext.java
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);
}
 
源代码7 项目: TencentKona-8   文件: ResolverConfigurationImpl.java
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;
}
 
源代码8 项目: SubServers-2   文件: SubServer.java
/**
 * 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());
}
 
源代码9 项目: BmapLite   文件: CacheInteracter.java
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);
}
 
源代码10 项目: kogito-runtimes   文件: RuleImpl.java
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;
}
 
源代码11 项目: SubServers-2   文件: SubServer.java
/**
 * 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());
}
 
源代码12 项目: DNC   文件: Path.java
/**
 * @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;
}
 
源代码14 项目: UVA   文件: 00514 Rails.java
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();
	}
}
 
源代码15 项目: Zettelkasten   文件: SearchResultsFrame.java
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;
}
 
源代码16 项目: core   文件: HelpSystem.java
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));
}
 
源代码17 项目: cloudstack   文件: NexentaStorAppliance.java
/**
 * 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);
  }
}
 
源代码19 项目: openjdk-jdk9   文件: ResolverConfigurationImpl.java
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;
}
 
源代码20 项目: chipster   文件: DataBean.java
private void conditionallySelect(DataBeanSelector selector, LinkedList<DataBean> selected, DataBean bean) {
	if (!selected.contains(bean) && selector.shouldSelect(bean)) {
		selected.add(bean);
	}
}