List of usage examples for java.util TreeSet size
public int size()
From source file:reconcile.hbase.mapreduce.KeyListInputFormat.java
public static String[] getLocations(HConnection connection, String tableName, List<String> keys) throws IOException { TreeSet<String> hosts = new TreeSet<String>(); for (String key : keys) { HRegionLocation region = connection.getRegionLocation(tableName.getBytes(), key.getBytes(), true); String hostName = region.getServerAddress().getHostname(); LOG.debug("Key(" + key + ") found on host (" + hostName + ")"); hosts.add(hostName);/*from ww w .ja va 2s .c om*/ } return hosts.toArray(new String[hosts.size()]); }
From source file:org.yccheok.jstock.gui.OptionsNetworkJPanel.java
private static String[] getPriceSourceEntryValues(Country country) { Set<PriceSource> priceSources = org.yccheok.jstock.engine.Utils.getSupportedPriceSources(country); TreeSet<String> treeSet = new TreeSet<String>(); for (PriceSource priceSource : priceSources) { treeSet.add(priceSource.name()); }/*from w w w. j av a2 s . co m*/ return treeSet.toArray(new String[treeSet.size()]); }
From source file:de.minestar.minestarlibrary.utils.PlayerUtils.java
/** * @return Sorted Set of all player's nicknames who has ever conntected to * the server. The nicknames are all in lowercase! *///from www .j a v a 2s .co m public static String[] getAllPlayerNames() { TreeSet<String> playerNames = new TreeSet<String>(); OfflinePlayer[] players = Bukkit.getServer().getOfflinePlayers(); for (OfflinePlayer player : players) playerNames.add(player.getName().toLowerCase()); return playerNames.toArray(new String[playerNames.size()]); }
From source file:DecorateMutationsSNP.java
/** * The procedure creates a .txt file containing the information about the SNP mutations in the extant units * The first row represents the position of each mutation that is a double value in the interval (0,1) * The other rows represent the leave nodes as a matrix of 0 and 1 indicating the absence/presence of the corresponding mutation * @param wholePath path of the directory where the output file is stored * @param arg instance of the class PopulationARG that represents the ARG of a single population (in this case and actual population) * @see PopulationARG/* w w w . ja v a 2 s .co m*/ */ public static void createSNP_TxtFile(String wholePath, PopulationARG arg) { Writer writer = null; File file = new File("" + wholePath); try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf-8")); TreeSet<Double> posMutations = GenerateAdmixturePopulations.getAllMutations(); //System.out.println("Creating file SNPs for population "+arg.getId_pop()); //System.out.println("# of all mutations in all populations "+posMutations.size()); writer.write("Population " + arg.getId_pop() + "\n"); writer.write("Number of extant units (rows): " + arg.getExtantUnits() + "\n"); writer.write("Number of SNPs for each extant unit (columns): " + posMutations.size() + "\n\n"); Iterator<Double> it_posMuts = posMutations.iterator(); Double position; while (it_posMuts.hasNext()) { position = it_posMuts.next(); String troncato = String.format("%.4f", position); writer.write(troncato + " "); } writer.write("\n\n"); //For each leave print a row representing the absence or presence of SNP mutations for (int i = 0; i < arg.getExtantUnits(); i++) { it_posMuts = posMutations.iterator(); while (it_posMuts.hasNext()) { position = it_posMuts.next(); //check if the arg has the mutation if (arg.getMutationSet().containsKey(position)) { //if yes then check if the leaf has the mutation //Mutation mut = arg.getMutationSet().get(position); TreeSet<Double> muts_set = arg.getNodeSet().get(i).getMutation_set(); if (muts_set.contains(position)) writer.write("1 "); else writer.write("0 "); } else writer.write("0 "); } writer.write("\n"); } writer.close(); } //fine try catch (IOException ex) { // report } }
From source file:org.alfresco.web.forms.xforms.SchemaUtil.java
private static void buildTypeTree(final XSTypeDefinition type, final TreeSet<XSTypeDefinition> descendents, final TreeMap<String, TreeSet<XSTypeDefinition>> typeTree) { if (type == null) { return;/* ww w. j av a2s. c o m*/ } if (LOGGER.isDebugEnabled()) LOGGER.debug("buildTypeTree(" + type.getName() + ", " + descendents.size() + " descendents)"); if (descendents.size() > 0) { TreeSet<XSTypeDefinition> compatibleTypes = typeTree.get(type.getName()); if (compatibleTypes == null) { if (LOGGER.isDebugEnabled()) LOGGER.debug("no compatible types found for " + type.getName() + ", creating a new set"); compatibleTypes = new TreeSet<XSTypeDefinition>(TYPE_EXTENSION_SORTER); typeTree.put(type.getName(), compatibleTypes); } if (LOGGER.isDebugEnabled()) LOGGER.debug("adding " + descendents.size() + " descendents to " + type.getName()); compatibleTypes.addAll(descendents); } final XSTypeDefinition parentType = type.getBaseType(); if (parentType == null || type.getTypeCategory() != parentType.getTypeCategory()) { return; } if (type != parentType && parentType.getName() != null && !parentType.getName().equals("anyType")) { TreeSet<XSTypeDefinition> newDescendents = typeTree.get(parentType.getName()); if (newDescendents == null) { if (LOGGER.isDebugEnabled()) LOGGER.debug("type tree doesn't contain " + parentType.getName() + ", creating a new descendant set"); newDescendents = new TreeSet<XSTypeDefinition>(TYPE_EXTENSION_SORTER); } if (LOGGER.isDebugEnabled()) LOGGER.debug("adding " + descendents.size() + " descendants to existing " + newDescendents.size() + " descendants of " + parentType.getName()); newDescendents.addAll(descendents); //extension (we only add it to "newDescendants" because we don't want //to have a type descendant to itself, but to consider it for the parent if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { final XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) type; if (complexType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION && !complexType.getAbstract() && !descendents.contains(type)) { if (LOGGER.isDebugEnabled()) LOGGER.debug("adding " + type.getName() + " to existing " + newDescendents.size() + " descendents of " + parentType.getName()); newDescendents.add(type); } } //note: extensions are impossible on simpleTypes ! SchemaUtil.buildTypeTree(parentType, newDescendents, typeTree); } }
From source file:com.hoho.android.usbserial.examples.SerialConsoleActivity.java
static void parseGesture() { int len = gestureRaw.size(); if (len >= stopSize) { boolean check = true; int finalState = gestureRaw.get(len - 1); for (int i = 0; i < stopSize; i++) { if (gestureRaw.get(len - 1 - i) != finalState) { check = false;// www. j a v a 2 s . c o m break; } } if (check) { gestureParse.clear(); int c1 = 1, pstate = gestureRaw.get(0); if (pstate != 0) gestureParse.add(pstate); for (Integer state : gestureRaw) { if (c1 == 1 && state == pstate) continue; else { if (state != 0) gestureParse.add(state); pstate = state; c1 = 0; } } gestureRaw.clear(); while (gestureParse.size() >= 2 && gestureParse.get(gestureParse.size() - 1) == gestureParse.get(gestureParse.size() - 2)) { gestureParse.remove(gestureParse.size() - 1); } TreeSet<Integer> size = new TreeSet<Integer>(); for (Integer integer : gestureParse) { size.add(integer); } if (gestureParse.size() >= gestureSize && size.size() > 2) { System.err.println(gestureParse); gestureToWrite.clear(); int length = gestureParse.size(); // gestureToWrite size is always numberOfGuestureInputs int filled = 0; for (int i = 1; i <= length; i++) { int upto = (numberOfGuestureInputs - 1) * i / length; for (; filled <= upto; filled++) { gestureToWrite.add(gestureParse.get(i - 1)); } } if (recognize) { g = svmg.getPrediction(gestureToWrite); gestureF = g + 1; updateGesture = true; System.out.println("gesture: " + g); } } } } }
From source file:org.dasein.cloud.util.APITrace.java
static public String[] listProviders() { TreeSet<String> providers = new TreeSet<String>(); synchronized (apiCount) { for (String call : apiCount.keySet()) { String[] parts = call.split(DELIMITER_REGEX); if (parts.length > 0) { providers.add(parts[0]); }/*from w w w. j av a 2 s. c o m*/ } } return providers.toArray(new String[providers.size()]); }
From source file:org.dasein.cloud.util.APITrace.java
static public String[] listClouds(@Nonnull String provider) { provider = provider.replaceAll(DELIMITER_REGEX, "_"); TreeSet<String> list = new TreeSet<String>(); synchronized (apiCount) { for (String call : apiCount.keySet()) { String[] parts = call.split(DELIMITER_REGEX); if (parts.length > 1 && parts[0].equals(provider)) { list.add(parts[1]);//from ww w . j a v a 2 s .c o m } } } return list.toArray(new String[list.size()]); }
From source file:edu.lternet.pasta.portal.search.AuthorSearch.java
/** * Parses the Solr query results using regular expression matching (as * opposed to XML parsing)// w ww .j a v a 2s.c o m * * @param xml the Solr query results, an XML document string * @param fieldName the field name to parse out of the XML, e.g. "author" * @return a String array of field values parsed from the XML */ private static String[] parseQueryResults(String xml, String fieldName) { String[] values = null; final String patternStr = String.format("^\\s*<%s>(.+)</%s>\\s*$", fieldName, fieldName); Pattern pattern = Pattern.compile(patternStr); TreeSet<String> valueSet = new TreeSet<String>(); if (xml != null) { String[] lines = xml.split("\n"); for (String line : lines) { Matcher matcher = pattern.matcher(line); if (matcher.matches()) { String capturedValue = matcher.group(1).trim(); String unescapedXML = StringEscapeUtils.unescapeXml(capturedValue); String trimmedXML = unescapedXML.replace("\r", " ").replace("\n", " ").replaceAll("\\s+", " ") .trim(); String escapedXML = StringEscapeUtils.escapeXml(trimmedXML); valueSet.add(escapedXML); } } values = valueSet.toArray(new String[valueSet.size()]); } return values; }
From source file:Business.PDU.java
public static byte[] respostaRanking(TreeSet<ParUsernamePontos> treeSet) { String username = new String(); for (ParUsernamePontos pup : treeSet) username = username + pup.getUsername() + '\0' + pup.getPontos() + '\0'; byte[] formato = formataPDU(); byte[] str = username.getBytes(); short tamanhoCampos = (short) (str.length); formato[4] = 0;//from w w w. ja v a2 s . c om formato[5] = (byte) (treeSet.size() * 2); formato[6] = (byte) (tamanhoCampos & 0xff); formato[7] = (byte) ((tamanhoCampos >> 8) & 0xff); return formato; }