Example #1
0
 private static void moveSomewhere() throws GameActionException {
   while (!defendQueue.isEmpty()) {
     int next = defendQueue.element();
     if (teamMemberNeedsHelp[next] > 0 && rc.getRoundNum() - teamMemberNeedsHelp[next] < 200) {
       if (rc.isCoreReady()) {
         Nav.goTo(teamLocations[next]);
       }
       return;
     }
     defendQueue.remove();
   }
   if (!moveQueue.isEmpty()) {
     MapLocation next = moveQueue.element();
     if (rc.isCoreReady()) {
       Nav.goTo(next);
     }
     if (rc.canSense(next) && rc.senseRobotAtLocation(next) == null) {
       moveQueue.remove();
     }
     return;
   }
   if (rc.isCoreReady()) {
     Nav.goTo(personalHQ);
     return;
   }
 }
  public void updateRecentlyOpenedFiles(String s) {
    // try to add this file to the list and update the preference
    Iterator i = list.iterator();

    // update the maxFile count in case it changed...
    list.remove(0);
    list.add(0, maxSize);

    // is file already in list?
    if (list.contains(s)) {
      int index = list.indexOf(s);
      list.remove(index);
      list.add(1, s);

    } else {
      // if it's not in the list add it to the top and deal with it later
      list.add(1, s);
    }

    // trim list if necessary...
    while (list.size() > (maxsize + 1)) list.removeLast();

    // build a new pref String;
    StringBuffer sbuffer = new StringBuffer();

    i = list.iterator();

    while (i.hasNext()) {
      sbuffer.append((String) i.next());
      sbuffer.append("*");
    }
    // update the preference
    openFilePref.setValue(sbuffer.toString());
  }
Example #3
0
  // Updates indexes, deleting informations about the last removed clause
  public void unregister(ClauseInfo ci) {
    Term clause = ci.getHead();
    if (clause instanceof Struct) {
      Struct g = (Struct) clause.getTerm();

      if (g.getArity() == 0) {
        return;
      }

      Term t = g.getArg(0).getTerm();
      if (t instanceof Var) {
        numCompClausesIndex.removeShared(ci);
        constantCompClausesIndex.removeShared(ci);
        structCompClausesIndex.removeShared(ci);

        listCompClausesList.remove(ci);
      } else if (t.isAtomic()) {
        if (t instanceof Number) {
          numCompClausesIndex.delete((Number) t, ci);
        } else if (t instanceof Struct) {
          constantCompClausesIndex.delete(((Struct) t).getName(), ci);
        }
      } else if (t instanceof Struct) {
        if (t.isList()) {
          listCompClausesList.remove(ci);
        } else {
          structCompClausesIndex.delete(((Struct) t).getPredicateIndicator(), ci);
        }
      }
    }
  }
  protected void removeRequest(PeerNATTraversal request, int outcome) {
    synchronized (initiators) {
      LinkedList requests = (LinkedList) initiators.get(request.getInitiator());

      if (requests != null) {

        requests.remove(request);
      }

      pending_requests.remove(request);

      if (active_requests.remove(request)) {

        usage_average.addValue(request.getTimeUsed());

        if (outcome == OUTCOME_SUCCESS) {

          success_count++;

        } else {

          InetSocketAddress target = request.getTarget();

          negative_result_bloom.add(target.toString().getBytes());

          if (outcome == OUTCOME_FAILED_NO_REND) {

            failed_no_rendezvous++;
          }
        }
      }
    }
  }
  private void buildValuePermutation() {

    for (int i = 0; i < inputValues.size(); i++) {
      LinkedList<String> lst2 = new LinkedList<String>(inputValues);
      lst2.remove(i);

      for (int j = 0; j < lst2.size(); j++) {
        LinkedList<String> lst3 = new LinkedList<String>(lst2);
        lst3.remove(j);

        for (int k = 0; k < lst3.size(); k++) {
          LinkedList<String> lst4 = new LinkedList<String>(lst3);
          lst4.remove(k);

          for (int l = 0; l < lst4.size(); l++) {
            LinkedList<String> rslt = new LinkedList<String>();
            rslt.addLast(inputValues.get(i));
            rslt.addLast(lst2.get(j));
            rslt.addLast(lst3.get(k));
            rslt.addLast(lst4.get(l));
            permutations.add(rslt);
          }
        }
      }
    }
  }
  /**
   * Moves a node (an Item) in the container immediately after a sibling node. The two nodes must
   * have the same parent in the container.
   *
   * @param itemId the identifier of the moved node (Item)
   * @param siblingId the identifier of the reference node (Item), after which the other node will
   *     be located
   */
  public void moveAfterSibling(Object itemId, Object siblingId) {
    Object parent2 = getParent(itemId);
    LinkedList<Object> childrenList;
    if (parent2 == null) {
      childrenList = roots;
    } else {
      childrenList = children.get(parent2);
    }
    if (siblingId == null) {
      childrenList.remove(itemId);
      childrenList.addFirst(itemId);

    } else {
      int oldIndex = childrenList.indexOf(itemId);
      int indexOfSibling = childrenList.indexOf(siblingId);
      if (indexOfSibling != -1 && oldIndex != -1) {
        int newIndex;
        if (oldIndex > indexOfSibling) {
          newIndex = indexOfSibling + 1;
        } else {
          newIndex = indexOfSibling;
        }
        childrenList.remove(oldIndex);
        childrenList.add(newIndex, itemId);
      } else {
        throw new IllegalArgumentException("Given identifiers no not have the same parent.");
      }
    }
    fireItemSetChange();
  }
