예제 #1
0
  public String updateModifiedOnlySql(ValueObject obj, String[] fields) throws SQLException {

    if ((obj instanceof PT_KICA_ERR_LOGEntity) == false) {
      throw new SQLException("DAO 에러(1): PT_KICA_ERR_LOG : updateModifiedOnly() ");
    }
    PT_KICA_ERR_LOGEntity entity = (PT_KICA_ERR_LOGEntity) obj;

    HashMap clobs = new HashMap();

    if (fields == null) throw new SQLException("Field Name can not be Null");

    StringBuffer setString = new StringBuffer();
    boolean flag = false;
    for (int i = 0; i < fields.length; i++) {
      if (fields[i] == null) throw new SQLException("Field Name can not be Null");
      if (default_update_field.containsKey(fields[i]) == false) {
        if (flag) setString.append(",");
        flag = true;
        if (clobs.containsKey(fields[i])) {
          setString.append(fields[i]).append("=?");
        } else {
          setString.append(fields[i]).append("=").append(toDB(entity.getByName(fields[i])));
        }
      }
    }
    if (flag = false) throw new SQLException("Nothing to update");

    StringBuffer sb = new StringBuffer();
    sb.append("update PT_KICA_ERR_LOG  set ").append(setString.toString()).append(" where  1=1 ");

    sb.append(" and SEQ = ").append(toDB(entity.getSEQ()));

    return sb.toString();
  }
예제 #2
0
 public static void main(String[] args) throws IOException {
   BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
   String[] temp = in.readLine().split(" ");
   int n = Integer.parseInt(temp[0]);
   int s = Integer.parseInt(temp[1]);
   HashMap<Integer, Integer> buy = new HashMap<>();
   HashMap<Integer, Integer> sell = new HashMap<>();
   for (int i = 1; i <= n; i++) {
     temp = in.readLine().split(" ");
     int p = Integer.parseInt(temp[1]);
     int q = Integer.parseInt(temp[2]);
     if (temp[0].charAt(0) == 'B') {
       if (buy.containsKey(p)) buy.put(p, buy.get(p) + q);
       else buy.put(p, q);
     } else {
       if (sell.containsKey(p)) sell.put(p, sell.get(p) + q);
       else sell.put(p, q);
     }
   }
   ArrayList<Integer> buyArr = new ArrayList<>();
   ArrayList<Integer> sellArr = new ArrayList<>();
   for (Integer i : buy.keySet()) buyArr.add(i);
   for (Integer i : sell.keySet()) sellArr.add(i);
   Collections.sort(buyArr, Comparator.reverseOrder());
   Collections.sort(sellArr);
   for (int i = Math.min(s, sellArr.size()) - 1; i >= 0; i--)
     System.out.println("S " + sellArr.get(i) + " " + sell.get(sellArr.get(i)));
   for (int i = 0; i < s && i < buyArr.size(); i++)
     System.out.println("B " + buyArr.get(i) + " " + buy.get(buyArr.get(i)));
 }
예제 #3
0
 public boolean hasRestoration(Player player) {
   UUID uuid = player.getUniqueId();
   if (multipleInventories()) {
     return RESTORATIONS.containsKey(uuid + "." + getWorldGroups(player));
   }
   return RESTORATIONS.containsKey(uuid.toString());
 }
    @Override
    public void reduce(Text key, Iterable<HMapStIW> values, Context context)
        throws IOException, InterruptedException {
      Iterator<HMapStIW> iter = values.iterator();
      HMapStIW map = new HMapStIW();

      while (iter.hasNext()) {
        map.plus(iter.next());
      }

      HMapStFW writeMap = new HMapStFW();

      double pmi = 0.0;
      for (MapKI.Entry<String> entry : map.entrySet()) {
        String k = entry.getKey();

        if (map.get(k) >= 10) {
          if (wordCounts.containsKey(key.toString()) && wordCounts.containsKey(k)) {
            int px = wordCounts.get(key.toString());
            int py = wordCounts.get(k);
            pmi = Math.log10(((double) (map.get(k)) / (px * py)) * wordCounts.get("numLines*"));
            writeMap.put(k, (float) pmi);
          }
        }
      }
      if (writeMap.size() > 0) {
        context.write(key, writeMap);
      }
    }
  public final String correct(String word) {
    if (nWords.containsKey(word)) return word;
    ArrayList<String> list = edits(word);
    HashMap<Integer, String> candidates = new HashMap<Integer, String>();
    for (String s : list) if (nWords.containsKey(s)) candidates.put(nWords.get(s), s);

    if (candidates.size() > 0) return candidates.get(Collections.max(candidates.keySet()));
    return candidates.size() > 0 ? candidates.get(Collections.max(candidates.keySet())) : word;
  }
