コード例 #1
1
  /** {@inheritDoc} */
  protected void getNewMonitors(Map<String, Monitor> map) throws MonitorException {
    assert Thread.holdsLock(this);

    int used = prologue.getUsed();
    long modificationTime = prologue.getModificationTimeStamp();

    if ((used > lastUsed) || (lastModificationTime > modificationTime)) {

      lastUsed = used;
      lastModificationTime = modificationTime;

      Monitor monitor = getNextMonitorEntry();
      while (monitor != null) {
        String name = monitor.getName();

        // guard against duplicate entries
        if (!map.containsKey(name)) {
          map.put(name, monitor);

          /*
           * insertedMonitors is null when called from pollFor()
           * via buildMonitorMap(). Since we update insertedMonitors
           * at the end of buildMonitorMap(), it's ok to skip the
           * add here.
           */
          if (insertedMonitors != null) {
            insertedMonitors.add(monitor);
          }
        }
        monitor = getNextMonitorEntry();
      }
    }
  }
コード例 #2
1
ファイル: TDTEngine.java プロジェクト: max90727/fosstrak
  /**
   * If the outbound level is BINARY, convert the string field to binary, then pad to the left with
   * the appropriate number of zero bits to reach a number of bits specified by the bitLength
   * attribute of the TDT definition file.
   */
  private void binaryPadding(Map<String, String> extraparams, Field tdtfield) {
    String fieldname = tdtfield.getName();
    int reqbitlength = tdtfield.getBitLength();
    String value;

    String binaryValue = fieldToBinary(tdtfield, extraparams);
    if (binaryValue.length() < reqbitlength) {
      int extraBitLength = reqbitlength - binaryValue.length();

      StringBuilder zeroPaddedBinaryValue = new StringBuilder("");
      for (int i = 0; i < extraBitLength; i++) {
        zeroPaddedBinaryValue.append("0");
      }
      zeroPaddedBinaryValue.append(binaryValue);
      value = zeroPaddedBinaryValue.toString();
    } else {
      if (binaryValue.length() > reqbitlength)
        throw new TDTException(
            "Binary value ["
                + binaryValue
                + "] for field "
                + fieldname
                + " exceeds maximum allowed "
                + reqbitlength
                + " bits.  Decimal value was "
                + extraparams.get(fieldname));

      value = binaryValue;
    }
    extraparams.put(fieldname, value);
  }
コード例 #3
0
  public List getUserListAT() {

    List<Map> list = new ArrayList<Map>();

    String[][] data = {
      {"3537255778", "Alex Chen"},
      {"2110989338", "Brian Wang"},
      {"3537640807", "David Hsieh"},
      {"5764816553", "James Yu"},
      {"3756404948", "K.C."},
      {"2110994764", "Neil Weinstock"},
      {"6797798390", "Owen Chen"},
      {"3831206627", "Randy Chen"},
      {"6312460903", "Tony Shen"},
      {"2110993498", "Yee Liaw"}
    };

    for (int i = 0; i < data.length; i++) {

      Map map = new HashMap();

      String userRef = data[i][0];
      String userName = data[i][1];

      map.put("userObjectId", userRef);
      map.put("userName", userName);

      list.add(map);
    }

    return list;
  }
コード例 #4
0
  public void processMethodMapping(
      String className,
      int firstLineNumber,
      int lastLineNumber,
      String methodReturnType,
      String methodName,
      String methodArguments,
      String newMethodName) {
    // Original class name -> obfuscated method names.
    Map methodMap = (Map) classMethodMap.get(className);
    if (methodMap == null) {
      methodMap = new HashMap();
      classMethodMap.put(className, methodMap);
    }

    // Obfuscated method name -> methods.
    Set methodSet = (Set) methodMap.get(newMethodName);
    if (methodSet == null) {
      methodSet = new LinkedHashSet();
      methodMap.put(newMethodName, methodSet);
    }

    // Add the method information.
    methodSet.add(
        new MethodInfo(
            firstLineNumber, lastLineNumber, methodReturnType, methodArguments, methodName));
  }