Example #7
0
  private void rebentaEstrela(Estrela estrela) {

    ArrayList<Estrela> estrelasARemover = null;
    ArrayList<Estrela> estrelasAAdicionar = null;

    if (estrelasARemover == null) {
      estrelasARemover = new ArrayList<>();
    }
    estrelasARemover.add(estrela);
    int diametroAtual = estrela.getDiametro();
    if (estrela.getDiametro() > 20) {
      if (estrelasAAdicionar == null) {
        estrelasAAdicionar = new ArrayList<>();
      }
      estrelasAAdicionar.add(estrela.criaMenor(diametroAtual - 20, false));
      estrelasAAdicionar.add(estrela.criaMenor(diametroAtual - 20, true));
    }

    if (estrelasARemover != null) {
      for (Estrela estrelaARemover : estrelasARemover) {
        estrelas.remove(estrelaARemover);
        pintaveis.remove(estrelaARemover);
      }
    }
    if (estrelasAAdicionar != null) {
      for (Estrela estrelaAAdicionar : estrelasAAdicionar) {
        estrelas.add(estrelaAAdicionar);
        pintaveis.add(estrelaAAdicionar);
      }
    }
    if (estrelas.isEmpty() && bolas.isEmpty()) fimNivel();
  }
Example #8
0
  /**
   * Realise un déplacement
   *
   * @param myCoup
   * @return
   */
  @SuppressWarnings("null")
  public boolean realiserCoup(Coup myCoup) {

    Piece pieceD = null;
    Position posA = null;
    piecePourTest = null;

    try {
      pieceD = myCoup.getPieceDepart();
      posA = myCoup.getPosArrivee();
      myCoup.setPiecePrise(this.getPiecePosition(posA));
    } catch (NullPointerException e) {
      e.getStackTrace();
    }
    if (myCoup.getRoque() == false) {
      if (pieceList.contains(pieceD)) {
        if (pieceD.positionAccessibleChessboard(this).contains(posA)) {
          pieceList.remove(this.getPiecePosition(posA));
          for (Piece piece : pieceList) {
            if (piece.equals(pieceD)) {
              pieceD.setPlayed();
              pieceD.setPos(posA);
              pieceList.remove(piece);
              pieceList.add(pieceD);
              break;
            }
          }
          return true;
        }
      } else return false;
    } else {
      realiserRoque(myCoup);
    }
    return false;
  }