예제 #6
0
 public static void main(String[] args) throws IOException {
   BufferedReader in = new BufferedReader(new FileReader("milk2.in"));
   PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("milk2.out")));
   int num = Integer.parseInt(in.readLine());
   HashMap<Integer, Integer> times = new HashMap<Integer, Integer>(num * 2);
   int startTime = 1000000, endTime = 0;
   // ArrayList<Integer> duplicates = new ArrayList<Integer>();
   for (int i = 0; i < num; i++) {
     StringTokenizer line = new StringTokenizer(in.readLine());
     int s = Integer.parseInt(line.nextToken());
     if (times.containsKey(s)) times.put(s, times.get(s) + 1);
     else times.put(s, 1);
     if (s < startTime) startTime = s;
     int e = Integer.parseInt(line.nextToken());
     if (times.containsKey(e)) times.put(e, times.get(e) - 1);
     else times.put(e, -1);
     if (e > endTime) endTime = e;
   }
   in.close();
   /*for (int i = 0; i < duplicates.size(); i++)
   times.remove(duplicates.get(i));*/
   // System.out.println(startTime + " " + endTime);
   int starts = 0, ends = 0, milkTime = 0, idleTime = 0, maxMilkTime = 0, maxIdleTime = 0;
   for (int t = startTime; t < endTime; t++) {
     if (times.containsKey(t)) {
       if (times.get(t) > 0) {
         starts += times.get(t);
       }
       if (times.get(t) < 0) {
         ends -= times.get(t);
       }
       // System.out.println(t + " " + times.get(t));
     }
     if (starts > ends) {
       milkTime++;
       if (milkTime > maxMilkTime) maxMilkTime = milkTime;
       if (idleTime != 0) idleTime = 0;
     } else {
       idleTime++;
       if (idleTime > maxIdleTime) maxIdleTime = idleTime;
       if (milkTime != 0) milkTime = 0;
     }
   }
   // System.out.println(starts + " " + ends);
   out.println(maxMilkTime + " " + maxIdleTime);
   out.close();
   System.exit(0);
 }
예제 #7
0
파일: Genes.java 프로젝트: dgaston/FGB
 public static Element gene_Info(Document doc, String symbol) {
   Element genes = doc.createElement(Consts.XML_TAG_GENES);
   doc.getElementsByTagName(Consts.DATA_ROOT).item(0).appendChild(genes);
   if (SymbolMap.containsKey(symbol)) {
     int index = SymbolMap.get(symbol);
     Element gene = doc.createElement(Consts.XML_TAG_GENE);
     gene.setAttribute(Consts.XML_TAG_ID, Symbols[index]);
     genes.appendChild(gene);
     XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_CHROMOSOME, ChrList[Chrs[index]]);
     XmlWriter.append_text_element(
         doc, gene, Consts.XML_TAG_FROM, Integer.toString(Starts[index] + 1));
     XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_TO, Integer.toString(Ends[index]));
     if (!RefSeqs[index].equals(""))
       XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_REFSEQ, RefSeqs[index]);
     if (!UCSCs[index].equals(""))
       XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_UCSC, UCSCs[index]);
     if (!Ensembls[index].equals(""))
       XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_ENSEMBL, Ensembls[index]);
     if (!Entrezs[index].equals(""))
       XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_ENTREZ, Entrezs[index]);
     XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_HGNC, HGNCs[index]);
     XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_NAME, Names[index]);
   }
   return genes;
 }
