Java Code Examples for java.util.TreeMap#put()
The following examples show how to use
java.util.TreeMap#put() .
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: Lehman_AnalyzeKStructure.java From symja_android_library with GNU General Public License v3.0 | 6 votes |
private void analyzeProgression(int start, int step, int arrayIndex, TreeMap<Integer, List<Progression>> successRate2Progressions) { int successSum = 0; int numCount = 0; final int kLimit = (int) Math.cbrt(1L<<(30+arrayIndex+1)); for (int k=start; k<kLimit; k+=step) { int successCount = kFactorCounts[k][arrayIndex]; successSum += successCount; numCount++; } int avgSuccessCount = (int) (successSum / (float) numCount); //LOG.info(" Progression " + step + "*m + " + start + ": Avg. successes = " + avgSuccessCount + ", #tests = " + numCount); List<Progression> progressions = successRate2Progressions.get(avgSuccessCount); if (progressions == null) progressions = new ArrayList<Progression>(); progressions.add(new Progression(start, step)); successRate2Progressions.put(avgSuccessCount, progressions); }
Example 2
Source File: SimpleRepository.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public SortedMap getNodeList(ITicket ticket) throws AccessDeniedException { Long workspaceId = ticket.getWorkspaceId(); List nodes = workspaceDAO.findWorkspaceNodes(workspaceId); if (log.isDebugEnabled()) { log.debug("Workspace " + workspaceId + " has " + nodes.size() + " nodes."); } TreeMap map = new TreeMap(); Iterator iter = nodes.iterator(); while (iter.hasNext()) { CrNode node = (CrNode) iter.next(); map.put(node.getNodeId(), node.getVersionHistory()); } return map; }
Example 3
Source File: ShardedTableMapFile.java From datawave with Apache License 2.0 | 6 votes |
public static TreeMap<Text,String> getShardIdToLocations(Configuration conf, String tableName) throws IOException { TreeMap<Text,String> locations = new TreeMap<>(); SequenceFile.Reader reader = ShardedTableMapFile.getReader(conf, tableName); Text shardID = new Text(); Text location = new Text(); try { while (reader.next(shardID, location)) { locations.put(new Text(shardID), location.toString()); } } finally { reader.close(); } return locations; }
Example 4
Source File: LobstackMap.java From jelectrum with MIT License | 6 votes |
public void putAll(Map<String, ByteString> m) { try { TreeMap<String, ByteBuffer> pm = new TreeMap<>(); for(Map.Entry<String, ByteString> me : m.entrySet()) { pm.put(me.getKey(), ByteBuffer.wrap(me.getValue().toByteArray())); } stack.putAll(pm); } catch(java.io.IOException e) { throw new RuntimeException(e); } }
Example 5
Source File: Matlab.java From LAML with Apache License 2.0 | 6 votes |
public static SparseVector sparse(Vector V) { if (V instanceof DenseVector) { double[] values = ((DenseVector) V).getPr(); TreeMap<Integer, Double> map = new TreeMap<Integer, Double>(); for (int k = 0; k < values.length; k++) { if (values[k] != 0) { map.put(k, values[k]); } } int nnz = map.size(); int[] ir = new int[nnz]; double[] pr = new double[nnz]; int dim = values.length; int ind = 0; for (Entry<Integer, Double> entry : map.entrySet()) { ir[ind] = entry.getKey(); pr[ind] = entry.getValue(); ind++; } return new SparseVector(ir, pr, nnz, dim); } else { return (SparseVector) V; } }
Example 6
Source File: AG_Border_Switch_Border_Color.java From incubator-weex-playground with Apache License 2.0 | 6 votes |
@Before public void setUp() throws InterruptedException { super.setUp(); TreeMap testMap = new <String, Object> TreeMap(); testMap.put("testComponet", "AG_Border"); testMap.put("testChildCaseInit", "AG_Border_Switch_Border_Color"); testMap.put("step1",new TreeMap(){ { put("click", "#FF0000"); put("screenshot", "AG_Border_Switch_Border_Color_01_#FF0000"); } }); testMap.put("step2",new TreeMap(){ { put("click", "#00FFFF"); put("screenshot", "AG_Border_Switch_Border_Color_02_#00FFFF"); } }); super.setTestMap(testMap); }
Example 7
Source File: AG_Margin_Text_Margin.java From incubator-weex-playground with Apache License 2.0 | 6 votes |
@Before public void setUp() throws InterruptedException { super.setUp(); TreeMap testMap = new <String, Object> TreeMap(); testMap.put("testComponet", "AG_Margin"); testMap.put("testChildCaseInit", "AG_Margin_Text_Margin"); testMap.put("step1",new TreeMap(){ { put("click", "10"); put("screenshot", "AG_Margin_Text_Margin_01_10"); } }); testMap.put("step2",new TreeMap(){ { put("click", "20"); put("screenshot", "AG_Margin_Text_Margin_02_20"); } }); super.setTestMap(testMap); }
Example 8
Source File: SingerStatus.java From singer with Apache License 2.0 | 6 votes |
@Override public String toString() { TreeMap<String, String> kvs = new TreeMap<>(); kvs.put(VERSION_KEY, this.version); kvs.put(HOSTNAME_KEY, this.hostName); kvs.put(JVM_UPTIME_KEY, Long.toString(this.jvmUptime)); kvs.put(TIMESTAMP_KEY, Long.toString(this.timestamp)); kvs.put(PROCESSOR_EXCEPTIONS_KEY, Long.toString(this.numExceptions)); kvs.put(NUM_LOG_STREAMS_KEY, Long.toString(this.numLogStreams)); kvs.put(NUM_STUCK_LOG_STREAMS_KEY, Long.toString(this.numStuckLogStreams)); Gson gson = new Gson(); kvs.put(KAFKA_WRITES_KEY, gson.toJson(this.kafkaWrites)); kvs.put(CURRENT_LATENCY_KEY, Double.toString(this.currentLatency)); kvs.put(LATENCY_KEY, gson.toJson(this.latency)); kvs.put(SKIPPED_BYTES_KEY, gson.toJson(this.skippedBytes)); String json = gson.toJson(kvs); return json; }
Example 9
Source File: ObservableList.java From pumpernickel with MIT License | 5 votes |
@Override void notifyListListener(ListListener<T> listener) { TreeMap<Integer, T> removedElements = new TreeMap<>(); removedElements.put(index, oldElement); listener.elementsRemoved(new RemoveElementsEvent<T>( ObservableList.this, removedElements)); }
Example 10
Source File: TzdbZoneRulesProvider.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override protected NavigableMap<String, ZoneRules> provideVersions(String zoneId) { TreeMap<String, ZoneRules> map = new TreeMap<>(); ZoneRules rules = getRules(zoneId, false); if (rules != null) { map.put(versionId, rules); } return map; }
Example 11
Source File: WhiteboardManager.java From openmeetings with Apache License 2.0 | 5 votes |
public Map<Long, List<BaseFileItem>> get(Room r, Long langId) { Map<Long, List<BaseFileItem>> result = new HashMap<>(); if (!contains(r.getId()) && r.getFiles() != null && !r.getFiles().isEmpty()) { if (map().tryLock(r.getId())) { try { TreeMap<Long, List<BaseFileItem>> files = new TreeMap<>(); for (RoomFile rf : r.getFiles()) { List<BaseFileItem> bfl = files.get(rf.getWbIdx()); if (bfl == null) { files.put(rf.getWbIdx(), new ArrayList<>()); bfl = files.get(rf.getWbIdx()); } bfl.add(rf.getFile()); } Whiteboards wbs = getOrCreate(r.getId(), null); for (Map.Entry<Long, List<BaseFileItem>> e : files.entrySet()) { Whiteboard wb = add(wbs, langId); wbs.setActiveWb(wb.getId()); result.put(wb.getId(), e.getValue()); } update(wbs); } finally { map().unlock(r.getId()); } } } return result; }
Example 12
Source File: AG_Input_Input_Event.java From incubator-weex-playground with Apache License 2.0 | 5 votes |
@Before public void setUp() throws InterruptedException { super.setUp(); TreeMap testMap = new <String, Object> TreeMap(); testMap.put("testComponet", "AG_Input"); testMap.put("testChildCaseInit", "AG_Input_Input_Event"); super.setTestMap(testMap); }
Example 13
Source File: ValidateProof.java From jelectrum with MIT License | 5 votes |
private TreeMap<String, String> getProof(String addr, Scanner in, PrintStream out) throws Exception { JSONObject request = new JSONObject(); request.put("id", "proof"); JSONArray arr = new JSONArray(); arr.put(addr); request.put("params", arr); request.put("method", "blockchain.address.get_proof"); out.println(request.toString()); String line = in.nextLine(); JSONObject reply = new JSONObject(line); JSONArray pa = reply.getJSONArray("result"); TreeMap<String, String> proof_map = new TreeMap<String, String>(); for(int i=0; i<pa.length(); i++) { JSONArray s = pa.getJSONArray(i); proof_map.put(s.getString(0), s.getString(1)); } return proof_map; }
Example 14
Source File: AG_CommonEvent_Input_Onclick.java From incubator-weex-playground with Apache License 2.0 | 5 votes |
@Before public void setUp() throws InterruptedException { super.setUp(); TreeMap testMap = new <String, Object> TreeMap(); testMap.put("testComponet", "AG_CommonEvent"); testMap.put("testChildCaseInit", "AG_CommonEvent_Input_Onclick"); super.setTestMap(testMap); }
Example 15
Source File: CFontManager.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override protected void addNativeFontFamilyNames(TreeMap<String, String> familyNames, Locale requestedLocale) { Font2D[] genericfonts = getGenericFonts(); for (int i=0; i < genericfonts.length; i++) { if (!(genericfonts[i] instanceof NativeFont)) { String name = genericfonts[i].getFamilyName(requestedLocale); familyNames.put(name.toLowerCase(requestedLocale), name); } } }
Example 16
Source File: MindmapOutputFactory.java From lams with GNU General Public License v2.0 | 5 votes |
public SortedMap<String, ToolOutput> getToolOutput(List<String> names, IMindmapService mindmapService, Long toolSessionId, Long learnerId) { TreeMap<String, ToolOutput> map = new TreeMap<String, ToolOutput>(); if (names == null || names.contains(OUTPUT_NAME_LEARNER_NUM_NODES)) { map.put(OUTPUT_NAME_LEARNER_NUM_NODES, getNumNodes(mindmapService, learnerId, toolSessionId)); } return map; }
Example 17
Source File: TzdbZoneRulesProvider.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected NavigableMap<String, ZoneRules> provideVersions(String zoneId) { TreeMap<String, ZoneRules> map = new TreeMap<>(); ZoneRules rules = getRules(zoneId, false); if (rules != null) { map.put(versionId, rules); } return map; }
Example 18
Source File: UsersTopic.java From twitch4j with MIT License | 4 votes |
private static TreeMap<String, Object> mapParameters(String userId) { TreeMap<String, Object> parameterMap = new TreeMap<>(); parameterMap.put("user_id", userId); return parameterMap; }
Example 19
Source File: Renderer.java From gpx-animator with Apache License 2.0 | 4 votes |
private void toTimePointMap(final TreeMap<Long, Point2D> timePointMap, final int trackIndex, final List<LatLon> latLonList) throws UserException { long forcedTime = 0; final TrackConfiguration trackConfiguration = cfg.getTrackConfigurationList().get(trackIndex); final Double minLon = cfg.getMinLon(); final Double maxLon = cfg.getMaxLon(); final Double minLat = cfg.getMinLat(); final Double maxLat = cfg.getMaxLat(); if (minLon != null) { minX = lonToX(minLon); } if (maxLon != null) { maxX = lonToX(maxLon); } if (maxLat != null) { minY = latToY(maxLat); } if (minLat != null) { maxY = latToY(minLat); } for (final LatLon latLon : latLonList) { final double x = lonToX(latLon.getLon()); final double y = latToY(latLon.getLat()); if (minLon == null) { minX = Math.min(x, minX); } if (maxLat == null) { minY = Math.min(y, minY); } if (maxLon == null) { maxX = Math.max(x, maxX); } if (minLat == null) { maxY = Math.max(y, maxY); } long time; final Long forcedPointInterval = trackConfiguration.getForcedPointInterval(); if (forcedPointInterval != null) { forcedTime += forcedPointInterval; time = forcedTime; } else { time = latLon.getTime(); if (time == Long.MIN_VALUE) { throw new UserException("missing time for point; specify --forced-point-time-interval option"); } } if (trackConfiguration.getTimeOffset() != null) { time += trackConfiguration.getTimeOffset(); } final Point2D point; if (latLon instanceof Waypoint) { final NamedPoint namedPoint = new NamedPoint(); namedPoint.setLocation(x, y); namedPoint.setName(((Waypoint) latLon).getName()); point = namedPoint; } else { point = new GpxPoint(x, y, latLon, time); } // hack to prevent overwriting existing (way)point with same time long freeTime = time; while (timePointMap.containsKey(freeTime)) { freeTime++; } timePointMap.put(freeTime, point); } }
Example 20
Source File: HadoopMetrics2ReporterTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Test public void testTimerReporting() { final String metricName = "my_timer"; final Timer timer = mock(Timer.class); final Snapshot snapshot = mock(Snapshot.class); TreeMap<String, Timer> timers = new TreeMap<>(); timers.put(metricName, timer); // Add the metrics objects to the internal "queues" by hand metrics2Reporter.setDropwizardTimers(timers); long count = 10L; double meanRate = 1.0; double oneMinRate = 2.0; double fiveMinRate = 5.0; double fifteenMinRate = 10.0; when(timer.getCount()).thenReturn(count); when(timer.getMeanRate()).thenReturn(meanRate); when(timer.getOneMinuteRate()).thenReturn(oneMinRate); when(timer.getFiveMinuteRate()).thenReturn(fiveMinRate); when(timer.getFifteenMinuteRate()).thenReturn(fifteenMinRate); when(timer.getSnapshot()).thenReturn(snapshot); double percentile75 = 75; double percentile95 = 95; double percentile98 = 98; double percentile99 = 99; double percentile999 = 999; double median = 50; double mean = 60; long min = 1L; long max = 100L; double stddev = 10; when(snapshot.get75thPercentile()).thenReturn(percentile75); when(snapshot.get95thPercentile()).thenReturn(percentile95); when(snapshot.get98thPercentile()).thenReturn(percentile98); when(snapshot.get99thPercentile()).thenReturn(percentile99); when(snapshot.get999thPercentile()).thenReturn(percentile999); when(snapshot.getMedian()).thenReturn(median); when(snapshot.getMean()).thenReturn(mean); when(snapshot.getMin()).thenReturn(min); when(snapshot.getMax()).thenReturn(max); when(snapshot.getStdDev()).thenReturn(stddev); MetricsCollector collector = mock(MetricsCollector.class); MetricsRecordBuilder recordBuilder = mock(MetricsRecordBuilder.class); Mockito.when(collector.addRecord(recordName)).thenReturn(recordBuilder); metrics2Reporter.getMetrics(collector, true); // We get the count from the meter and histogram verify(recordBuilder).addGauge(Interns.info(metricName + "_count", ""), count); // Verify the rates verify(recordBuilder).addGauge(Interns.info(metricName + "_mean_rate", ""), metrics2Reporter.convertRate(meanRate)); verify(recordBuilder).addGauge(Interns.info(metricName + "_1min_rate", ""), metrics2Reporter.convertRate(oneMinRate)); verify(recordBuilder).addGauge(Interns.info(metricName + "_5min_rate", ""), metrics2Reporter.convertRate(fiveMinRate)); verify(recordBuilder).addGauge(Interns.info(metricName + "_15min_rate", ""), metrics2Reporter.convertRate(fifteenMinRate)); // Verify the histogram verify(recordBuilder).addGauge(Interns.info(metricName + "_max", ""), metrics2Reporter.convertDuration(max)); verify(recordBuilder).addGauge(Interns.info(metricName + "_min", ""), metrics2Reporter.convertDuration(min)); verify(recordBuilder).addGauge(Interns.info(metricName + "_median", ""), metrics2Reporter.convertDuration(median)); verify(recordBuilder).addGauge(Interns.info(metricName + "_stddev", ""), metrics2Reporter.convertDuration(stddev)); verify(recordBuilder).addGauge(Interns.info(metricName + "_75thpercentile", ""), metrics2Reporter.convertDuration(percentile75)); verify(recordBuilder).addGauge(Interns.info(metricName + "_95thpercentile", ""), metrics2Reporter.convertDuration(percentile95)); verify(recordBuilder).addGauge(Interns.info(metricName + "_98thpercentile", ""), metrics2Reporter.convertDuration(percentile98)); verify(recordBuilder).addGauge(Interns.info(metricName + "_99thpercentile", ""), metrics2Reporter.convertDuration(percentile99)); verify(recordBuilder).addGauge(Interns.info(metricName + "_999thpercentile", ""), metrics2Reporter.convertDuration(percentile999)); verifyRecordBuilderUnits(recordBuilder); // Should not be the same instance we gave before. Our map should have gotten swapped out. assertTrue("Should not be the same map instance after collection", timers != metrics2Reporter.getDropwizardTimers()); }