コード例 #5
0
  // Store the invariant for later printing. Ignore duplicate
  // invariants at the same program point.
  private static boolean store_invariant(
      String predicate, String index, HashedConsequent consequent, String pptname) {
    if (!pptname_to_conditions.containsKey(pptname)) {
      pptname_to_conditions.put(pptname, new HashMap<String, Map<String, HashedConsequent>>());
    }

    Map<String, Map<String, HashedConsequent>> cluster_to_conditions =
        pptname_to_conditions.get(pptname);
    if (!cluster_to_conditions.containsKey(predicate)) {
      cluster_to_conditions.put(predicate, new HashMap<String, HashedConsequent>());
    }

    Map<String, HashedConsequent> conditions = cluster_to_conditions.get(predicate);
    if (conditions.containsKey(index)) {
      HashedConsequent old = conditions.get(index);
      if (old.fakeFor != null && consequent.fakeFor == null) {
        // We already saw (say) "x != y", but we're "x == y", so replace it.
        conditions.remove(index);
        conditions.remove(old.fakeFor);
        conditions.put(index, consequent);
        return true;
      }
      return false;
    } else {
      conditions.put(index, consequent);
      return true;
    }
  }
コード例 #6
0
 private void mergeDiseaseFreeData(
     Map<String, DiseaseFreeData> sourceMap, Map<String, DiseaseFreeData> destMap) {
   for (String patientId : sourceMap.keySet()) {
     DiseaseFreeData diseaseFreeData = sourceMap.get(patientId);
     if (destMap.containsKey(patientId)) {
       destMap.put(patientId, mergeDiseaseFreeData(destMap.get(patientId), diseaseFreeData));
     } else {
       destMap.put(patientId, diseaseFreeData);
     }
   }
 }
コード例 #7
0
 private void mergeSurvivalData(
     Map<String, SurvivalData> sourceMap, Map<String, SurvivalData> destMap) {
   for (String patientId : sourceMap.keySet()) {
     SurvivalData survivalData = sourceMap.get(patientId);
     if (destMap.containsKey(patientId)) {
       destMap.put(patientId, mergeSurvivalData(destMap.get(patientId), survivalData));
     } else {
       destMap.put(patientId, survivalData);
     }
   }
 }
コード例 #8
0
  public List getUserList() {
    List<Map> list = new ArrayList<Map>();

    try {

      /*
      String apiUrl=rallyApiHost+"/user?query="+
      	"((TeamMemberships%20%3D%20https%3A%2F%2Frally1.rallydev.com%2Fslm%2Fwebservice%2F1.34%2Fproject%2F6169133135)%20or%20"+
      	"(TeamMemberships%20%3D%20https%3A%2F%2Frally1.rallydev.com%2Fslm%2Fwebservice%2F1.34%2Fproject%2F6083311244))"+
      	"&fetch=true&order=Name&start=1&pagesize=100";
      */

      String apiUrl =
          rallyApiHost
              + "/user?query=(Disabled%20=%20false)"
              + "&fetch=true&order=Name&start=1&pagesize=100";

      log.info("apiUrl=" + apiUrl);

      String responseXML = getRallyXML(apiUrl);

      org.jdom.input.SAXBuilder bSAX = new org.jdom.input.SAXBuilder();
      org.jdom.Document doc = bSAX.build(new StringReader(responseXML));
      Element root = doc.getRootElement();

      XPath xpath = XPath.newInstance("//Object");
      List xlist = xpath.selectNodes(root);

      Iterator iter = xlist.iterator();
      while (iter.hasNext()) {

        Map map = new HashMap();

        Element item = (Element) iter.next();

        String userRef = item.getAttribute("ref").getValue();
        String userName = item.getAttribute("refObjectName").getValue();
        String userObjectId = item.getChildText("ObjectID");

        map.put("userRef", userRef);
        map.put("userObjectId", userObjectId);
        map.put("userName", userName);

        list.add(map);
      }

    } catch (Exception ex) {
      log.error("", ex);
    }

    return list;
  }