예제 #8
0
파일: Genes.java 프로젝트: dgaston/FGB
 public static Element overlap_Genes(
     Document doc, String chr, int start, int end, IndividualStat is) {
   Element genes = doc.createElement(Consts.XML_TAG_GENES);
   doc.getElementsByTagName(Consts.DATA_ROOT).item(0).appendChild(genes);
   if (ChrMap.containsKey(chr)) {
     int[] range = binarySearchOverlap(ChrMap.get(chr), start, end);
     if (range != null) {
       float[] scores = null;
       if (is != null) scores = is.get_GeneScores(range[1], range[0]);
       for (int i = range[0]; i <= range[1]; i++) {
         Element gene = doc.createElement(Consts.XML_TAG_GENE);
         gene.setAttribute(Consts.XML_TAG_ID, Symbols[i]);
         XmlWriter.append_text_element(
             doc, gene, Consts.XML_TAG_FROM, Integer.toString(Starts[i] + 1));
         XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_TO, Integer.toString(Ends[i]));
         if (is != null)
           XmlWriter.append_text_element(
               doc,
               gene,
               Consts.XML_TAG_SCORE,
               Float.toString(Math.round(scores[i - range[0]] * 10) / 10));
         genes.appendChild(gene);
       }
     }
   }
   return genes;
 }
예제 #9
0
파일: ToolBox.java 프로젝트: asw12/zoogas
 /**
  * Process key presses. If the toolbox contains a SprayTool associated with this key, the
  * SprayTool is used.
  *
  * @param c
  * @return true if the ToolBox fired a SprayTool
  */
 public boolean hotKeyPressed(char c) {
   if (toolKeys.containsKey(c)) {
     currentTool = toolKeys.get(c);
     return true;
   }
   return false;
 }
  public static void countPairs(Integer[] arr) {

    HashMap<Integer, Integer> seenElements = new HashMap<Integer, Integer>();

    // ArrayList<Integer> countList = new ArrayList<Integer

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

      if (!seenElements.containsKey(arr[i])) {
        seenElements.put(arr[i], 1);
      } else {

        seenElements.put(arr[i], seenElements.get(arr[i]) + 1);
      }
    }

    BigInteger count = null;
    for (int element : seenElements.keySet()) {
      if (seenElements.get(element) > 1) {
        System.out.println("count is :" + seenElements.get(element));
        count.add(
            factorial(seenElements.get(element)).divide(factorial(seenElements.get(element) - 2)));
        System.out.println(count);
      }
    }

    if (count == null) {
      System.out.println("0");
    }
  }
  private void write(List<String> words, String documentsName) throws DictionaryException {

    for (int i = 0; i < words.size(); i++) {
      HashMap<String, Integer> hashMap = new HashMap<String, Integer>();

      if (dictionary.containsKey(words.get(i))) {
        hashMap = dictionary.get(words.get(i));
        int countWords;

        if (hashMap.containsKey(documentsName)) {
          countWords = hashMap.get(documentsName);
          countWords += 1;
          hashMap.remove(documentsName);
          hashMap.put(documentsName, countWords);
        } else {
          hashMap.put(documentsName, 1);
        }
        dictionary.remove(words.get(i));
        dictionary.put(words.get(i), hashMap);
      } else {
        hashMap.put(documentsName, 1);
        dictionary.put(words.get(i), hashMap);
      }
    }
    writeToFile();
  }
