コード例 #1
0
  public void flipLayoutLeftRight() {
    LayoutBox box = getExactLayoutBox();
    Iterator<NodeLayout> ne = nodes.iterator();
    while (ne.hasNext()) {
      NodeLayout nl = ne.next();
      if (nl.processID.equals("null")) {
        nl.x =
            box.topleft.x
                + (box.width - (nl.x - box.topleft.x))
                - 60; // minus 60 which is the width of process node's box, since using upperleft
                      // coor
      } else if (isSecondary(nl)) {
        nl.x = box.topleft.x + (box.width - (nl.x - box.topleft.x)) - 60;
      } else {
        nl.x = box.topleft.x + (box.width - (nl.x - box.topleft.x)) - 20;
      }
    }

    Iterator<EdgeLayout> e2 = edges.iterator();
    EdgeLayout el;
    while (e2.hasNext()) {
      el = e2.next();
      for (LayoutPoint lp : el.bends) {
        lp.x = box.topleft.x + (box.width - (lp.x - box.topleft.x));
      }
    }
  }
コード例 #2
0
  // convert coordinates to relative coordinates with the top-left one as (0,0)
  public void convertToRelativePositions() {
    LayoutBox box = getExactLayoutBox();
    // System.out.println("Box
    // ("+box.topleft.x+","+box.topleft.y+");("+(box.topleft.x+box.width)+","+(box.topleft.y+box.height));
    Iterator<NodeLayout> e = nodes.iterator();
    NodeLayout nl;
    while (e.hasNext()) {
      nl = e.next();
      /* Debug code
      if(nl.x<box.topleft.x || nl.y<box.topleft.y || nl.x>(box.topleft.x+box.width) || nl.y>(box.topleft.y+box.height)){

          System.out.println("Invalid node     "+nl.x+","+nl.y);
      }
      //*/
      nl.x = nl.x - box.topleft.x;
      nl.y = nl.y - box.topleft.y;
    }

    Iterator<EdgeLayout> e2 = edges.iterator();
    EdgeLayout el;
    while (e2.hasNext()) {
      el = e2.next();
      for (LayoutPoint lp : el.bends) {
        lp.x = lp.x - box.topleft.x;
        lp.y = lp.y - box.topleft.y;
      }
    }
  }
コード例 #3
0
 private void safeBeginParagraph() {
   if (!myParagraphStarted) {
     myParagraphStarted = true;
     myBufferIsEmpty = true;
     beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
     if (!myParagraphStored) {
       // final ArrayList models = Model.getBookTextModels();
       // myParagraphVector.add(new Pair(((ZLTextPlainModel)
       // models.get(models.size()-1)/*BookTextModel*/).getParagraphsNumber() - 1, models.size() -
       // 1));
       myParagraphStored = true;
     }
     for (Iterator it = myDelayedControls.iterator(); it.hasNext(); ) {
       Pair pit = (Pair) it.next();
       addControl((Byte) pit.myFirst, (Boolean) pit.mySecond);
     }
     // if (myForcedEntry != null) {
     //	addControl(myForcedEntry);
     // } else {
     addControl(FBTextKind.REGULAR, true);
     // }
     for (Iterator it = myDelayedHyperlinks.iterator(); it.hasNext(); ) {
       addHyperlinkControl(FBTextKind.INTERNAL_HYPERLINK, (String) it.next());
     }
     myDelayedHyperlinks.clear();
   }
 }
コード例 #4
0
  @Test
  public void test1() throws Exception {

    Student denise = studentHome.create("823", "Denise Smith");

    Course power = courseHome.create("220", "Power J2EE Programming");

    Enroller enroller = enrollerHome.create();
    enroller.enroll("823", "220");
    enroller.enroll("823", "333");
    enroller.enroll("823", "777");
    enroller.enroll("456", "777");
    enroller.enroll("388", "777");

    System.out.println(denise.getName() + ":");
    ArrayList courses = denise.getCourseIds();
    Iterator i = courses.iterator();
    while (i.hasNext()) {
      String courseId = (String) i.next();
      Course course = courseHome.findByPrimaryKey(courseId);
      System.out.println(courseId + " " + course.getName());
    }

    System.out.println();

    Course intro = courseHome.findByPrimaryKey("777");
    System.out.println(intro.getName() + ":");
    courses = intro.getStudentIds();
    i = courses.iterator();
    while (i.hasNext()) {
      String studentId = (String) i.next();
      Student student = studentHome.findByPrimaryKey(studentId);
      System.out.println(studentId + " " + student.getName());
    }
  }