コード例 #9
0
ファイル: QueryService.java プロジェクト: GerritBoers/exist
 private org.exist.source.Source buildQuerySource(String query, Object[] params, String cookie) {
   Map<String, String> combinedMap = namespaceBindings.getCombinedMap();
   for (Map.Entry<String, Document> entry : moduleMap.entrySet()) {
     combinedMap.put("<module> " + entry.getKey(), entry.getValue().path());
   }
   for (Map.Entry<QName, Object> entry : bindings.entrySet()) {
     combinedMap.put(
         "<var> " + entry.getKey(),
         null); // don't care about values, as long as the same vars are bound
   }
   combinedMap.put("<posvars> " + params.length, null);
   combinedMap.put("<cookie>", cookie);
   // TODO: should include statically known documents and baseURI too?
   return new StringSourceWithMapKey(query, combinedMap);
 }
コード例 #10
0
  private int parse() throws IOException {
    String line;
    BufferedReader reader = new BufferedReader(new FileReader(inputFile));
    int count = 0;

    line = reader.readLine(); // Quality Scores;
    String[] array = line.split("\t");
    qualityScores = new Integer[array.length - offset];
    for (int i = offset; i < array.length; i++) {
      qualityScores[i - offset] = Integer.parseInt(array[i]);
    }

    line = reader.readLine(); // Experiment Names
    array = line.split("\t");
    experiments = new String[array.length - offset];
    for (int i = offset; i < array.length; i++) {
      experiments[i - offset] = array[i];
      exptIndices.put(array[i], i - offset);
    }

    // Reads the rest of the table.
    while ((line = reader.readLine()) != null) {
      array = line.split("\t");
      String id = array[0]; // first column is the ID
      if (array.length != experiments.length + offset) {
        System.err.println(
            String.format(
                "Line %s has length %d != %d", id, array.length, experiments.length + offset));
      } else {
        // we're going to skip the second column (an index value), and
        // put the rest of the values in the array.  Any parsing exceptions
        // indicate missing (NULL) values.
        Float[] values = new Float[experiments.length];
        for (int i = 0; i < experiments.length; i++) {
          try {
            values[i] = Float.parseFloat(array[i + offset]);
            count += 1;
          } catch (NumberFormatException nfe) {
            values[i] = null;
          }
        }
        table.put(id, values);
      }
    }

    reader.close();
    return count;
  }
コード例 #11
0
ファイル: ChatUI.java プロジェクト: Trojanz/Custom-Salem
 protected RichText.Part text(PState s, String text, Map<? extends Attribute, ?> attrs)
     throws IOException {
   RichText.Part ret = null;
   int p = 0;
   while (true) {
     Matcher m = urlpat.matcher(text);
     if (!m.find(p)) break;
     URL url;
     try {
       String su = text.substring(m.start(), m.end());
       if (su.indexOf(':') < 0) su = "http://" + su;
       url = new URL(su);
     } catch (java.net.MalformedURLException e) {
       p = m.end();
       continue;
     }
     RichText.Part lead = new RichText.TextPart(text.substring(0, m.start()), attrs);
     if (ret == null) ret = lead;
     else ret.append(lead);
     Map<Attribute, Object> na = new HashMap<Attribute, Object>(attrs);
     na.putAll(urlstyle);
     na.put(ChatAttribute.HYPERLINK, new FuckMeGentlyWithAChainsaw(url));
     ret.append(new RichText.TextPart(text.substring(m.start(), m.end()), na));
     p = m.end();
   }
   if (ret == null) ret = new RichText.TextPart(text, attrs);
   else ret.append(new RichText.TextPart(text.substring(p), attrs));
   return (ret);
 }
コード例 #12
0
ファイル: PCNode.java プロジェクト: shahidminhas/abc
 PCNode insertFullName(String full_name, boolean cl, boolean weavable) {
   int dotpos = full_name.indexOf('.');
   String head;
   String rest;
   if (dotpos == -1) {
     head = full_name;
     rest = null;
   } else {
     head = full_name.substring(0, dotpos);
     rest = full_name.substring(dotpos + 1);
   }
   PCNode child;
   if (!inners.containsKey(head)) {
     child = new PCNode(head, this, root);
     inners.put(head, child);
   } else {
     child = (PCNode) inners.get(head);
   }
   if (rest != null) {
     return child.insertFullName(rest, cl, weavable);
   } else {
     child.is_class |= cl;
     child.is_weavable |= weavable;
     return child;
   }
 }
