List of usage examples for java.util TreeMap TreeMap
public TreeMap()
From source file:com.titankingdoms.dev.titanchat.command.CommandManager.java
public CommandManager() { this.plugin = TitanChat.getInstance(); if (getCommandDirectory().mkdirs()) plugin.log(Level.INFO, "Creating commands directory..."); this.commands = new TreeMap<String, Command>(); this.labels = new HashMap<String, Command>(); }
From source file:com.mothsoft.alexis.engine.numeric.CorrelationCalculatorImpl.java
@Override public double[][] correlate(List<DataSet> dataSets, Timestamp startDate, Timestamp endDate, TimeUnits granularity) {//from w w w .ja va 2 s . com if (dataSets == null || dataSets.size() < 2) { throw new IllegalArgumentException("At least 2 data sets are required for correlation"); } final Map<Long, List<Double>> orderedPoints = new TreeMap<Long, List<Double>>(); for (int i = 0; i < dataSets.size(); i++) { final DataSet dataSet = dataSets.get(i); final List<DataSetPoint> points = this.dao.findAndAggregatePointsGroupedByUnit(dataSet, startDate, endDate, granularity); for (final DataSetPoint point : points) { final Long millis = point.getX().getTime(); if (!orderedPoints.containsKey(millis)) { orderedPoints.put(millis, newDoubleList(dataSets.size())); } orderedPoints.get(millis).set(i, point.getY()); } } if (orderedPoints.size() <= 1) { throw new IllegalArgumentException("Needed at least 2 points, found: " + orderedPoints.size()); } final double[][] points = new double[orderedPoints.size()][dataSets.size()]; int i = 0; for (final Map.Entry<Long, List<Double>> entry : orderedPoints.entrySet()) { final List<Double> values = entry.getValue(); for (int j = 0; j < values.size(); j++) { points[i][j] = values.get(j); } i++; } final PearsonsCorrelation correlation = new PearsonsCorrelation(); final RealMatrix matrix = correlation.computeCorrelationMatrix(points); return matrix.getData(); }
From source file:com.joliciel.csvLearner.features.NormalisationLimitReader.java
public Map<String, Float> read() { Map<String, Float> featureToMaxMap = new TreeMap<String, Float>(); try {// w w w . j a v a2 s . c o m if (inputStream != null) { this.readCSVFile(inputStream, featureToMaxMap); } else if (file.isDirectory()) { Stack<File> directoryStack = new Stack<File>(); directoryStack.add(file); while (!directoryStack.isEmpty()) { File directory = directoryStack.pop(); LOG.debug("Scanning directory: " + directory.getName()); File[] files = directory.listFiles(); if (files == null) { continue; } for (File oneFile : files) { if (oneFile.isDirectory()) { directoryStack.push(oneFile); } else if (oneFile.getName().endsWith(".nrm_limits.csv")) { LOG.debug("Scanning limits file : " + oneFile.getName()); this.readCSVFile(new FileInputStream(oneFile), featureToMaxMap); } else { LOG.trace("Ignoring : " + oneFile.getName()); } } } } else { LOG.debug("Scanning limits file : " + file.getName()); this.readCSVFile(new FileInputStream(file), featureToMaxMap); } } catch (FileNotFoundException e) { throw new RuntimeException(e); } return featureToMaxMap; }
From source file:edu.umd.cfar.lamp.viper.util.Range.java
/** * Creates a new, empty Range. */ public Range() { spans = new TreeMap(); }
From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java
private static void infoRefs(Repository db) { Map<String, Ref> refs = db.getAllRefs(); System.out.printf("%nAll Refs (%d)%n", refs.size()); Ref head = refs.get(Constants.HEAD); if (head == null) { System.out.println(" HEAD ref is dead and/or non-existent?"); return;//ww w .ja v a 2 s.c om } Map<String, Ref> printRefs = new TreeMap<String, Ref>(); String current = head.getLeaf().getName(); if (current.equals(Constants.HEAD)) { printRefs.put("(no branch)", head); } for (Ref ref : RefComparator.sort(refs.values())) { String name = ref.getName(); if (name.startsWith(Constants.R_HEADS) || name.startsWith(Constants.R_REMOTES)) { printRefs.put(name, ref); } } int maxLength = 0; for (String name : printRefs.keySet()) { maxLength = Math.max(maxLength, name.length()); } System.out.printf("Refs (Heads/Remotes) (%d)%n", printRefs.size()); for (Entry<String, Ref> e : printRefs.entrySet()) { Ref ref = e.getValue(); ObjectId objectId = ref.getObjectId(); System.out.printf("%c %-" + maxLength + "s %s%n", (current.equals(ref.getName()) ? '*' : ' '), e.getKey(), objectId.abbreviate(ABBREV_LEN).name()); } }
From source file:com.jaeksoft.searchlib.analysis.ClassFactory.java
public ClassFactory() { config = null;/*from ww w.ja va2s .c om*/ properties = new TreeMap<ClassPropertyEnum, ClassProperty>(); userProperties = null; addProperty(ClassPropertyEnum.CLASS, null, null, 0, 0); packageName = null; }
From source file:com.aurel.track.fieldType.fieldChange.converter.CompositeSelectSetterConverter.java
/** * Convert the string to object value after load * @param value//from w w w .ja va 2 s . co m * @param setter * @return */ @Override public Object getActualValueFromStoredString(String value, Integer setter) { if (value == null || setter == null) { return null; } switch (setter.intValue()) { case FieldChangeSetters.SET_TO: SortedMap<Integer, Integer[]> actualValuesMap = new TreeMap<Integer, Integer[]>(); String[] partStringArr = value.split(PART_SPLITTER_STRING); if (partStringArr != null && partStringArr.length > 0) { for (int i = 0; i < partStringArr.length; i++) { String partString = partStringArr[i]; if (partString != null && !"".equals(partString)) { try { Integer partValue = Integer.valueOf(partString); actualValuesMap.put(Integer.valueOf(i + 1), new Integer[] { partValue }); } catch (Exception e) { LOGGER.warn("Converting the " + i + 1 + "th part " + partString + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } } return actualValuesMap; } return null; }
From source file:com.servioticy.dispatcher.jsonprocessors.JsonPathReplacer.java
public JsonPathReplacer(String str, ObjectMapper mapper, Set<String> excludedDocIds) { this.mapper = mapper; this.jsonPaths = new TreeMap<Integer, LinkedList<Map.Entry<String, JsonPath>>>(); this.str = str; // compile JsonPaths on the String for (int firstIndex = 0; firstIndex < this.str.length();) { firstIndex = this.str.indexOf("{", firstIndex); if (firstIndex == -1) { break; }/*from ww w . ja v a2 s. c o m*/ if ((firstIndex != 0) && (this.str.charAt(firstIndex - 1) == '\\')) { firstIndex++; continue; } int lastIndex; for (lastIndex = firstIndex; lastIndex < this.str.length(); lastIndex++) { lastIndex = this.str.indexOf("}", lastIndex); if (lastIndex == -1) { break; } // Ignore if escaped. if (this.str.charAt(lastIndex - 1) == '\\') { lastIndex++; continue; } break; } if (lastIndex == -1) { break; } String jsonPath = this.str.substring(firstIndex + 1, lastIndex); String jsonId = ""; // Check that right after the '{' char there is the '$' character (may be spaces in between). Then get // the substring between the '$' and the '.' and use it as JSON id. int iDollar = jsonPath.indexOf("$"); int endJsonId = jsonPath.indexOf('.', iDollar); endJsonId = endJsonId != -1 ? endJsonId : jsonPath.length(); if (iDollar == -1) { firstIndex = lastIndex; continue; } // // Exclude jsonIds // // if(excludedDocIds.contains(jsonId)){ // firstIndex++; // continue; // } // Change the index of the JsonPaths already existing in positions further than firstIndex. // Also, if any of those JsonPaths are before lastIndex, ignore it. // int indexOffset = (lastIndex-1) - (firstIndex+1); // boolean recJsonPath = false; // If there is a jsonId, extract it from the jsonPath and make the jsonPath 'standard' if (iDollar + 1 != endJsonId) { jsonId = jsonPath.substring(iDollar + 1, endJsonId); jsonPath = deleteSubstring(jsonPath, iDollar + 1, endJsonId); } // Escape \\{ and \\} unescapeChar(jsonPath, '{'); unescapeChar(jsonPath, '}'); JsonPath jp; try { jp = JsonPath.compile(jsonPath); } catch (java.lang.IllegalArgumentException e) { // If the detected JsonPath is invalid for any reason, simply ignore it. firstIndex++; continue; } // // jpstr.jsonPaths is ordered by key. // for(Entry<Integer, LinkedList<Entry<String, JsonPath>>> currentJpList : this.jsonPaths.entrySet()){ // if(currentJpList.getKey() > firstIndex){ // if(currentJpList.getKey() <= lastIndex){ // recJsonPath = true; // break; // } // int newIndex = currentJpList.getKey() - indexOffset; // if(this.jsonPaths.get(newIndex) != null){ // this.jsonPaths.get(newIndex).addAll(currentJpList.getValue()); // } // else{ // this.jsonPaths.put(newIndex, currentJpList.getValue()); // } // this.jsonPaths.remove(currentJpList.getKey()); // } // } // if(recJsonPath){ // firstIndex++; // continue; // } LinkedList<Entry<String, JsonPath>> jplist = new LinkedList<Entry<String, JsonPath>>(); jplist.add(new AbstractMap.SimpleEntry<String, JsonPath>(jsonId, jp)); if (this.jsonPaths.get(firstIndex) != null) { this.jsonPaths.get(firstIndex).addAll(jplist); } else { this.jsonPaths.put(firstIndex, jplist); } this.str = deleteSubstring(this.str, firstIndex, lastIndex + 1); } // Escape \\{ and \\} unescapeChar(this.str, '{'); unescapeChar(this.str, '}'); }
From source file:main.java.org.ros.sensorfilters.UltrasonicSensorFilter.java
@Override public void main(NodeConfiguration configuration) { Preconditions.checkState(node == null); Preconditions.checkNotNull(configuration); node = new DefaultNodeFactory().newNode("sensor_listener", configuration); prevFilteredRange = new TreeMap<String, Range>(); this.setup("ultrasonic_topics"); }
From source file:com.azaptree.services.spring.application.SpringApplicationService.java
private static void logDebugSystemProperties(final Logger log) { Assert.notNull(log);/*from ww w . j a va2 s . c o m*/ if (log.isDebugEnabled()) { final TreeMap<String, String> sysProps = new TreeMap<>(); for (final Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { sysProps.put(entry.getKey().toString(), entry.getValue().toString()); } final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final PrintStream ps = new PrintStream(bos); for (final Map.Entry<String, String> entry : sysProps.entrySet()) { ps.print(entry.getKey()); ps.print('='); ps.println(entry.getValue()); } log.debug("System Properties:\n{}", bos); } }