Example #9
0
 /**
  * This method exists to make it easier to see when and where classes are changing the formula
  * This also serves another purpose by adding spaces and formatting when needed, something that
  * the normal setFormula() method cannot do.
  *
  * @param op
  */
 public void addToFormula(char op) throws SyntaxErrorException {
   // if the cell to add the operator in does not exist yet, create it
   if ((opList == null) || (nextEntry >= opList.size())) opList.add(new TreeCell());
   TreeCell currentCell = opList.get(nextEntry); // get the current cell that we will be using
   try {
     if (((op == '/') || (op == '*')) && (nextEntry > 0)) {
       if ((opList.get(nextEntry).getleftSon() == null)
           && (opList.get(nextEntry - 1).getcellValue().length() == 1)) {
         opList.remove(nextEntry);
         nextEntry--;
         currentCell = opList.get(nextEntry);
         currentCell.addOpAndReform(op);
       } else if ((opList.get(nextEntry).getcellValue() == null)
           && (opList.get(nextEntry - 1).getcellValue().length() >= 1)) {
         // this is the first operator to be entered, the first entry being an input.
         opList.remove(nextEntry);
         nextEntry--;
         currentCell = opList.get(nextEntry);
         currentCell.setleftSon(new TreeCell(currentCell.getcellValue()));
         currentCell.setrightSon(null);
         currentCell.setcellValue(op + "");
         currentCell.setstatusCell(TreeCell.LEFT_COMPLETED);
       }
     } else {
       currentCell.addOpInCell(op);
     }
   } catch (SyntaxErrorException e) {
     throw e;
   }
 }
 public void adjustAdjacency(int src, int tgt) {
   int[] passed = new int[edges.size()];
   for (int i = 0; i < edges.size(); i++) passed[i] = 0;
   ArrayList<ArrayList<Integer>> reverseAdj = new ArrayList<ArrayList<Integer>>(nodes.size());
   for (int i = 0; i < nodes.size(); i++) reverseAdj.add(new ArrayList<Integer>());
   for (int i = 0; i < srcs.size(); i++) reverseAdj.get(tgts.get(i)).add(i);
   LinkedList<Integer> nodeQueue = new LinkedList<Integer>();
   nodeQueue.add(src);
   while (!nodeQueue.isEmpty()) {
     int node = nodeQueue.remove();
     for (int i = 0; i < adjacency.get(node).size(); i++) {
       int edge = adjacency.get(node).get(i);
       passed[edge]++;
       nodeQueue.add(tgts.get(edge));
     }
     adjacency.get(node).clear();
   }
   adjacency = reverseAdj;
   nodeQueue.add(tgt);
   while (!nodeQueue.isEmpty()) {
     int node = nodeQueue.remove();
     for (int i = 0; i < adjacency.get(node).size(); i++) {
       int edge = adjacency.get(node).get(i);
       passed[edge]++;
       nodeQueue.add(srcs.get(edge));
     }
     adjacency.get(node).clear();
   }
   for (int n = 0; n < nodes.size(); n++) adjacency.get(n).clear();
   for (int e = 0; e < edges.size(); e++) if (passed[e] == 2) adjacency.get(srcs.get(e)).add(e);
 }
  public void swap(LinkedList n, int a, int b) {
    if (n.isEmpty()) {
      return;
    } else {
      int x = 0;
      int y = 0;
      if (n.contains(a)) {
        x = n.indexOf(a);
      }
      if (n.contains(b)) {
        y = n.indexOf(b);
      }

      if (x < y) {
        n.remove(x);
        n.add(y, a);
        n.remove(y - 1);
        n.add(x, b);
      } else {
        n.remove(y);
        n.add(x, b);
        n.remove(x - 1);
        n.add(y, a);
      }
    }
    System.out.println(n);
  }