예제 #12
0
    public String hasSameContent(JarFile2 file, JarEntry entry) throws IOException {

      String thisName = null;

      Long crcL = new Long(entry.getCrc());

      // check if this jar contains files with the passed in entry's crc
      if (_crcToEntryMap.containsKey(crcL)) {
        // get the Linked List with files with the crc
        LinkedList ll = (LinkedList) _crcToEntryMap.get(crcL);
        // go through the list and check for content match
        ListIterator li = ll.listIterator(0);
        if (li != null) {
          while (li.hasNext()) {
            JarEntry thisEntry = (JarEntry) li.next();

            // check for content match
            InputStream oldIS = getJarFile().getInputStream(thisEntry);
            InputStream newIS = file.getJarFile().getInputStream(entry);

            if (!differs(oldIS, newIS)) {
              thisName = thisEntry.getName();
              return thisName;
            }
          }
        }
      }

      return thisName;
    }
  public static ArrayList<ArrayList<TaggedWord>> getPhrasesNaive(
      String sentence, LexicalizedParser lp, AbstractSequenceClassifier<CoreLabel> classifier) {
    ArrayList<ArrayList<TaggedWord>> newList = new ArrayList<ArrayList<TaggedWord>>();
    ArrayList<TaggedWord> taggedWords = StanfordNER.parse(sentence, lp, classifier);
    HashMap<String, String> phraseBoundaries = new HashMap<String, String>();
    phraseBoundaries.put(",", ",");
    phraseBoundaries.put("\"", "\"");
    phraseBoundaries.put("''", "''");
    phraseBoundaries.put("``", "``");
    phraseBoundaries.put("--", "--");
    // List<Tree> leaves = parse.getLeaves();
    ArrayList<TaggedWord> temp = new ArrayList<TaggedWord>();
    int index = 0;
    while (index < taggedWords.size()) {
      if ((phraseBoundaries.containsKey(taggedWords.get(index).word()))) {
        if (temp.size() > 0) {
          // System.out.println(temp);
          ArrayList<TaggedWord> tempCopy = new ArrayList<TaggedWord>(temp);
          newList.add(Preprocess(tempCopy));
        }
        temp.clear();
      } else {
        // System.out.println(taggedWords.get(index).toString());
        temp.add(taggedWords.get(index));
      }
      index += 1;
    }
    if (temp.size() > 0) {
      ArrayList<TaggedWord> tempCopy = new ArrayList<TaggedWord>(temp);
      newList.add(Preprocess(tempCopy));
    }

    // System.out.println(newList);
    return newList;
  }
  public static ArrayList<TaggedWord> StopWordRemoval(ArrayList<TaggedWord> taggedWords) {
    ArrayList<TaggedWord> newList = new ArrayList<TaggedWord>();

    try {
      String path = "data/nltk_stoplist.txt";
      File textFile = new File(path);
      BufferedReader br = new BufferedReader(new FileReader(textFile));
      String stopwordsLine = br.readLine();
      br.close();

      String[] stopwords = stopwordsLine.split(",");
      HashMap<String, String> stopwordsDict = new HashMap<String, String>();
      for (int i = 0; i < stopwords.length; i++) {
        stopwordsDict.put(stopwords[i], stopwords[i]);
      }

      for (int i = 0; i < taggedWords.size(); i++) {
        String word = taggedWords.get(i).word();
        String posTag = taggedWords.get(i).tag();

        if (!stopwordsDict.containsKey(word.toLowerCase())) {
          String newWord, newPosTag;
          newWord = word;
          newPosTag = posTag;
          newList.add(new TaggedWord(newWord, newPosTag));
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return newList;
  }
예제 #15
0
 public static void main(String[] args) throws IOException {
   BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
   int[] marbles;
   HashMap<Integer, Integer> positions;
   int n, m;
   StringTokenizer r;
   int cases = 1;
   StringBuilder output = new StringBuilder();
   while (true) {
     r = new StringTokenizer(in.readLine());
     n = Integer.parseInt(r.nextToken());
     m = Integer.parseInt(r.nextToken());
     if (n == 0 && m == 0) break;
     marbles = new int[n];
     positions = new HashMap<Integer, Integer>();
     for (int i = 0; i < n; i++) marbles[i] = Integer.parseInt(in.readLine());
     Arrays.sort(marbles);
     for (int i = n - 1; i >= 0; i--) positions.put(marbles[i], i + 1);
     output.append("CASE# ").append(cases++).append(":").append("\n");
     for (int i = 0; i < m; i++) {
       n = Integer.parseInt(in.readLine());
       if (positions.containsKey(n))
         output.append(n).append(" found at ").append(positions.get(n)).append("\n");
       else output.append(n).append(" not found").append("\n");
     }
   }
   System.out.print(output);
   in.close();
   System.exit(0);
 }
예제 #16
0
  private static void convertToInlinkMap(
      HashMap<String, Set<String>> outlinkmapping, HashMap<String, JSONArray> inlinkmapping)
      throws Exception, FileNotFoundException {
    Iterator<String> keys = outlinkmapping.keySet().iterator();
    System.out.println("outlink map count " + outlinkmapping.size());
    while (keys.hasNext()) {
      String key = (String) keys.next();
      Set<String> s = outlinkmapping.get(key);
      ArrayList<String> a = new ArrayList<String>(s);
      // System.out.println("Started for "+count++ + + outlinkmapping.size() +a.size());

      for (int i = 0; i < a.size(); i++) {
        String inlink = a.get(i);
        if (outlinkmapping.containsKey(inlink)) {
          Object inlinks =
              inlinkmapping.containsKey(inlink) ? inlinkmapping.get(inlink) : new JSONArray();
          ((JSONArray) inlinks).add(key);
          inlinkmapping.put(inlink, (JSONArray) inlinks);
        }
      }
      // System.out.println("Endded for "+count++  + "  " + outlinkmapping.size() +"  "+a.size());
    }
    System.out.println("inlink map count " + inlinkmapping.size());

    System.out.println("Done");
  }
예제 #17
0
  /**
   * Construct the <code>BufferedImage</code> from the given file. The file can be given as an URL,
   * or a reference to local image file. If this image has been loaded already, use the saved
   * version.
   *
   * @param filename the file name for the desired image
   */
  public ImageMaker(String filename) {
    /** now we set up the image file for the user to process */
    try {
      this.inputfile = new File(filename);
      String abs = inputfile.getCanonicalPath();
      if (loadedImages.containsKey(abs)) {
        this.image = loadedImages.get(abs);
        this.width = this.image.getWidth();
        this.height = this.image.getHeight();
      } else {
        this.imageSource = ImageIO.read(this.inputfile);
        this.width = this.imageSource.getWidth();
        this.height = this.imageSource.getHeight();

        this.cmodel = this.imageSource.getColorModel();
        this.image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB);
        this.colorOp =
            new ColorConvertOp(
                this.cmodel.getColorSpace(), image.getColorModel().getColorSpace(), null);
        this.colorOp.filter(this.imageSource, this.image);
        loadedImages.put(abs, this.image);
      }
    } catch (IOException e) {
      System.out.println("Could not open the file");
    }
  }
예제 #18
0
 // keyboard discovery code
 private void _mapKey(char charCode, int keyindex, boolean shift, boolean altgraph) {
   log("_mapKey: " + charCode);
   // if character is not in map, add it
   if (!charMap.containsKey(new Integer(charCode))) {
     log("Notified: " + (char) charCode);
     KeyEvent event =
         new KeyEvent(
             applet(),
             0,
             0,
             (shift ? KeyEvent.SHIFT_MASK : 0) + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0),
             ((Integer) vkKeys.get(keyindex)).intValue(),
             (char) charCode);
     charMap.put(new Integer(charCode), event);
     log("Mapped char " + (char) charCode + " to KeyEvent " + event);
     if (((char) charCode) >= 'a' && ((char) charCode) <= 'z') {
       // put shifted version of a-z in automatically
       int uppercharCode = (int) Character.toUpperCase((char) charCode);
       event =
           new KeyEvent(
               applet(),
               0,
               0,
               KeyEvent.SHIFT_MASK + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0),
               ((Integer) vkKeys.get(keyindex)).intValue(),
               (char) uppercharCode);
       charMap.put(new Integer(uppercharCode), event);
       log("Mapped char " + (char) uppercharCode + " to KeyEvent " + event);
     }
   }
 }