コード例 #13
0
  /**
   * Reads the file that specifies method calls that should be replaced by other method calls. The
   * file is of the form:
   *
   * <p>[regex] [orig-method-def] [new-method-name]
   *
   * <p>where the orig_method-def is of the form:
   *
   * <p>fully-qualified-method-name (args)
   *
   * <p>Blank lines and // comments are ignored. The orig-method-def is replaced by a call to
   * new-method-name with the same arguments in any classfile that matches the regular expressions.
   * All method names and argument types should be fully qualified.
   */
  public void read_map_file(File map_file) throws IOException {

    LineNumberReader lr = new LineNumberReader(new FileReader(map_file));
    MapFileError mfe = new MapFileError(lr, map_file);
    Pattern current_regex = null;
    Map<MethodDef, MethodInfo> map = new LinkedHashMap<MethodDef, MethodInfo>();
    for (String line = lr.readLine(); line != null; line = lr.readLine()) {
      line = line.replaceFirst("//.*$", "");
      if (line.trim().length() == 0) continue;
      if (line.startsWith(" ")) {
        if (current_regex == null)
          throw new IOException("No current class regex on line " + lr.getLineNumber());
        StrTok st = new StrTok(line, mfe);
        st.stok.wordChars('.', '.');
        MethodDef md = parse_method(st);
        String new_method = st.need_word();
        map.put(md, new MethodInfo(new_method));
      } else {
        if (current_regex != null) {
          MethodMapInfo mmi = new MethodMapInfo(current_regex, map);
          map_list.add(mmi);
          map = new LinkedHashMap<MethodDef, MethodInfo>();
        }
        current_regex = Pattern.compile(line);
      }
    }
    if (current_regex != null) {
      MethodMapInfo mmi = new MethodMapInfo(current_regex, map);
      map_list.add(mmi);
    }

    dump_map_list();
  }
コード例 #14
0
ファイル: QueryService.java プロジェクト: GerritBoers/exist
 /**
  * Import an XQuery library module from the given document. The namespace and preferred prefix of
  * the module are extracted from the module itself. The MIME type of the document is set to
  * "application/xquery" as a side-effect.
  *
  * @param module the non-XML document that holds the library module's source
  * @return this service, to chain calls
  * @throws DatabaseException if the module is an XML document, or the module declaration cannot be
  *     found at the top of the document
  */
 public QueryService importModule(Document module) {
   if (module instanceof XMLDocument)
     throw new DatabaseException("module cannot be an XML document: " + module);
   Matcher matcher = MODULE_DECLARATION_DQUOTE.matcher(module.contentsAsString());
   if (!matcher.find()) {
     matcher = MODULE_DECLARATION_SQUOTE.matcher(module.contentsAsString());
     if (!matcher.find())
       throw new DatabaseException("couldn't find a module declaration at the top of " + module);
   }
   module.metadata().setMimeType("application/xquery");
   String moduleNamespace = matcher.group(1);
   // TODO: should do URILiteral processing here to replace entity and character references and
   // normalize
   // whitespace, but since it seems that eXist doesn't do it either (bug?) there's no reason to
   // rush.
   Document prevModule = moduleMap.get(moduleNamespace);
   if (prevModule != null && !prevModule.equals(module))
     throw new DatabaseException(
         "module "
             + moduleNamespace
             + " already bound to "
             + prevModule
             + ", can't rebind to "
             + module);
   moduleMap.put(moduleNamespace, module);
   return this;
 }
コード例 #15
0
  protected Map<String, String> getAttributes() {
    if (attributes != null) {
      return attributes;
    }

    attributes = new HashMap<String, String>();

    matcher = ADDITIONAL_ATTRIBUTES_PATTERN.matcher(firstLine);
    if (matcher.find()) {
      String s;
      Matcher attributeMatcher;

      s = matcher.group(2);
      attributeMatcher = ADDITIONAL_ATTRIBUTE_PATTERN.matcher(s);
      while (attributeMatcher.find()) {
        String key;
        String value;

        key = attributeMatcher.group(1);
        value = attributeMatcher.group(2);
        attributes.put(key.toLowerCase(Locale.ENGLISH), value);
      }
    }
    return attributes;
  }