コード例 #5
0
  /**
   * @return exact rectangle box bounding all the center points of the nodes and all the bend
   *     points.
   */
  public LayoutBox getExactLayoutBox() {

    Iterator<NodeLayout> e = nodes.iterator();
    double tlx = 0, tly = 0, brx = 0, bry = 0; // top left, bottom right
    NodeLayout nl;

    if (e.hasNext()) {
      nl = e.next();
      tlx = nl.x;
      tly = nl.y;
      brx = nl.x;
      bry = nl.y;
    }

    while (e.hasNext()) {
      nl = e.next();
      if (nl.x < tlx) {
        tlx = nl.x;
      }
      if (nl.x > brx) {
        brx = nl.x;
      }
      if (nl.y < tly) {
        tly = nl.y;
      }
      if (nl.y > bry) {
        bry = nl.y;
      }
    }

    Iterator<EdgeLayout> ee = edges.iterator();
    Iterator<LayoutPoint> be;
    LayoutPoint lp;
    EdgeLayout el;
    while (ee.hasNext()) {
      el = ee.next();
      be = el.bends.iterator();
      while (be.hasNext()) {
        lp = be.next();
        if (lp.x < tlx) {
          tlx = lp.x;
        }
        if (lp.x > brx) {
          brx = lp.x;
        }
        if (lp.y < tly) {
          tly = lp.y;
        }
        if (lp.y > bry) {
          bry = lp.y;
        }
      }
    }

    return new LayoutBox(tlx, tly, brx - tlx, bry - tly);
  }
コード例 #6
0
 public String toString() {
   if (isEmpty()) {
     return "";
   }
   StringBuffer sb = new StringBuffer();
   Iterator<NodeLayout> e = nodes.iterator();
   while (e.hasNext()) sb.append((e.next()).toString());
   sb.append("\n");
   Iterator<EdgeLayout> ee = edges.iterator();
   while (ee.hasNext()) sb.append((ee.next()).toString());
   return sb.toString();
 }
コード例 #7
0
  private JunctionTree buildJtStructure() {
    TreeSet pq = new TreeSet(sepsetChooser);

    // Initialize pq with all possible edges...
    for (Iterator it = cliques.iterator(); it.hasNext(); ) {
      BitVarSet c1 = (BitVarSet) it.next();
      for (Iterator it2 = cliques.iterator(); it2.hasNext(); ) {
        BitVarSet c2 = (BitVarSet) it2.next();
        if (c1 == c2) break;
        pq.add(new BitVarSet[] {c1, c2});
      }
    }

    // ...and add the edges to jt that come to the top of the queue
    //  and don't cause a cycle.
    // xxx OK, this sucks.  openjgraph doesn't allow adding
    //  disconnected edges to a tree, so what we'll do is create a
    //  Graph frist, then convert it to a Tree.
    ListenableUndirectedGraph g = new ListenableUndirectedGraph(new SimpleGraph());

    // first add every clique to the graph
    for (Iterator it = cliques.iterator(); it.hasNext(); ) {
      VarSet c = (VarSet) it.next();
      g.addVertex(c);
    }

    ConnectivityInspector inspector = new ConnectivityInspector(g);
    g.addGraphListener(inspector);

    // then add n - 1 edges
    int numCliques = cliques.size();
    int edgesAdded = 0;
    while (edgesAdded < numCliques - 1) {
      VarSet[] pair = (VarSet[]) pq.first();
      pq.remove(pair);

      if (!inspector.pathExists(pair[0], pair[1])) {
        g.addEdge(pair[0], pair[1]);
        edgesAdded++;
      }
    }

    JunctionTree jt = graphToJt(g);
    if (logger.isLoggable(Level.FINER)) {
      logger.finer("  jt structure was " + jt);
    }
    return jt;
  }