Example #12
0
  public static void update() {
    Statistics.colonyReset();

    for (Mouse mouse : mice) {
      mouse.update();
      if (!mouse.isAlive()) deadMice.add(mouse);

      Statistics.colonyInclude(mouse);
    }

    Statistics.colonyReady();

    while (!deadMice.isEmpty()) {
      Mouse deadMouse = deadMice.remove();

      mice.remove(deadMouse);
      Stream.history("Colony Size: " + mice.size());
      MouseSim.getWorld().getWorldNode(deadMouse.getPosition()).remove(deadMouse);

      if (mice.size() == 1) {
        Stream.update(mice.get(0) + " is the last mouse alive! x_x");
      }
    }

    while (!bornMice.isEmpty()) {
      Mouse bornMouse = bornMice.remove();
      mice.add(bornMouse);
      Stream.history("Colony Size: " + mice.size());
    }

    if (mice.isEmpty()) {
      MouseSim.endGame("all the mice have died.");
    }
  }
Example #13
0
  /**
   * Returns a <tt>LogInputStream</tt> object from the pool if it already exists. Otherwise, it
   * creates a new instance and adds it to the pool.
   *
   * @exception IOException if an I/O error occurs
   */
  synchronized LogInputStream getLogInputStream(File file, long offset) throws IOException {
    StreamKey key = new StreamKey(file, StreamType.INPUT);
    LogInputStream in = (LogInputStream) pool.get(key);
    if (in != null) { // found it!
      if (freeList.remove(key) == false)
        throw new InternalMailboxException(
            "Did not find re-used input log " + "stream in freelist.");
    }

    if (in == null
        || // if log not found OR
        in.getOffset() > offset) // current read offset is past desired
    { // then create a new log and add it
      ensurePoolSpace();

      in = new LogInputStream(file, key);
      pool.put(key, in);

      if (freeList.remove(key))
        throw new InternalMailboxException("Found newly created ControlLog " + "on freeList");
    }

    // Sanity check for offset value
    if (offset > file.length()) throw new EOFException("Attempting to read past end of file.");

    // Check if log offset needs adjusting.
    // By this point in.offset <= offset.
    while (in.getOffset() < offset) {
      in.skip(offset - in.getOffset());
    }

    return in;
  }
  public static void main(String[] args) {
    DoublyLinkedList<Number> doublyLinkedList = new DoublyLinkedList<>();
    for (int i = 0; i < 1000000; i++) {
      doublyLinkedList.add(i);
    }
    LinkedList<Number> numbers = new LinkedList<>();
    for (int i = 0; i < 1000000; i++) {
      numbers.add(i);
    }

    Timer timer = new Timer();
    System.out.println("Addition/remove to/from the beggining test");
    System.out.println("==============================");
    timer.start();
    doublyLinkedList.add(0, 45);
    System.out.println("DoublyLinkedList.add(e): " + timer.getElapsedTime());
    timer.start();
    numbers.add(0, 45);
    System.out.println("LinkedList.add(e): " + timer.getElapsedTime());
    System.out.println("------------");
    timer.start();
    doublyLinkedList.remove(0);
    System.out.println("DoublyLinkedList.remove(e): " + timer.getElapsedTime());
    timer.start();
    numbers.remove(0);
    System.out.println("LinkedList.remove(e): " + timer.getElapsedTime());
    System.out.println("==============================");
    System.out.println("Addition/remove to/from the middle test");
    System.out.println("==============================");
    timer.start();
    doublyLinkedList.add(500000, 45);
    System.out.println("DoublyLinkedList.add(e): " + timer.getElapsedTime());
    timer.start();
    numbers.add(500000, 45);
    System.out.println("LinkedList.add(e): " + timer.getElapsedTime());
    System.out.println("------------");
    timer.start();
    doublyLinkedList.remove(500000);
    System.out.println("DoublyLinkedList.remove(e): " + timer.getElapsedTime());
    timer.start();
    numbers.remove(500000);
    System.out.println("LinkedList.remove(e): " + timer.getElapsedTime());
    System.out.println("==============================");
    System.out.println("Addition/remove to/from the end test");
    System.out.println("==============================");
    timer.start();
    doublyLinkedList.add(doublyLinkedList.size() - 1, 222);
    System.out.println("DoublyLinkedList.add(e): " + timer.getElapsedTime());
    timer.start();
    numbers.add(numbers.size() - 1, 222);
    System.out.println("LinkedList.add(e): " + timer.getElapsedTime());
    System.out.println("------------");
    timer.start();
    doublyLinkedList.remove(doublyLinkedList.size() - 1);
    System.out.println("DoublyLinkedList.remove(e): " + timer.getElapsedTime());
    timer.start();
    numbers.remove(numbers.size() - 1);
    System.out.println("LinkedList.remove(e): " + timer.getElapsedTime());
  }