コード例 #16
0
ファイル: FileDescLoader.java プロジェクト: Unknow0/sync
  /** @return matching bloc B bloc -> A bloc */
  public static Map<Integer, Integer> diff(FileDesc a, FileDesc b) {
    Map<Integer, List<IndexedHash>> blocA = new HashMap<Integer, List<IndexedHash>>();
    int i = 0;
    for (Bloc bloc : a.blocs) {
      List<IndexedHash> l = blocA.get(bloc.roll);
      if (l == null) {
        l = new ArrayList<IndexedHash>();
        blocA.put(bloc.roll, l);
      }
      l.add(new IndexedHash(i++, bloc.hash));
    }

    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
    loop:
    for (i = 0; i < b.blocs.length; i++) {
      Bloc blocB = b.blocs[i];
      List<IndexedHash> list = blocA.get(blocB.roll);
      if (list != null) {
        for (IndexedHash bloc : list) {
          if (blocB.hash.equals(bloc.h)) {
            map.put(i, bloc.i);
            continue loop;
          }
        }
      }
    }
    return map;
  }
コード例 #17
0
  /**
   * This is called when JPM runs in the background to start jobs
   *
   * @throws Exception
   */
  public void daemon() throws Exception {
    Runtime.getRuntime()
        .addShutdownHook(
            new Thread("Daemon shutdown") {
              public void run() {

                for (Service service : startedByDaemon) {
                  try {
                    reporter.error("Stopping " + service);
                    service.stop();
                    reporter.error("Stopped " + service);
                  } catch (Exception e) {
                    // Ignore
                  }
                }
              }
            });
    List<ServiceData> services = getServices();
    Map<String, ServiceData> map = new HashMap<String, ServiceData>();
    for (ServiceData d : services) {
      map.put(d.name, d);
    }
    List<ServiceData> start = new ArrayList<ServiceData>();
    Set<ServiceData> set = new HashSet<ServiceData>();
    for (ServiceData sd : services) {
      checkStartup(map, start, sd, set);
    }

    if (start.isEmpty()) reporter.warning("No services to start");

    for (ServiceData sd : start) {
      try {
        Service service = getService(sd.name);
        reporter.trace("Starting " + service);
        String result = service.start();
        if (result != null) reporter.error("Started error " + result);
        else startedByDaemon.add(service);
        reporter.trace("Started " + service);
      } catch (Exception e) {
        reporter.error("Cannot start daemon %s, due to %s", sd.name, e);
      }
    }

    while (true) {
      for (Service sd : startedByDaemon) {
        try {
          if (!sd.isRunning()) {
            reporter.error("Starting due to failure " + sd);
            String result = sd.start();
            if (result != null) reporter.error("Started error " + result);
          }
        } catch (Exception e) {
          reporter.error("Cannot start daemon %s, due to %s", sd, e);
        }
      }
      Thread.sleep(10000);
    }
  }
コード例 #18
0
  public Map<String, Revision> latest(Collection<Revision> list) {
    Map<String, Revision> programs = new HashMap<String, Library.Revision>();

    for (Revision r : list) {
      String coordinates = r.groupId + ":" + r.artifactId;
      if (r.classifier != null) coordinates += ":" + r.classifier;

      if (r.groupId.equals(Library.SHA_GROUP)) continue;

      Revision current = programs.get(coordinates);
      if (current == null) programs.put(coordinates, r);
      else {
        // who is better?
        if (compare(r, current) >= 0) programs.put(coordinates, r);
      }
    }
    return programs;
  }
コード例 #19
0
 public Map<String, String> getFormatSpecifierDescriptions() {
   Map<String, String> m = new LinkedHashMap<String, String>();
   Iterator<String> keys = scoreBoardValues.keySet().iterator();
   while (keys.hasNext()) {
     String k = keys.next();
     m.put(k, scoreBoardValues.get(k).getDescription());
   }
   return m;
 }
コード例 #20
0
ファイル: MetatypeTest.java プロジェクト: vikchilu/bnd
 public static void testConfigurableForNonPrimitives() {
   Map<String, String> p = new HashMap<String, String>();
   C config = Configurable.createConfigurable(C.class, p);
   assertNull(config.port());
   p.put("port", "10");
   config = Configurable.createConfigurable(C.class, p);
   assertEquals(Integer.valueOf(10), config.port()); // property port is
   // not set
 }