コード例 #8
0
ファイル: TestClass.java プロジェクト: rituc/Programming
  public static void main(String args[]) {
    int N;
    Scanner in = new Scanner(System.in);
    N = in.nextInt();
    int arr[] = new int[N];
    ArrayList even = new ArrayList();
    ArrayList odd = new ArrayList();
    ArrayList list = new ArrayList();

    for (int i = 0; i < N; i++) {
      arr[i] = in.nextInt();
    }
    int evenSum = 0;
    int oddSum = 0;
    for (int i = 0; i < N; i++) {
      if (arr[i] % 2 == 0) {
        even.add(arr[i]);
        evenSum = evenSum + arr[i];
      } else {
        odd.add(arr[i]);
        oddSum = oddSum + arr[i];
      }
    }
    even.add(evenSum);
    odd.add(oddSum);
    Collections.sort(even);
    Collections.sort(odd);
    list.addAll(even);
    list.addAll(odd);
    Iterator itr = list.iterator();
    while (itr.hasNext()) {
      System.out.println(itr.next());
    }
  }
コード例 #9
0
  /** Parses the last consonant. */
  private void parseLastConsonant() {
    if (!validViSyll) return;
    if (iCurPos > strSyllable.length()) strLastConsonant = ZERO;
    String strCon = strSyllable.substring(iCurPos, strSyllable.length());

    if (strCon.length() > 3) {
      validViSyll = false;
      return;
    }

    Iterator iter = alLastConsonants.iterator();
    while (iter.hasNext()) {
      String tempLastCon = (String) iter.next();
      if (strCon.equals(tempLastCon)) {
        strLastConsonant = tempLastCon;
        iCurPos += strLastConsonant.length();
        return;
      }
    }
    strLastConsonant = ZERO;
    if (iCurPos >= strSyllable.length()) validViSyll = true;
    else validViSyll = false;

    return;
  }
コード例 #10
0
  /** Parses the main vowel. */
  private void parseMainVowel() {
    if (!validViSyll) return;
    if (iCurPos > strSyllable.length() - 1) {
      validViSyll = false;
      return;
    }

    String strVowel = "";
    for (int i = iCurPos; i < strSyllable.length(); ++i) {
      int idx = vnVowels.indexOf(strSyllable.charAt(i));
      if (idx == -1) break;

      strVowel += vnVowels.charAt((idx / 6) * 6);
      if (tone.getValue() == TONE.NO_TONE.getValue()) tone = TONE.getTone(idx % 6);
    }

    Iterator iter = alMainVowels.iterator();
    while (iter.hasNext()) {
      String tempVowel = (String) iter.next();
      if (strVowel.startsWith(tempVowel)) {
        strMainVowel = tempVowel;
        iCurPos += tempVowel.length();
        return;
      }
    }
    validViSyll = false;
    return;
  }
コード例 #11
0
  public Double calculateRating(ArrayList nearestNeighbours, int subjectID, int minOccurences) {
    Double totalSimilarity = 0.0;
    Double totalWeight = 0.0;
    Integer occurenceCounter = 0;
    Iterator<ArrayList<Double>> neighbourIterator = nearestNeighbours.iterator();

    while (neighbourIterator.hasNext()) {
      ArrayList<Double> neighbourMapping = neighbourIterator.next();

      Double neighbourSimilarity = neighbourMapping.get(1);
      try {
        Double neighbourRating =
            getNeighbourRating(userPreferences.get(neighbourMapping.get(0).intValue()), subjectID);
        totalSimilarity += neighbourSimilarity;
        totalWeight += neighbourSimilarity * neighbourRating;
        occurenceCounter++;
      } catch (NullPointerException e) {
        // if the subject isn't found, skip
        continue;
      }
    }

    if (occurenceCounter < minOccurences) {
      return null;
    }
    return totalWeight / totalSimilarity;
  }