예제 #19
0
파일: Pcc.java 프로젝트: topiaf/Graph
 // methodes covoiturage
 // renvoie le cout vers un chemin en particulier a partir de la hashmap
 public double cout_vers(Sommet S) {
   if (maplabel.containsKey(S)) {
     return maplabel.get(S).getCout();
   } else {
     return Double.MAX_VALUE;
   }
 }
예제 #20
0
  /**
   * Marshalls the mgf file object to a file. If the file already exists it will be overwritten.
   *
   * @param file The file to marshall the mgf file to.
   */
  public void marshallToFile(File file) throws JMzReaderException {
    try {
      // create the object to write the file
      BufferedWriter writer = new BufferedWriter(new FileWriter(file));

      // process all additional parameters
      String parameters = marshallAdditionalParameters();

      // write the parameters
      writer.write(parameters);

      // process the pmf spectra
      for (PmfQuery q : pmfQueries) writer.write(q.toString() + "\n");

      writer.write("\n");

      // write the spectra
      for (Integer index = 0; index < 1000000; index++) {
        if (!ms2Queries.containsKey(index)) continue;

        writer.write(ms2Queries.get(index).toString() + "\n");
      }

      writer.close();

    } catch (IOException e) {
      throw new JMzReaderException("Failed to write output file", e);
    }
  }