Example #15
0
 protected void rebentaBola(BolaQJ bola) {
   bolas.remove(bola);
   pintaveis.remove(bola);
   adicBolasRebentamento(bola);
   if (bolas.isEmpty() && estrelas.isEmpty()) {
     fimNivel();
   }
 }
Example #16
0
 @Override
 public void cancelEvent(Event event) {
   if (events.contains(event)) {
     events.remove(event);
   }
   if (worldevents.contains(event)) {
     worldevents.remove(event);
   }
 }
Example #17
0
  public void taxiOffDuty(TaxiQueueItem tqi) {
    for (TaxiQueueItem t : availableTaxis) {
      if (tqi.getTaxiID().equals(t.getTaxiID())) {
        availableTaxis.remove(t);
        registeredTaxis.remove(t);
      }
    }

    System.out.println("TaxiDispatcher: " + tqi + " now off duty (and unavailable)");
  }
Example #18
0
  @Override
  public void removeComponent(IDiagramComponent component) {
    components.remove(component);

    // Optimizes this (create more array for specific elements, not just an
    // array for all components.
    if (component instanceof Entity) entities.remove(component);

    for (final IComponentsObserver c : observers) c.removeComponent(component);
  }
Example #19
0
  /**
   * Look for a path in graph, from def to use. This path has to lie inside an extended basic block
   * (and this property implies uniqueness.). The path returned includes from and to.
   *
   * @param from start point for the path.
   * @param to end point for the path.
   * @return null if there is no such path.
   */
  public List getExtendedBasicBlockPathBetween(Unit from, Unit to) {
    UnitGraph g = this;

    // if this holds, we're doomed to failure!!!
    if (g.getPredsOf(to).size() > 1) return null;

    // pathStack := list of succs lists
    // pathStackIndex := last visited index in pathStack
    LinkedList pathStack = new LinkedList();
    LinkedList pathStackIndex = new LinkedList();

    pathStack.add(from);
    pathStackIndex.add(new Integer(0));

    int psiMax = (g.getSuccsOf((Unit) pathStack.get(0))).size();
    int level = 0;
    while (((Integer) pathStackIndex.get(0)).intValue() != psiMax) {
      int p = ((Integer) (pathStackIndex.get(level))).intValue();

      List succs = g.getSuccsOf((Unit) (pathStack.get(level)));
      if (p >= succs.size()) {
        // no more succs - backtrack to previous level.

        pathStack.remove(level);
        pathStackIndex.remove(level);

        level--;
        int q = ((Integer) pathStackIndex.get(level)).intValue();
        pathStackIndex.set(level, new Integer(q + 1));
        continue;
      }

      Unit betweenUnit = (Unit) (succs.get(p));

      // we win!
      if (betweenUnit == to) {
        pathStack.add(to);
        return pathStack;
      }

      // check preds of betweenUnit to see if we should visit its kids.
      if (g.getPredsOf(betweenUnit).size() > 1) {
        pathStackIndex.set(level, new Integer(p + 1));
        continue;
      }

      // visit kids of betweenUnit.
      level++;
      pathStackIndex.add(new Integer(0));
      pathStack.add(betweenUnit);
    }
    return null;
  }
Example #20
0
 public void deleteKid(Node<K, V> obj) {
   int index = kids.indexOf(obj);
   if (index == 0) {
     guides.remove(index);
     kids.remove(index);
   } else if (index > 0) {
     guides.remove(index - 1);
     kids.remove(index);
   }
   if (isUnderHalfFull()) {
     merge();
   }
 }
