Java Code Examples for java.util.LinkedList#contains()
The following examples show how to use
java.util.LinkedList#contains() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetRoomInfo.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @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; }
Example 2
Source File: InfoMap.java From tapir with MIT License | 6 votes |
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; }
Example 3
Source File: LegacyNetVSBattleMode.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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(); }
Example 4
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 6 votes |
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(); }
Example 5
Source File: NetRoomInfo.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @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; }
Example 6
Source File: CacheInteracter.java From BmapLite with GNU General Public License v3.0 | 5 votes |
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); }
Example 7
Source File: RuleImpl.java From kogito-runtimes with Apache License 2.0 | 5 votes |
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; }
Example 8
Source File: SubServer.java From SubServers-2 with Apache License 2.0 | 5 votes |
/** * 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()); }
Example 9
Source File: Path.java From DNC with GNU Lesser General Public License v2.1 | 5 votes |
/** * @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); }
Example 10
Source File: ResolverConfigurationImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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; }
Example 11
Source File: SubServer.java From SubServers-2 with Apache License 2.0 | 5 votes |
/** * 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()); }
Example 12
Source File: ResolverConfigurationImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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; }
Example 13
Source File: 00514 Rails.java From UVA with GNU General Public License v3.0 | 5 votes |
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(); } }
Example 14
Source File: SearchResultsFrame.java From Zettelkasten with GNU General Public License v3.0 | 5 votes |
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; }
Example 15
Source File: HelpSystem.java From core with GNU Lesser General Public License v2.1 | 5 votes |
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)); }
Example 16
Source File: NexentaStorAppliance.java From cloudstack with Apache License 2.0 | 5 votes |
/** * 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); }
Example 17
Source File: PackageRepositorySecurityDecorator.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
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); } }
Example 18
Source File: ResolverConfigurationImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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; }
Example 19
Source File: KsonContext.java From kson with Apache License 2.0 | 5 votes |
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); }
Example 20
Source File: DataBean.java From chipster with MIT License | 4 votes |
private void conditionallySelect(DataBeanSelector selector, LinkedList<DataBean> selected, DataBean bean) { if (!selected.contains(bean) && selector.shouldSelect(bean)) { selected.add(bean); } }