예제 #21
0
파일: UDP.java 프로젝트: NZDIS/jgroups
 void handleConfigEvent(HashMap map) {
   if (map == null) {
     return;
   }
   if (map.containsKey("additional_data")) {
     additional_data = (byte[]) map.get("additional_data");
   }
   if (map.containsKey("send_buf_size")) {
     mcast_send_buf_size = ((Integer) map.get("send_buf_size")).intValue();
     ucast_send_buf_size = mcast_send_buf_size;
   }
   if (map.containsKey("recv_buf_size")) {
     mcast_recv_buf_size = ((Integer) map.get("recv_buf_size")).intValue();
     ucast_recv_buf_size = mcast_recv_buf_size;
   }
   setBufferSizes();
 }
예제 #22
0
 public Monster getMonsterById(String id) {
   if (monsters.containsKey(id)) {
     Monster monster = monsters.get(id);
     return monster;
   } else {
     return null;
   }
 }
 static void pf(int n) {
   int c = 0;
   for (int i = 2; i * i <= n; i++)
     if ((n % i == 0)) {
       c = 0;
       while ((n % i == 0)) {
         c++;
         n /= i;
       }
       if (hm.containsKey(i)) hm.put(i, Math.max((int) hm.get(i), c));
       else hm.put(i, c);
     }
   if (n > 1) {
     if (hm.containsKey(n)) hm.put(n, Math.max((int) hm.get(n), 1));
     else hm.put(n, 1);
   }
 }
 public void add(Transferable t) {
   DataFlavor[] f = t.getTransferDataFlavors();
   for (int i = 0; i < f.length; i++) {
     if (!transferables.containsKey(f[i])) {
       flavors.add(f[i]);
     }
     transferables.put(f[i], t);
   }
 }
예제 #25
0
 @Override
 public void notify(
     String filename, String event, FileWatcher.Watch watch, boolean isDir) {
   String path = watch.fspec.startsWith("web/") ? watch.fspec.substring(4) : watch.fspec;
   if (templates.containsKey(path)) {
     templates.put(path, compile(getInputStream(path)));
     LOGGER.info("Recompiling template: {}", path);
   }
 }
예제 #26
0
 /**
  * Obtient le socket enregistré correspondant à l'addresse IP donnée.
  *
  * @return le socket correspondant à l'IP source donnée s'il a été enregistré null sinon.
  */
 public Socket popSocket(InetAddress addr) {
   String addrname = toId(addr);
   if (acceptedSockets.containsKey(addrname)) {
     Socket sock = acceptedSockets.get(addrname);
     acceptedSockets.remove(addrname);
     return sock;
   }
   return null;
 }
예제 #27
0
  public List getSuccsOf(Object s) {

    if (!unitToSuccs.containsKey(s)) {
      return new ArrayList();
      //			throw new RuntimeException("Invalid stmt:" + s);
    }

    return unitToSuccs.get(s);
  }
 public ArrayList getPointList(long handId) {
   ArrayList curList;
   if (_pointLists.containsKey(handId)) curList = (ArrayList) _pointLists.get(handId);
   else {
     curList = new ArrayList(_maxPoints);
     _pointLists.put(handId, curList);
   }
   return curList;
 }
예제 #29
0
 // Returns the correct person for a given name and gender from the HashMap storing all popularity
 // rank data
 public Person getPerson(String name, String gender) {
   String nameGender = "";
   nameGender += name;
   nameGender += gender;
   if (persons.containsKey(nameGender)) {
     return persons.get(nameGender);
   } else {
     return null;
   }
 }
예제 #30
0
 public void processMonsterUpdateUDP(UDPMonster up) {
   if (up != null) {
     if (monsters.containsKey(up.id)) {
       Monster monster = monsters.get(up.id);
       if (monster != null) {
         monster.processUpdate(up);
       }
     }
   }
 }