Example #21
0
 /**
  * Deplace une piece sans faire de test
  *
  * @param posDepart
  * @param posArrivee
  * @return s'il y a une prise de piece
  */
 public boolean deplacerPiecePourTest(Position posDepart, Position posArrivee) {
   Piece pieceD = null;
   boolean prise = false;
   pieceD = this.getPiecePosition(posDepart);
   piecePourTest = this.getPiecePosition(posArrivee);
   if (piecePourTest != null) {
     prise = true;
     pieceList.remove(piecePourTest);
   }
   pieceD.setPos(posArrivee);
   pieceList.remove(pieceD);
   pieceList.add(pieceD);
   return prise;
 }
 // Consumes a LinkedList of Trains and returns the one with the smallest time
 // for the first element in the list of predictions
 // NF
 public static Train getEarliestTrain(LinkedList<Train> trains, String stopName) {
   // for(int t=0;t<trains.size();t++){
   if (trains.isEmpty()) {
     return null;
   } else if (trains.size() == 1) {
     return trains.get(0);
   } else if (compare(trains.get(0), trains.get(1), stopName)) {
     trains.remove(0);
     return getEarliestTrain(trains, stopName);
   } else {
     trains.remove(1);
     return getEarliestTrain(trains, stopName);
   }
 }
Example #23
0
  /*
   * (non-Javadoc)
   * @see bluej.groupwork.Repository#getAllLocallyDeletedFiles()
   */
  public void getAllLocallyDeletedFiles(Set files) {
    LinkedList stack = new LinkedList();
    stack.add(projectPath);
    Set tempSet = new HashSet();
    FileFilter reposFilter = getMetadataFilter();

    while (!stack.isEmpty()) {
      File dir = (File) stack.remove(0);
      File[] subDirs = dir.listFiles(new DirectoryFilter());
      for (int i = 0; i < subDirs.length; i++) {
        if (reposFilter.accept(subDirs[i])) {
          stack.add(subDirs[i]);
        }
      }
      try {
        getLocallyDeletedFiles(files, dir);
      } catch (IOException ioe) {
      }
    }

    File delDir = new File(projectPath, "CVS");
    delDir = new File(delDir, "deleted");
    if (delDir.exists()) {
      stack.add(delDir);
    }

    while (!stack.isEmpty()) {
      File dir = (File) stack.remove(0);
      File[] subDirs = dir.listFiles(new DirectoryFilter());
      for (int i = 0; i < subDirs.length; i++) {
        if (reposFilter.accept(subDirs[i])) {
          stack.add(subDirs[i]);
        }
      }
      try {
        getLocallyDeletedFiles(tempSet, dir);
        for (Iterator i = tempSet.iterator(); i.hasNext(); ) {
          File file = (File) i.next();
          // map the file back to the real directory
          String fileStr = file.getPath();
          fileStr = fileStr.substring(delDir.getPath().length());
          file = new File(projectPath, fileStr);
          files.add(file);
        }
        tempSet.clear();
      } catch (IOException ioe) {
      }
    }
  }
Example #24
0
 /**
  * Deplacer la piece un coup,
  *
  * @param pieceDepart
  * @param posArrivee
  * @return
  */
 public boolean realiserCoup(Piece pieceDepart, Position posArrivee) {
   if (pieceList.contains(pieceDepart)) {
     pieceList.remove(this.getPiecePosition(posArrivee));
     for (Piece piece : pieceList) {
       if (piece.equals(pieceDepart)) {
         pieceDepart.setPos(posArrivee);
         pieceList.remove(piece);
         pieceList.add(pieceDepart);
         break;
       }
     }
     pieceDepart.setPlayed();
     return true;
   } else return false;
 }