コード例 #21
0
  public void processFieldMapping(
      String className, String fieldType, String fieldName, String newFieldName) {
    // Original class name -> obfuscated field names.
    Map fieldMap = (Map) classFieldMap.get(className);
    if (fieldMap == null) {
      fieldMap = new HashMap();
      classFieldMap.put(className, fieldMap);
    }

    // Obfuscated field name -> fields.
    Set fieldSet = (Set) fieldMap.get(newFieldName);
    if (fieldSet == null) {
      fieldSet = new LinkedHashSet();
      fieldMap.put(newFieldName, fieldSet);
    }

    // Add the field information.
    fieldSet.add(new FieldInfo(fieldType, fieldName));
  }
コード例 #22
0
  static int lonelyInteger(int[] arr) {
    Map<Integer, Integer> occurrences = new HashMap<>();
    for (int value : arr) {
      boolean alreadyExist = occurrences.containsKey(value);
      if (!alreadyExist) {
        occurrences.put(value, 0);
      }
      occurrences.put(value, occurrences.get(value) + 1);
    }

    int result = 0;

    for (java.util.Map.Entry<Integer, Integer> entry : occurrences.entrySet()) {
      if (entry.getValue().equals(1)) {
        result = entry.getKey();
      }
    }

    return result;
  }
コード例 #23
0
ファイル: RestXqFunction.java プロジェクト: jolau/basex-api
 /**
  * Adds parameters from the passed on request body.
  *
  * @param body request body
  * @param params map parameters
  */
 private static void addParams(final String body, final Map<String, String[]> params) {
   for (final String nv : body.split("&")) {
     final String[] parts = nv.split("=", 2);
     if (parts.length < 2) continue;
     try {
       params.put(parts[0], new String[] {URLDecoder.decode(parts[1], Token.UTF8)});
     } catch (final Exception ex) {
       Util.notexpected(ex);
     }
   }
 }
コード例 #24
0
  public List getProjectList() {
    List<Map> list = new ArrayList<Map>();

    try {

      String apiUrl = rallyApiHost + "/project?" + "fetch=true&order=Name&start=1&pagesize=200";

      log.info("rallyApiUrl:" + apiUrl);

      String responseXML = getRallyXML(apiUrl);

      org.jdom.input.SAXBuilder bSAX = new org.jdom.input.SAXBuilder();
      org.jdom.Document doc = bSAX.build(new StringReader(responseXML));
      Element root = doc.getRootElement();

      XPath xpath = XPath.newInstance("//Object");
      List xlist = xpath.selectNodes(root);

      Iterator iter = xlist.iterator();
      while (iter.hasNext()) {

        Map map = new HashMap();

        Element item = (Element) iter.next();
        String objId = item.getChildText("ObjectID");
        String name = item.getChildText("Name");
        String state = item.getChildText("State");

        map.put("objId", objId);
        map.put("name", name);
        map.put("state", state);

        list.add(map);
      }

    } catch (Exception ex) {
      log.error("ERROR: ", ex);
    }

    return list;
  }
コード例 #25
0
ファイル: StartNamedBlock.java プロジェクト: mpobrien/templ8
 public CompilerCommand processCompileNodes(
     Node node, Node appendTo, Stack<Node> nodeStack, Map<String, StartNamedBlock> blocks) {
   // TODO check for duplicate key?
   blocks.put(this.blockName, this);
   if (getExecuteNode() == null) {
     nodeStack.push(this);
     setExecuteNode(node);
     return new CompilerCommand(node, node, false);
   } else {
     setNextNode(node);
     return new CompilerCommand(node, node, false);
   }
 }
