java.util.LinkedList Java Examples
The following examples show how to use
java.util.LinkedList.
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: NetworkConfiguration.java From openjdk-jdk9 with GNU General Public License v2.0 | 9 votes |
/** * Return a NetworkConfiguration instance. */ public static NetworkConfiguration probe() throws IOException { Map<NetworkInterface, List<Inet4Address>> ip4Interfaces = new HashMap<>(); Map<NetworkInterface, List<Inet6Address>> ip6Interfaces = new HashMap<>(); List<NetworkInterface> nifs = list(getNetworkInterfaces()); for (NetworkInterface nif : nifs) { // ignore interfaces that are down if (!nif.isUp() || nif.isPointToPoint()) continue; List<Inet4Address> ip4Addresses = new LinkedList<>(); List<Inet6Address> ip6Addresses = new LinkedList<>(); ip4Interfaces.put(nif, ip4Addresses); ip6Interfaces.put(nif, ip6Addresses); for (InetAddress addr : list(nif.getInetAddresses())) { if (addr instanceof Inet4Address) ip4Addresses.add((Inet4Address)addr); else if (addr instanceof Inet6Address) ip6Addresses.add((Inet6Address)addr); } } return new NetworkConfiguration(ip4Interfaces, ip6Interfaces); }
Example #2
Source File: SmsDatabase.java From mollyim-android with GNU General Public License v3.0 | 7 votes |
public MessageRecord getCurrent() { return new SmsMessageRecord(id, message.getMessageBody(), message.getRecipient(), message.getRecipient(), 1, System.currentTimeMillis(), System.currentTimeMillis(), -1, 0, message.isSecureMessage() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(), threadId, 0, new LinkedList<>(), message.getSubscriptionId(), message.getExpiresIn(), System.currentTimeMillis(), 0, false, Collections.emptyList(), false); }
Example #3
Source File: VariantSupport.java From lams with GNU General Public License v2.0 | 7 votes |
/** * Writes a warning to {@code System.err} that a variant type is * unsupported by HPSF. Such a warning is written only once for each variant * type. Log messages can be turned on or off by * * @param ex The exception to log */ protected static void writeUnsupportedTypeMessage (final UnsupportedVariantTypeException ex) { if (isLogUnsupportedTypes()) { if (unsupportedMessage == null) { unsupportedMessage = new LinkedList<Long>(); } Long vt = Long.valueOf(ex.getVariantType()); if (!unsupportedMessage.contains(vt)) { logger.log( POILogger.ERROR, ex.getMessage()); unsupportedMessage.add(vt); } } }
Example #4
Source File: HubRegistrationDAOImpl.java From arcusplatform with Apache License 2.0 | 6 votes |
@Override protected List<Object> getValues(HubRegistration entity) { List<Object> values = new LinkedList<Object>(); //Note this needs to be same order as defined in COLUMN_ORDER values.add(entity.getLastConnected()); values.add(entity.getState()!=null?entity.getState().name():null); values.add(entity.getUpgradeRequestTime()); values.add(entity.getFirmwareVersion()); values.add(entity.getTargetVersion()); values.add(entity.getUpgradeErrorCode()); values.add(entity.getUpgradeErrorMessage()); values.add(entity.getDownloadProgress()); values.add(entity.getUpgradeErrorTime()); log.trace("HubRegistration:Values = [{}]", values ); return values; }
Example #5
Source File: DeviceStatusManagerImpl.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private List<Device> getDetailedDevices() { List<Device> deviceList = new LinkedList<Device>(); JsonObject result = connMan.getDigitalSTROMAPI().query2(connMan.getSessionToken(), GET_DETAILD_DEVICES); if (result != null && result.isJsonObject()) { if (result.getAsJsonObject().get(GeneralLibConstance.QUERY_BROADCAST_ZONE_STRING).isJsonObject()) { result = result.getAsJsonObject().get(GeneralLibConstance.QUERY_BROADCAST_ZONE_STRING) .getAsJsonObject(); for (Entry<String, JsonElement> entry : result.entrySet()) { if (!(entry.getKey().equals(JSONApiResponseKeysEnum.ZONE_ID.getKey()) && entry.getKey().equals(JSONApiResponseKeysEnum.NAME.getKey())) && entry.getValue().isJsonObject()) { deviceList.add(new DeviceImpl(entry.getValue().getAsJsonObject())); } } } } return deviceList; }
Example #6
Source File: StatisticsLogParser.java From openAGV with Apache License 2.0 | 6 votes |
/** * Parses the given log file and returns a list of records contained in it. * * @param inputFile The file to be parsed. * @return A list of records contained in the file. * @throws FileNotFoundException If the given file was not found. * @throws IOException If there was a problem reading the file. */ public static List<StatisticsRecord> parseLog(File inputFile) throws FileNotFoundException, IOException { requireNonNull(inputFile, "inputFile"); List<StatisticsRecord> result = new LinkedList<>(); try (BufferedReader inputReader = new BufferedReader( new InputStreamReader(new FileInputStream(inputFile), Charset.forName("UTF-8")))) { String inputLine = inputReader.readLine(); while (inputLine != null) { StatisticsRecord record = StatisticsRecord.parseRecord(inputLine); if (record != null) { result.add(record); } inputLine = inputReader.readLine(); } } catch (IOException exc) { LOG.warn("Exception parsing input file", exc); throw exc; } return result; }
Example #7
Source File: Hypothesis.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
public LinkedList<Rule> generateRules(int ruleGenerationMode, Attribute label) { LinkedList<Rule> rules = new LinkedList<>(); switch (ruleGenerationMode) { case POSITIVE_RULE: rules.add(getPositiveRule(label)); break; case NEGATIVE_RULE: rules.add(getNegativeRule(label)); break; case PREDICTION_RULE: rules.add(getPredictionRule(label)); break; case POSITIVE_AND_NEGATIVE_RULES: rules.add(getPositiveRule(label)); rules.add(getNegativeRule(label)); break; } return rules; }
Example #8
Source File: UserRecommendService.java From sanshanblog with Apache License 2.0 | 6 votes |
/** * 完成用户推荐 * @return */ public List<UserRecommendDO> generateUsers(){ List<UserRecommendDO> recommendUsers = new LinkedList<>(); log.info("生成一次 推荐用户数据"); //List<UserDO> users = userRepository.findAll(); //for (int i = 0; i < users.size(); i++) { // UserDO userDO = users.get(i); // String username = userDO.getUsername(); // List<BlogVO> blogVOS = userBlogCacheService.getUserBlogs(username); // for (int j = 0; j <blogVOS.size() ; j++) { // Long id = blogVOS.get(i).getId(); // BlogRecommendDO blogRecommendDO = blogRecommendRepository.findOne(id); // Double blogRate = blogRecommendDO.getRecommendRate(); // } //} return recommendUsers; }
Example #9
Source File: SessionAuthHistory.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
/** * Undo/Remove entries upto and including the supplied entry from the history stack. * This can be done if the current authenticator decides it is FALLBACK. * * @return The last undone history element. Null if there is no matching entry. */ public AuthHistory undoUpto(AuthHistory historyElement) { LinkedList<AuthHistory> modifyingHistory = new LinkedList<>(); AuthHistory matchedEntry = null; for (AuthHistory historyEntry : authenticationStepHistory) { if (historyEntry.equals(historyElement)) { matchedEntry = historyEntry; break; } modifyingHistory.add(historyEntry); } if (matchedEntry != null) { authenticationStepHistory = modifyingHistory; } return matchedEntry; }
Example #10
Source File: RandomNumberGenerator.java From Neural-Network-Programming-with-Java-SecondEdition with MIT License | 6 votes |
public static int[] hashInt(int start,int end){ LinkedList<Integer> ll = new LinkedList<>(); ArrayList<Integer> al = new ArrayList<>(); for(int i=start;i<=end;i++){ ll.add(i); } int start0=0; for(int end0=end-start;end0>start0;end0--){ int rnd = RandomNumberGenerator.GenerateIntBetween(start0, end0); int value = ll.get(rnd); ll.remove(rnd); al.add(value); } al.add(ll.get(0)); ll.remove(0); return ArrayOperations.arrayListToIntVector(al); }
Example #11
Source File: KickstartParser.java From uyuni with GNU General Public License v2.0 | 6 votes |
/** * Constructor. * @param kickstartFileContentsIn Contents of the kickstart file. */ public KickstartParser(String kickstartFileContentsIn) { ksFileContents = kickstartFileContentsIn; optionLines = new LinkedList<String>(); packageLines = new LinkedList<String>(); preScriptLines = new LinkedList<String>(); postScriptLines = new LinkedList<String>(); String [] ksFileLines = ksFileContents.split("\\n"); List<String> currentSectionLines = new LinkedList<String>(); for (int i = 0; i < ksFileLines.length; i++) { String currentLine = ksFileLines[i]; if (isNewSection(currentLine)) { storeSection(currentSectionLines); currentSectionLines = new LinkedList<String>(); } currentSectionLines.add(currentLine); } storeSection(currentSectionLines); }
Example #12
Source File: SimpleTEDB.java From netphony-topology with Apache License 2.0 | 6 votes |
@Override public void notifyWavelengthReservationWLAN(LinkedList<Object> sourceVertexList,LinkedList<Object> targetVertexList,LinkedList<Integer> wlans, boolean bidirectional) { TEDBlock.lock(); try { for (int i=0;i<sourceVertexList.size();++i){ IntraDomainEdge edge=networkGraph.getEdge(sourceVertexList.get(i), targetVertexList.get(i)); edge.getTE_info().setWavelengthReserved(wlans.get(i)); log.info("Reservo: "+sourceVertexList.get(i).toString() + "-"+ targetVertexList.get(i).toString() +" wavelength: "+wlans.get(i)+" bidirectional"+bidirectional); if (bidirectional == true){ edge=networkGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i)); edge.getTE_info().setWavelengthReserved(wlans.get(i)); //log.info(""+edge.toString()); } } }finally{ TEDBlock.unlock(); } for (int i=0;i<registeredAlgorithms.size();++i){ registeredAlgorithms.get(i).notifyWavelengthReservation(sourceVertexList, targetVertexList, wlans.get(i)); if (bidirectional == true){ registeredAlgorithms.get(i).notifyWavelengthReservation(targetVertexList, sourceVertexList, wlans.get(i)); } } }
Example #13
Source File: SinkConfigUtils.java From pulsar with Apache License 2.0 | 6 votes |
private static Collection<String> collectAllInputTopics(SinkConfig sinkConfig) { List<String> retval = new LinkedList<>(); if (sinkConfig.getInputs() != null) { retval.addAll(sinkConfig.getInputs()); } if (sinkConfig.getTopicToSerdeClassName() != null) { retval.addAll(sinkConfig.getTopicToSerdeClassName().keySet()); } if (sinkConfig.getTopicsPattern() != null) { retval.add(sinkConfig.getTopicsPattern()); } if (sinkConfig.getTopicToSchemaType() != null) { retval.addAll(sinkConfig.getTopicToSchemaType().keySet()); } if (sinkConfig.getInputSpecs() != null) { retval.addAll(sinkConfig.getInputSpecs().keySet()); } return retval; }
Example #14
Source File: ComputeExteriorTest.java From elements-of-programming-interviews with MIT License | 6 votes |
@Test//a b c d e h m n p o i public void exteriorBinaryTree3() throws Exception { tree = BinaryTreeUtil.getFigureTenDotOne(); expected = new LinkedList<>( Arrays.asList( tree, tree.left, tree.left.left, tree.left.left.left, tree.left.left.right, tree.left.right.right.left, tree.right.left.right.left.right, tree.right.left.right.right, tree.right.right.right, tree.right.right, tree.right) ); test(expected, tree); }
Example #15
Source File: FindDuplicatesRefactoringPlugin.java From netbeans with Apache License 2.0 | 6 votes |
@Messages("WARN_HasQueries=The selected configuration contains inspections that do not provide any transformations. " + "No diff will be provided for code detected by such inspections. Use Source/Inspect... to perform code analysis.") private List<MessageImpl> performSearchForPattern(final RefactoringElementsBag refactoringElements) { ProgressHandleWrapper w = new ProgressHandleWrapper(this, 10, 90); Iterable<? extends HintDescription> queries = filterQueries(refactoring.getPattern(), true); BatchResult candidates = BatchSearch.findOccurrences(queries, refactoring.getScope(), w, /*XXX:*/HintsSettings.getGlobalSettings()); List<MessageImpl> problems = new LinkedList<MessageImpl>(candidates.problems); if (queries.iterator().hasNext()) { problems.add(new MessageImpl(MessageKind.WARNING, Bundle.WARN_HasQueries())); } prepareElements(candidates, w, refactoringElements, refactoring.isVerify(), problems); w.finish(); return problems; }
Example #16
Source File: TestAlarmSubsystemCallTree.java From arcusplatform with Apache License 2.0 | 6 votes |
@Test public void testCallTree() { List<Map<String, Object>> list = new LinkedList<Map<String,Object>>(); CallTreeEntry entry1 = createCallTreeEntry(owner, true); CallTreeEntry entry2 = createCallTreeEntry(person1, true); CallTreeEntry entry3 = createCallTreeEntry(person2, true); list.addAll(ImmutableList.<Map<String,Object>>of(entry1.toMap(), entry2.toMap(), entry3.toMap())); replay(); //1. owner first and enabled doSetAttributeForOkScenario(list, ImmutableList.<CallTreeEntry> of(entry1, entry2, entry3)); //2. owner 2nd and enabled, OK, should fail Map<String, Object> removed = list.remove(0); list.add(1, removed); doSetAttributeForFailedScenario(list, "Should get an exception for account owner not first"); //3. owner first and disabled, fail entry1.setEnabled(false); removed = list.remove(1); list.add(0, entry1.toMap()); doSetAttributeForFailedScenario(list, "Should get an exception for owner first and disabled"); }
Example #17
Source File: RFXMenuItem.java From marathonv5 with Apache License 2.0 | 6 votes |
private String getTagForMenu(MenuItem source) { LinkedList<MenuItem> menuItems = new LinkedList<>(); while (source != null) { menuItems.addFirst(source); source = source.getParentMenu(); } if (menuItems.getFirst() instanceof Menu) { if (menuItems.size() >= 2) { ownerNode = menuItems.get(1).getParentPopup().getOwnerNode(); return isMenuBar(ownerNode) ? "#menu" : "#contextmenu"; } } else { ownerNode = menuItems.getFirst().getParentPopup().getOwnerNode(); return "#contextmenu"; } return null; }
Example #18
Source File: ListDefaults.java From hottub with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="listProvider", parallel=true) public static Object[][] listCases() { final List<Object[]> cases = new LinkedList<>(); cases.add(new Object[] { Collections.emptyList() }); cases.add(new Object[] { new ArrayList<>() }); cases.add(new Object[] { new LinkedList<>() }); cases.add(new Object[] { new Vector<>() }); cases.add(new Object[] { new Stack<>() }); cases.add(new Object[] { new CopyOnWriteArrayList<>() }); cases.add(new Object[] { Arrays.asList() }); List<Integer> l = Arrays.asList(42); cases.add(new Object[] { new ArrayList<>(l) }); cases.add(new Object[] { new LinkedList<>(l) }); cases.add(new Object[] { new Vector<>(l) }); Stack<Integer> s = new Stack<>(); s.addAll(l); cases.add(new Object[]{s}); cases.add(new Object[] { new CopyOnWriteArrayList<>(l) }); cases.add(new Object[] { l }); return cases.toArray(new Object[0][cases.size()]); }
Example #19
Source File: JedisShartClient.java From howsun-javaee-framework with Apache License 2.0 | 6 votes |
/** * @param args */ public static void main(String[] args) { List<JedisShardInfo> list = new LinkedList<JedisShardInfo>(); JedisShardInfo jedisShardInfo1 = new JedisShardInfo(ip1, port); jedisShardInfo1.setPassword(JedisConstant.password); list.add(jedisShardInfo1); JedisShardInfo jedisShardInfo2 = new JedisShardInfo(ip2, port); jedisShardInfo2.setPassword(JedisConstant.password); list.add(jedisShardInfo2); ShardedJedisPool pool = new ShardedJedisPool(config, list); for (int i = 0; i < 2000; i++) { ShardedJedis jedis = pool.getResource(); String key = "howsun_" + i; //jedis.set(key, UUID.randomUUID().toString()); System.out.println(key + "\t" + jedis.get(key) + "\t" + jedis.toString()); pool.returnResource(jedis); } }
Example #20
Source File: ChannelManager.java From cloudsimsdn with GNU General Public License v2.0 | 5 votes |
public boolean updatePacketProcessing() { boolean needSendEvent = false; LinkedList<Channel> completeChannels = new LinkedList<Channel>(); // Check every channel for(Channel ch:channelTable.values()){ boolean isCompleted = ch.updatePacketProcessing(); if(isCompleted) { completeChannels.add(ch); if(ch.getActiveTransmissionNum() != 0) { // There are more transmissions even after completing these transmissions. needSendEvent = true; } } else { // Something is not completed. Need to send an event. needSendEvent = true; } } if(completeChannels.size() != 0) { nos.processCompletePackets(completeChannels); updateChannel(); } return needSendEvent; }
Example #21
Source File: UrlTagTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void createQueryStringOneParamForExsistingQueryString() throws JspException { List<Param> params = new LinkedList<>(); Set<String> usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); param.setValue("value"); params.add(param); String queryString = tag.createQueryString(params, usedParams, false); assertEquals("&name=value", queryString); }
Example #22
Source File: Introspector.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the list of "getter" methods for the given class. The list * is ordered so that isXXX methods appear before getXXX methods - this * is for compatibility with the JavaBeans Introspector. */ static List<Method> getReadMethods(Class<?> clazz) { // return cached result if available List<Method> cachedResult = getCachedMethods(clazz); if (cachedResult != null) return cachedResult; // get list of public methods, filtering out methods that have // been overridden to return a more specific type. List<Method> methods = StandardMBeanIntrospector.getInstance().getMethods(clazz); methods = MBeanAnalyzer.eliminateCovariantMethods(methods); // filter out the non-getter methods List<Method> result = new LinkedList<Method>(); for (Method m: methods) { if (isReadMethod(m)) { // favor isXXX over getXXX if (m.getName().startsWith(IS_METHOD_PREFIX)) { result.add(0, m); } else { result.add(m); } } } // add result to cache cache.put(clazz, new SoftReference<List<Method>>(result)); return result; }
Example #23
Source File: TilePlanetaryHologram.java From AdvancedRocketry with MIT License | 5 votes |
@Override public List<ModuleBase> getModules(int id, EntityPlayer player) { List<ModuleBase> modules = new LinkedList<ModuleBase>(); modules.add(targetGrav); modules.add(new ModuleSlider(6, 60, 0, TextureResources.doubleWarningSideBarIndicator, (ISliderBar)this)); modules.add(redstoneControl); updateText(); return modules; }
Example #24
Source File: LinkedArrayBenchmark.java From skywalking with Apache License 2.0 | 5 votes |
@Benchmark public void testReusedLinked200K() { LinkedList<SampleData> list = new LinkedList<SampleData>(); for (int times = 0; times < 1000; times++) { for (int pos = 0; pos < 200000; pos++) { list.add(new SampleData()); } list.clear(); } }
Example #25
Source File: AbstractIDEBridge.java From netbeans with Apache License 2.0 | 5 votes |
public void annotate( DebuggerAnnotation annotation ) { String type = annotation.getAnnotationType(); synchronized ( myAnnotations ) { List<DebuggerAnnotation> list = myAnnotations.get( type ); if ( list == null ) { list = new LinkedList<>(); myAnnotations.put( type , list ); } list.add( annotation ); } }
Example #26
Source File: CompoundFileWriter.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
/** Create the compound stream in the specified file. The file name is the * entire name (no extensions are added). */ public CompoundFileWriter(Directory dir, String name) { if (dir == null) throw new IllegalArgumentException("Missing directory"); if (name == null) throw new IllegalArgumentException("Missing name"); directory = dir; fileName = name; ids = new HashSet(); entries = new LinkedList(); }
Example #27
Source File: URLSearchParams.java From htmlunit with Apache License 2.0 | 5 votes |
/** * The getAll() method of the URLSearchParams interface returns all the values * associated with a given search parameter as an array. * * @param name The name of the parameter to return. * @return An array of USVStrings. */ @JsxFunction public NativeArray getAll(final String name) { final List<String> result = new LinkedList<>(); for (Entry<String, String> param : params_) { if (param.getKey().equals(name)) { result.add(param.getValue()); } } final NativeArray jsValues = new NativeArray(result.toArray()); ScriptRuntime.setBuiltinProtoAndParent(jsValues, getWindow(this), TopLevel.Builtins.Array); return jsValues; }
Example #28
Source File: DatasourceUIHelper.java From netbeans with Apache License 2.0 | 5 votes |
private static List populate(List<Datasource> datasources, boolean creationSupported, final JComboBox combo, final Datasource selectedDatasource, boolean selectItemLater, boolean serverSelectionSupported) { List<Object> items = (datasources == null ? new LinkedList<Object>() : new LinkedList<Object>(datasources)); if (items.size() > 0) { items.add(SEPARATOR_ITEM); } if (creationSupported) { items.add(NEW_ITEM); } if (serverSelectionSupported) { items.add(SELECT_SERVER_ITEM); } DatasourceComboBoxModel model = new DatasourceComboBoxModel(datasources, items); combo.setModel(model); if (selectedDatasource != null) { // Ensure that the correct item is selected before listeners like FocusListener are called. // ActionListener.actionPerformed() is not called if this method is already called from // actionPerformed(), in that case selectItemLater should be set to true and setSelectedItem() // below is called asynchronously so that the actionPerformed() is called setSelectedItem(combo, selectedDatasource); if (selectItemLater) { SwingUtilities.invokeLater(new Runnable() { // postpone item selection to enable event firing from JCombobox.setSelectedItem() @Override public void run() { setSelectedItem(combo, selectedDatasource); } }); } } return datasources; }
Example #29
Source File: EndToEndTransactionOrderTest.java From pravega with Apache License 2.0 | 5 votes |
private CompletableFuture<Void> startWriter(String writerId, MockClientFactory clientFactory, AtomicBoolean done) { EventWriterConfig writerConfig = EventWriterConfig.builder() .transactionTimeoutTime(30000) .build(); TransactionalEventStreamWriter<Integer> test = clientFactory.createTransactionalEventWriter(writerId, "test", new IntegerSerializer(), writerConfig); List<UUID> list = new LinkedList<>(); writersList.put(writerId, list); // Mocking pravega service by putting scale up and scale down requests for the stream return Futures.loop(() -> !done.get(), () -> Futures.delayedFuture(Duration.ofMillis(10), executor).thenAccept(v -> { try { Transaction<Integer> transaction = test.beginTxn(); transaction.getTxnId(); int i1 = counter.incrementAndGet(); transaction.writeEvent("0", i1); transaction.commit(); list.add(transaction.getTxnId()); eventToTxnMap.put(i1, transaction.getTxnId()); txnToWriter.put(transaction.getTxnId(), writerId); } catch (Throwable e) { log.error("test exception writing events {}", e); throw new CompletionException(e); } }), executor) .thenAccept(v -> test.close()); }
Example #30
Source File: ErrataFactory.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Finds errata based on CVE string * @param cve cve text * @return Errata if found, otherwise null */ public static List lookupByCVE(String cve) { List retval = new LinkedList(); SelectMode mode = ModeFactory.getMode("Errata_queries", "erratas_for_cve"); Map<String, Object> params = new HashMap<String, Object>(); params.put("cve", cve); List result = mode.execute(params); Session session = HibernateFactory.getSession(); for (Iterator iter = result.iterator(); iter.hasNext();) { Map row = (Map) iter.next(); Long rawId = (Long) row.get("id"); retval.add(session.load(PublishedErrata.class, rawId)); } return retval; }