コード例 #12
0
  public void updateTrackedEntities() {
    ArrayList arraylist = new ArrayList();
    Iterator iterator = trackedEntitySet.iterator();

    do {
      if (!iterator.hasNext()) {
        break;
      }

      EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
      entitytrackerentry.updatePlayerList(field_72795_a.playerEntities);

      if (entitytrackerentry.playerEntitiesUpdated
          && (entitytrackerentry.trackedEntity instanceof EntityPlayerMP)) {
        arraylist.add((EntityPlayerMP) entitytrackerentry.trackedEntity);
      }
    } while (true);

    for (Iterator iterator1 = arraylist.iterator(); iterator1.hasNext(); ) {
      EntityPlayerMP entityplayermp = (EntityPlayerMP) iterator1.next();
      EntityPlayerMP entityplayermp1 = entityplayermp;
      Iterator iterator2 = trackedEntitySet.iterator();

      while (iterator2.hasNext()) {
        EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator2.next();

        if (entitytrackerentry1.trackedEntity != entityplayermp1) {
          entitytrackerentry1.updatePlayerEntity(entityplayermp1);
        }
      }
    }
  }
コード例 #13
0
  /**
   * Submit a request to the server which expects a list of execution items in the response, and
   * return a single QueuedItemResult parsed from the response.
   *
   * @param tempxml xml temp file (or null)
   * @param otherparams parameters for the request
   * @param requestPath
   * @return a single QueuedItemResult
   * @throws com.dtolabs.rundeck.core.dispatcher.CentralDispatcherException if an error occurs
   */
  private QueuedItemResult submitExecutionRequest(
      final File tempxml, final HashMap<String, String> otherparams, final String requestPath)
      throws CentralDispatcherException {

    final HashMap<String, String> params = new HashMap<String, String>();
    if (null != otherparams) {
      params.putAll(otherparams);
    }

    final WebserviceResponse response;
    try {
      response = serverService.makeRundeckRequest(requestPath, params, tempxml, null);
    } catch (MalformedURLException e) {
      throw new CentralDispatcherServerRequestException("Failed to make request", e);
    }
    validateResponse(response);

    final ArrayList<QueuedItem> list = parseExecutionListResult(response);
    if (null == list || list.size() < 1) {

      return QueuedItemResultImpl.failed("Server response contained no success information.");
    } else {

      final QueuedItem next = list.iterator().next();
      return QueuedItemResultImpl.successful(
          "Succeeded queueing " + next.getName(), next.getId(), next.getUrl(), next.getName());
    }
  }
コード例 #14
0
ファイル: PlayStoreList.java プロジェクト: ezraerb/nflodap
 // NOTE: K is used by DataStoreInterface, end up with L and M
 public <L extends Enum<L>, M extends Enum<M>> void pivot(
     EnumMap<L, EnumMap<M, ArrayList<SinglePlay>>> plays,
     Class<L> firstEnumType,
     Class<M> secondEnumType) {
   /* Need to iterate through the map and extract the wanted value
   from each play. If an entry does not already exist in the
   result map, have to add it, and then insert the play */
   Iterator<SinglePlay> index = _plays.iterator();
   while (index.hasNext()) {
     SinglePlay testPlay = index.next();
     L firstWantValue = testPlay.getValue(firstEnumType);
     M secondWantValue = testPlay.getValue(secondEnumType);
     if ((firstWantValue != null) && (secondWantValue != null)) { // Play has value in wanted types
       EnumMap<M, ArrayList<SinglePlay>> wantMap = plays.get(firstWantValue);
       if (wantMap == null) {
         /* NOTE: creating an enum map of M here, so need the
         second enumerated type, not the first */
         wantMap = new EnumMap<M, ArrayList<SinglePlay>>(secondEnumType);
         plays.put(firstWantValue, wantMap);
       }
       ArrayList<SinglePlay> wantList = wantMap.get(secondWantValue);
       if (wantList == null) {
         wantList = new ArrayList<SinglePlay>();
         wantMap.put(secondWantValue, wantList);
       }
       wantList.add(testPlay);
     } // Play has value in wanted type
   } // While plays to process
 } // Rollup method