コード例 #26
0
  public static void main(String[] args) {
    long start = System.currentTimeMillis();
    Scanner input = new Scanner(System.in);
    int numberOfTestCases = input.nextInt();
    ArrayList<Integer> order = new ArrayList<Integer>(numberOfTestCases);
    int previousKey = -1;
    int previousValue = 0;
    int cycleNumber = 0;

    Map<Integer, Integer> testCases = new TreeMap<Integer, Integer>();

    for (int i = 0; i < numberOfTestCases; i++) {
      int numberOfCycles = input.nextInt();
      testCases.put(numberOfCycles, 1);
      order.add(numberOfCycles);
    }

    for (Map.Entry<Integer, Integer> entry : testCases.entrySet()) {
      int numberOfCycles;
      int initialHeight;

      if (previousKey == -1) {
        numberOfCycles = entry.getKey();
        initialHeight = entry.getValue();
      } else {
        numberOfCycles = entry.getKey() - previousKey;
        initialHeight = previousValue;
      }

      for (int i = 0; i < numberOfCycles; i++) {
        if (cycleNumber % 2 == 0) {
          initialHeight *= 2;
        } else {
          initialHeight += 1;
        }
        cycleNumber++;
      }

      entry.setValue(initialHeight);
      previousKey = entry.getKey();
      previousValue = initialHeight;
    }

    for (Integer element : order) {
      System.out.println(testCases.get(element));
    }

    long elapsed = System.currentTimeMillis() - start;
    System.out.println("time: " + elapsed);
  }
コード例 #27
0
  private Map<String, DiseaseFreeData> getDiseaseFreeDataForMatrix(DataMatrix dataMatrix) {
    Map<String, DiseaseFreeData> diseaseFreeDataMap = new HashMap<String, DiseaseFreeData>();

    List<String> patientIds = getPatientIds(dataMatrix);
    for (int lc = 0; lc < patientIds.size(); lc++) {
      String patientId = patientIds.get(lc);
      DiseaseFreeData df = getDiseaseFreeDataForPatient(lc, dataMatrix);
      if (diseaseFreeDataMap.containsKey(patientId)) {
        df = mergeDiseaseFreeData(diseaseFreeDataMap.get(patientId), df);
      }
      diseaseFreeDataMap.put(patientId, df);
    }

    return diseaseFreeDataMap;
  }
コード例 #28
0
 /**
  * Adds the sequence with name <tt>name</tt> and sequence <tt>gas</tt> to the alignment.
  *
  * @param name The name of the sequence to be added
  * @param gas The sequence as a <tt>GappedAlignmentString</tt>
  * @see GappedAlignmentString
  */
 public void addGappedAlignment(String name, GappedAlignmentString gas) {
   if (ordering.isEmpty()) {
     gappedLength = gas.gappedLength();
   } else {
     if (gas.gappedLength() != gappedLength) {
       throw new IllegalArgumentException(
           String.format("Gapped Length %d doesn't match.", gas.gappedLength()));
     }
     if (ordering.contains(name)) {
       throw new IllegalArgumentException(String.format("Duplicate name: %s", name));
     }
   }
   ordering.add(name);
   gappedAlignments.put(name, gas);
 }
コード例 #29
0
  private Map<String, SurvivalData> getSurvivalDataForMatrix(DataMatrix dataMatrix) {
    Map<String, SurvivalData> survivalDataMap = new HashMap<String, SurvivalData>();

    List<String> patientIds = getPatientIds(dataMatrix);
    for (int lc = 0; lc < patientIds.size(); lc++) {
      String patientId = patientIds.get(lc);
      SurvivalData sd = getSurvivalDataForPatient(lc, dataMatrix);
      if (survivalDataMap.containsKey(patientId)) {
        sd = mergeSurvivalData(survivalDataMap.get(patientId), sd);
      }
      survivalDataMap.put(patientId, sd);
    }

    return survivalDataMap;
  }
コード例 #30
0
  /**
   * @param data
   * @param target
   * @throws Exception
   * @throws IOException
   */
  public String createCommand(CommandData data, boolean force) throws Exception, IOException {

    // TODO
    // if (Data.validate(data) != null)
    // return "Invalid command data: " + Data.validate(data);

    Map<String, String> map = null;
    if (data.trace) {
      map = new HashMap<String, String>();
      map.put("java.security.manager", "aQute.jpm.service.TraceSecurityManager");
      reporter.trace("tracing");
    }
    String s = platform.createCommand(data, map, force, service.getAbsolutePath());
    if (s == null) storeData(new File(commandDir, data.name), data);
    return s;
  }