Example #25
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    LinkedList<Integer> pq = new PQueue();
    pq.add(12);
    pq.add(1);
    pq.add(110);
    pq.add(13);
    pq.add(14);
    pq.remove();
    System.out.println("list is empty? " + pq.isEmpty());
    pq.remove();
    System.out.println("Peeking: " + pq.peek());

    System.out.println("Whole list: " + pq);
  }
  /*
   * check to see if hit the limit for max # completed apps kept
   */
  protected synchronized void checkAppNumCompletedLimit() {
    // check apps kept in state store.
    while (completedAppsInStateStore > this.maxCompletedAppsInStateStore) {
      ApplicationId removeId = completedApps.get(completedApps.size() - completedAppsInStateStore);
      RMApp removeApp = rmContext.getRMApps().get(removeId);
      LOG.info(
          "Max number of completed apps kept in state store met:"
              + " maxCompletedAppsInStateStore = "
              + maxCompletedAppsInStateStore
              + ", removing app "
              + removeApp.getApplicationId()
              + " from state store.");
      rmContext.getStateStore().removeApplication(removeApp);
      completedAppsInStateStore--;
    }

    // check apps kept in memorty.
    while (completedApps.size() > this.maxCompletedAppsInMemory) {
      ApplicationId removeId = completedApps.remove();
      LOG.info(
          "Application should be expired, max number of completed apps"
              + " kept in memory met: maxCompletedAppsInMemory = "
              + this.maxCompletedAppsInMemory
              + ", removing app "
              + removeId
              + " from memory: ");
      rmContext.getRMApps().remove(removeId);
      this.applicationACLsManager.removeApplication(removeId);
    }
  }
Example #27
0
 /** Dispose of the photo gracefully, in case we can see some of it. */
 public void fadeAway(final View photo, final boolean replace) {
   // fade out of view
   mOnTable.remove(photo);
   exitStageLeft(photo);
   photo.setOnTouchListener(null);
   photo.animate().cancel();
   photo
       .animate()
       .withLayer()
       .alpha(0f)
       .setDuration(mPickUpDuration)
       .withEndAction(
           new Runnable() {
             @Override
             public void run() {
               if (photo == getFocus()) {
                 clearFocus();
               }
               mStageLeft.removeView(photo);
               recycle(photo);
               if (replace) {
                 scheduleNext(mNowDropDelay);
               }
             }
           });
 }
Example #28
0
 private List<Number> initList(LinkedList<Number> list) {
   list.add(new Double(1000f));
   list.add(new Double("123e-445632"));
   list.add(new Float(-90 / -3));
   list.remove(new Double("123e-445632"));
   return list;
 }
Example #29
0
 // 一个经常使用的函数,当MathSignQueue的一部分由于得出值被化简,则这一部分将被一个具体的实数值替代
 public void simplify(int start, int end, MathSign result) {
   result.setIndex(mMathSigns.get(start).start(), mMathSigns.get(end - 1).end());
   while (end-- > start) {
     mMathSigns.remove(start);
   }
   mMathSigns.add(start, result);
 }
Example #30
0
 /**
  * this method removes the last element of the formula, and returns whether the element removed is
  * an operator or an input:
  *
  * @return true if it is an operator, false otherwise
  * @exception SyntaxErrorException TO COMMENT FURTHER
  */
 public boolean removeFromFormula() throws SyntaxErrorException {
   boolean isOperator = true;
   TreeCell currentCell;
   if (nextEntry == 0) // only one value
   {
     currentCell = opList.get(0);
   } else if ((nextEntry < opList.size())
       && (opList.get(nextEntry).getstatusCell() != TreeCell.NOT_COMPLETED)) {
     currentCell = opList.get(nextEntry);
   } else {
     currentCell = opList.get(nextEntry - 1); // get the current cell that we will be using
   }
   try {
     isOperator = currentCell.removeInCell();
     if (!isOperator) this.removeLeaveTotal();
     if (currentCell.getstatusCell() == TreeCell.NOT_COMPLETED) {
       if (nextEntry > 0) nextEntry--;
       if (nextEntry < opList.size()) opList.remove(currentCell);
     } else if ((currentCell.getstatusCell() == TreeCell.LEFT_COMPLETED))
       nextEntry = this.opList.size();
     else if (nextEntry < opList.size()) {
       nextEntry++;
     }
     return isOperator;
   } catch (SyntaxErrorException e) {
     throw e;
   }
 }