コード例 #15
0
ファイル: Hooks.java プロジェクト: sepiroth887/KinectHomer
  void filterServiceEventReceivers(
      final ServiceEvent evt, final Collection /*<ServiceListenerEntry>*/ receivers) {
    ArrayList srl = fwCtx.services.get(EventHook.class.getName());
    if (srl != null) {
      HashSet ctxs = new HashSet();
      for (Iterator ir = receivers.iterator(); ir.hasNext(); ) {
        ctxs.add(((ServiceListenerEntry) ir.next()).getBundleContext());
      }
      int start_size = ctxs.size();
      RemoveOnlyCollection filtered = new RemoveOnlyCollection(ctxs);

      for (Iterator i = srl.iterator(); i.hasNext(); ) {
        ServiceReferenceImpl sr = ((ServiceRegistrationImpl) i.next()).reference;
        EventHook eh = (EventHook) sr.getService(fwCtx.systemBundle);
        if (eh != null) {
          try {
            eh.event(evt, filtered);
          } catch (Exception e) {
            fwCtx.debug.printStackTrace(
                "Failed to call event hook  #" + sr.getProperty(Constants.SERVICE_ID), e);
          }
        }
      }
      // NYI, refactor this for speed!?
      if (start_size != ctxs.size()) {
        for (Iterator ir = receivers.iterator(); ir.hasNext(); ) {
          if (!ctxs.contains(((ServiceListenerEntry) ir.next()).getBundleContext())) {
            ir.remove();
          }
        }
      }
    }
  }
コード例 #16
0
ファイル: Hero.java プロジェクト: Nekrofage/tyrant
  public static String reportKillData() {
    HashMap hm = getKillHashMap();

    ArrayList al = new ArrayList(hm.keySet());

    Collections.sort(al);

    StringBuffer sb = new StringBuffer();

    sb.append("You have killed the following creatures:\n");
    sb.append("\n");

    boolean uniques = true;

    for (Iterator it = al.iterator(); it.hasNext(); ) {
      String name = (String) it.next();

      // display line after uniques
      if (uniques && (!Character.isUpperCase(name.charAt(0)))) {
        uniques = false;
        sb.append("\n");
      }

      Integer count = (Integer) (hm.get(name));
      String g = Text.centrePad(name, count.toString(), 60);
      sb.append(g + "\n");
    }

    return sb.toString();
  }
コード例 #17
0
 public void parcoursEnfants() {
   for (Iterator<ModeleInstruction> iter = instructions.iterator(); iter.hasNext(); ) {
     Noeud nd = (Noeud) iter.next();
     nd.parent = this;
     nd.parcoursEnfants();
   }
 }
コード例 #18
0
  private void func_22181_a(
      File file, ArrayList arraylist, int i, int j, IProgressUpdate iprogressupdate) {
    Collections.sort(arraylist);
    byte abyte0[] = new byte[4096];
    int i1;
    for (Iterator iterator = arraylist.iterator();
        iterator.hasNext();
        iprogressupdate.setLoadingProgress(i1)) {
      ChunkFile chunkfile = (ChunkFile) iterator.next();
      int k = chunkfile.func_22323_b();
      int l = chunkfile.func_22321_c();
      RegionFile regionfile = RegionFileCache.func_22193_a(file, k, l);
      if (!regionfile.func_22202_c(k & 0x1f, l & 0x1f)) {
        try {
          DataInputStream datainputstream =
              new DataInputStream(
                  new GZIPInputStream(new FileInputStream(chunkfile.func_22324_a())));
          DataOutputStream dataoutputstream =
              regionfile.getChunkDataOutputStream(k & 0x1f, l & 0x1f);
          for (int j1 = 0; (j1 = datainputstream.read(abyte0)) != -1; ) {
            dataoutputstream.write(abyte0, 0, j1);
          }

          dataoutputstream.close();
          datainputstream.close();
        } catch (IOException ioexception) {
          ioexception.printStackTrace();
        }
      }
      i++;
      i1 = (int) Math.round((100D * (double) i) / (double) j);
    }

    RegionFileCache.func_22192_a();
  }
コード例 #19
0
  /**
   * Estimates the mean of array <code>y</code>. <code>robustMu</code> uses a Gaussian model to
   * remove outliers iteratively.
   *
   * @param y an array
   * @return the estimated mean of <code>y</code>
   */
  private double robustMu(double[] y) {

    ArrayList<Double> x = new ArrayList<Double>(y.length);

    for (int i = 0; i < y.length; i++) {
      x.add(y[i]);
    }

    double sigma = 0;
    NormalDist gaussian = new NormalDist();
    double cutoff = 0;
    double cutoff1 = 0;
    double cutoff2 = 0;

    int xSize = x.size();

    sigma = std(x);
    double areaRemoved = 0.5 / xSize;

    cutoff = abs(gaussian.inverseF(areaRemoved));

    cutoff1 = -cutoff * sigma + mean(x);
    cutoff2 = cutoff * sigma + mean(x);

    while (true) {

      Iterator<Double> iter = x.iterator();

      int numRemoved = 0;
      while (iter.hasNext()) {

        double cn = iter.next();
        if (cn < cutoff1 || cn > cutoff2) {
          numRemoved++;
          iter.remove();
        }
      }

      if (numRemoved == 0) {
        break;
      }

      sigma = std(x);
      sigma =
          sigma
              / sqrt(
                  (1 - 2 * areaRemoved - 2 * cutoff * exp(-pow(cutoff, 2) / 2) / sqrt(2 * PI))
                      / (1 - 2 * areaRemoved));

      xSize = x.size();
      areaRemoved = 0.5 / xSize;

      cutoff = abs(gaussian.inverseF(areaRemoved));

      cutoff1 = -cutoff * sigma + mean(x);
      cutoff2 = cutoff * sigma + mean(x);
    }

    return mean(x);
  }
コード例 #20
0
 private int[] getHashes(LireFeature feature) {
   // result = new int[maximumHits];
   hashingResultScoreDocs.clear();
   maxDistance = 0f;
   tmpScore = 0f;
   int rep = 0;
   LireFeature tmpFeature;
   for (Iterator<LireFeature> iterator = representatives.iterator(); iterator.hasNext(); ) {
     tmpFeature = iterator.next();
     tmpScore = tmpFeature.getDistance(feature);
     if (hashingResultScoreDocs.size() < maximumHits) {
       hashingResultScoreDocs.add(new SimpleResult(tmpScore, null, rep));
       maxDistance = Math.max(maxDistance, tmpScore);
     } else if (tmpScore < maxDistance) {
       hashingResultScoreDocs.add(new SimpleResult(tmpScore, null, rep));
     }
     while (hashingResultScoreDocs.size() > maximumHits) {
       hashingResultScoreDocs.remove(hashingResultScoreDocs.last());
       maxDistance = hashingResultScoreDocs.last().getDistance();
     }
     rep++;
   }
   rep = 0;
   for (Iterator<SimpleResult> iterator = hashingResultScoreDocs.iterator();
       iterator.hasNext(); ) {
     SimpleResult next = iterator.next();
     result[rep] = next.getIndexNumber();
     rep++;
   }
   return result;
 }
コード例 #21
0
ファイル: ProbaTree.java プロジェクト: student2ua/myTaning
 private void createPainToTree3true(
     final DefaultTreeModel treeModel, DefaultMutableTreeNode root, Collection paintCollection) {
   ArrayList a = (ArrayList) paintCollection;
   Iterator i = a.iterator();
   Person p = null;
   Person parent = null;
   DefaultMutableTreeNode parentNode = root;
   DefaultMutableTreeNode newNode;
   while (i.hasNext()) {
     p = (Person) i.next();
     int ves, ves2;
     if (parent != null) {
       parent = (Person) parentNode.getUserObject();
       ves = comparePerson(p, (Person) parentNode.getUserObject());
       ves2 = comparePersonAsString(p, (Person) parentNode.getUserObject()) + 1;
       System.out.println("ves = " + ves + " ves2= " + ves2);
       switch (ves) {
         case 0:
           {
             parentNode = root;
             parent = null;
             break;
           }
         case 1:
           {
           }
       }
     }
     newNode = new DefaultMutableTreeNode(p);
     parentNode.add(newNode);
     parent = p;
     parentNode = newNode;
   }
 }
コード例 #22
0
 protected void fetchURLAndProcess(
     Utils.Notification notification, Utils.Function<Void, ArrayList<JuickMessage>> cont) {
   if (page == 0) {
     urlParser.getArgsMap().remove("page");
   } else {
     urlParser.getArgsMap().put("page", "" + page);
   }
   final String jsonStr =
       httpClientService.getJSON(urlParser.getFullURL(), notification).getResult();
   ArrayList<JuickMessage> messages = parseJSONpure(jsonStr);
   if (messages.size() > 0) {
     ArrayList<JuickMessage> reverse = new ArrayList<JuickMessage>();
     for (Iterator<JuickMessage> iterator = messages.iterator(); iterator.hasNext(); ) {
       JuickMessage message = iterator.next();
       if (!loadedMessages.add(message.getMID().toString())) {
         iterator.remove();
       } else {
         reverse.add(0, message);
       }
     }
     if (loadedMessages.size() == 0) {
       page++;
       fetchURLAndProcess(notification, cont);
       return;
     } else {
       messages = reverse;
     }
   }
   cont.apply(messages);
 }
コード例 #23
0
 public static ArrayList<Interview> processInterviews(
     ArrayList<Interview> interviews, FeatureExtractor extractor) {
   ArrayList<Interview> new_interviews = new ArrayList<>();
   for (Iterator<Interview> i = interviews.iterator(); i.hasNext(); )
     new_interviews.add(extractor.update(i.next()));
   return new_interviews;
 }
コード例 #24
0
ファイル: Solution.java プロジェクト: yuzhuY/leetcode_answers
 public int[] intersect(int[] nums1, int[] nums2) {
   HashMap<Integer, Integer> set = new HashMap<Integer, Integer>();
   ArrayList<Integer> res = new ArrayList<Integer>();
   for (int i = 0; i < nums1.length; i++) {
     if (set.containsKey(nums1[i])) {
       set.put(nums1[i], set.get(nums1[i]) + 1);
     } else {
       set.put(nums1[i], 1);
     }
   }
   for (int i = 0; i < nums2.length; i++) {
     if (set.containsKey(nums2[i])) {
       res.add(nums2[i]);
       if (set.get(nums2[i]) > 1) {
         set.put(nums2[i], set.get(nums2[i]) - 1);
       } else {
         set.remove(nums2[i]);
       }
     }
   }
   Iterator<Integer> iter = res.iterator();
   int[] resArray = new int[res.size()];
   for (int i = 0; iter.hasNext(); i++) {
     resArray[i] = iter.next();
   }
   return resArray;
 }
コード例 #25
0
  public ArrayList<ArrayList<float[]>> getGestureTracesByID(String id) {
    /*
     *  this convenience method returns
     *  gesture traces as arrays
     *
     */

    ArrayList<Gesture> gestures = this.getGesturesByID(id);

    if (gestures != null) {
      int g_count = gestures.size();
      ArrayList<ArrayList<float[]>> out =
          new ArrayList<ArrayList<float[]>>(g_count); // new float[g_count][][];
      ArrayList<float[][]> traces = new ArrayList<float[][]>(10);

      Iterator<Gesture> it = gestures.iterator();
      // collect the gesture traces (hopefully no copying!)
      int g_maxLength = 0; // max length of the gestures --> to fill the array (?)
      int g_idx = 0;
      while (it.hasNext()) {
        Gesture g = it.next();
        out.add(g.gestureTrace);
      }

      return out;
      // no fill up the array
    } else {
      Log.i("getGestureTracesByID", "No Gestures for id " + id);
      return null;
    }
  }
コード例 #26
0
ファイル: RPGItem.java プロジェクト: OsipXD/RPG-Items
 public boolean removePower(String pow) {
   Iterator<Power> it = powers.iterator();
   Power power = null;
   while (it.hasNext()) {
     Power p = it.next();
     if (p.getName().equalsIgnoreCase(pow)) {
       it.remove();
       power = p;
       rebuild();
       break;
     }
   }
   if (power != null) {
     if (power instanceof PowerHit) {
       powerHit.remove((PowerHit) power);
     }
     if (power instanceof PowerLeftClick) {
       powerLeftClick.remove(power);
     }
     if (power instanceof PowerRightClick) {
       powerRightClick.remove(power);
     }
     if (power instanceof PowerProjectileHit) {
       powerProjectileHit.remove(power);
     }
     if (power instanceof PowerTick) {
       powerTick.remove(power);
     }
   }
   return power != null;
 }
コード例 #27
0
ファイル: Hooks.java プロジェクト: sepiroth887/KinectHomer
  void filterServiceReferences(
      BundleContextImpl bc,
      String service,
      String filter,
      boolean allServices,
      Collection /*<ServiceReference>*/ refs) {
    ArrayList srl = fwCtx.services.get(FindHook.class.getName());
    if (srl != null) {
      RemoveOnlyCollection filtered = new RemoveOnlyCollection(refs);

      for (Iterator i = srl.iterator(); i.hasNext(); ) {
        ServiceReferenceImpl sr = ((ServiceRegistrationImpl) i.next()).reference;
        FindHook fh = (FindHook) sr.getService(fwCtx.systemBundle);
        if (fh != null) {
          try {
            fh.find(bc, service, filter, allServices, filtered);
          } catch (Exception e) {
            fwCtx.listeners.frameworkError(
                bc,
                new BundleException(
                    "Failed to call find hook  #" + sr.getProperty(Constants.SERVICE_ID), e));
          }
        }
      }
    }
  }
コード例 #28
0
  /** A Wizard with a smattering of problems */
  protected static CharacterWrapper _testScenario1(GameData data) {
    GameObject character = data.getGameObjectByName("Wizard");
    GameObject f1 = data.getGameObjectByName("Test Fly Chit 1");
    character.add(f1);
    System.out.println(character);

    CharacterWrapper wrapper = new CharacterWrapper(character);
    wrapper.setCharacterLevel(4);
    wrapper.initChits();

    // artifically fatigue and wound some chits
    ArrayList list = new ArrayList(wrapper.getAllChits());
    Collections.sort(list);
    int n = 0;
    for (Iterator i = list.iterator(); i.hasNext(); ) {
      CharacterActionChitComponent aChit = (CharacterActionChitComponent) i.next();
      System.out.println((n++) + " " + aChit.getGameObject().getName());
    }

    CharacterActionChitComponent aChit = (CharacterActionChitComponent) list.get(1);
    aChit.getGameObject().setThisAttribute("action", "FLY");
    aChit.getGameObject().setThisAttribute("effort", "1");

    //		aChit.makeFatigued();
    //		for (int i=4;i<11;i++) {
    //			aChit = (CharacterActionChitComponent)list.get(i);
    //			aChit.makeWounded();
    //		}
    aChit = (CharacterActionChitComponent) list.get(11);
    aChit.enchant();
    //		(new Curse(new JFrame())).applyThree(wrapper);
    return wrapper;
  }
コード例 #29
0
ファイル: Driver.java プロジェクト: trunkatedpig/hw
  public static void main(String[] args) throws FileNotFoundException {
    String s;

    ArrayList<String> AL = new ArrayList<String>();
    AL.add("one");
    AL.add("two");
    AL.add("three");
    AL.add("four");
    AL.add("five");
    AL.add("six");
    System.out.println("ArrayList (iterator) " + AL);
    Iterator<String> it = AL.iterator();
    while (it.hasNext()) {
      s = it.next();
      System.out.println("AL: " + s);
    }
    System.out.println();

    myList ml = new myList();
    ml.add(20);
    ml.add(50);
    ml.add(12);
    ml.add(13);
    ml.add(53);
    ml.add(33);
    ml.add(23);

    System.out.println(ml);
    Iterator<Integer> mlit = ml.iterator();
    while (mlit.hasNext()) {
      System.out.println(mlit.next());
    }
  }
コード例 #30
0
  /** Prints a user-readable version of this query. */
  @Override
  public final String toString(String f) {
    StringBuilder buffer = new StringBuilder();
    if (field == null || !field.equals(f)) {
      buffer.append(field);
      buffer.append(":");
    }

    buffer.append("\"");
    Iterator<Term[]> i = termArrays.iterator();
    while (i.hasNext()) {
      Term[] terms = i.next();
      if (terms.length > 1) {
        buffer.append("(");
        for (int j = 0; j < terms.length; j++) {
          buffer.append(terms[j].text());
          if (j < terms.length - 1) buffer.append(" ");
        }
        buffer.append(")");
      } else {
        buffer.append(terms[0].text());
      }
      if (i.hasNext()) buffer.append(" ");
    }
    buffer.append("\"");

    if (slop != 0) {
      buffer.append("~");
      buffer.append(slop);
    }

    buffer.append(ToStringUtils.boost(getBoost()));

    return buffer.toString();
  }