public void tick() {
    To4ka nOVApoZiciqTo4ka =
        new To4ka(
            (zmiiskoTqlo.get(0).daiXiksa() + velocityX),
            (zmiiskoTqlo.get(0).daiIgreka() + velocityY));

    if (nOVApoZiciqTo4ka.daiXiksa() > Igr1t1.WIDTH - 20) {
      Igr1t1.gameRunning = false;
    } else if (nOVApoZiciqTo4ka.daiXiksa() < 0) {
      Igr1t1.gameRunning = false;
    } else if (nOVApoZiciqTo4ka.daiIgreka() < 0) {
      Igr1t1.gameRunning = false;
    } else if (nOVApoZiciqTo4ka.daiIgreka() > Igr1t1.height - 20) {
      Igr1t1.gameRunning = false;
    } else if (Igr1t1.apalkata.daiTo4ka().equals(nOVApoZiciqTo4ka)) {
      zmiiskoTqlo.add(Igr1t1.apalkata.daiTo4ka());
      Igr1t1.apalkata = new Qbalkata(this);
      Igr1t1.to4ki += 50;
    } else if (zmiiskoTqlo.contains(nOVApoZiciqTo4ka)) {
      Igr1t1.gameRunning = false;
      System.out.println("You ate yourself");
    }

    for (int i = zmiiskoTqlo.size() - 1; i > 0; i--) {
      zmiiskoTqlo.set(i, new To4ka(zmiiskoTqlo.get(i - 1)));
    }
    zmiiskoTqlo.set(0, nOVApoZiciqTo4ka);
  }
  public void tick() {
    Point newPoint =
        new Point((snakeBody.get(0).getX() + velocityX), (snakeBody.get(0).getY() + velocityY));

    if (newPoint.getX() > Game.WIDTH - 20) {
      Game.gameRunning = false;
    } else if (newPoint.getX() < 0) {
      Game.gameRunning = false;
    } else if (newPoint.getY() < 0) {
      Game.gameRunning = false;
    } else if (newPoint.getY() > Game.HEIGHT - 20) {
      Game.gameRunning = false;
    } else if (Game.apple.getPoint().equals(newPoint)) {
      snakeBody.add(Game.apple.getPoint());
      Game.apple = new Apple(this);
      Game.points += 50;
    } else if (snakeBody.contains(newPoint)) {
      Game.gameRunning = false;
      System.out.println("You ate yourself");
    }

    for (int i = snakeBody.size() - 1; i > 0; i--) {
      snakeBody.set(i, new Point(snakeBody.get(i - 1)));
    }
    snakeBody.set(0, newPoint);
  }
  // Given n intervals [si, fi] find the maximum number of overlapping intervals...
  public LinkedList<Integer> reverse(LinkedList<Integer> intervalList) {

    int centre = (intervalList.size()) / 2;

    for (int i = 0; i < centre; i++) {
      intervalList.set(i, intervalList.set(intervalList.size() - 1 - i, intervalList.get(i)));
    }

    return intervalList;
  }
示例#4
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;
  }
示例#5
0
 void moveNode(int dragNode, LatLon coor) {
   LatLon dragged = points.get(dragNode);
   // points.getLast().equals(points.getFirst()
   if (closedFlag && points.getFirst().equals(dragged)) {
     // move both ends
     points.set(0, coor);
     points.set(points.size() - 1, coor);
   } else {
     points.set(dragNode, coor);
   }
   if (fixed.contains(dragged)) {
     fixed.remove(dragged);
     fixed.add(coor);
   }
 }
示例#6
0
  @Override
  public ResultSet apply(ResultSet pResultSet) {
    TableMetadata tableMetadata = pResultSet.getTableMetadata();

    LinkedList<String> tmp = new LinkedList<String>();

    for (int x = 0; x < tableMetadata.getTableColumns().size(); x++) {
      tmp.add("null");
    }

    LinkedList<Integer> colIndex = new LinkedList<>();
    LinkedList<Integer> colNull = new LinkedList<>();

    Iterator<String> i = this._Columns.iterator();

    String col;

    while (i.hasNext()) {
      col = i.next();
      int indexOfColumn = tableMetadata.indexByName(col);
      System.out.println(indexOfColumn);
      colIndex.add(indexOfColumn);
    }

    for (int c = 0; c < tableMetadata.getTableColumns().size(); c++) {
      System.out.println("concha");
      if (!colIndex.contains(c)) {
        System.out.println("culo");
        colNull.add(c);
      }
    }

    for (int j = 0; j < this._Values.size(); j++) {
      System.out.println("pene");
      tmp.set(colIndex.get(j), this._Values.get(j));
    }

    for (int k = 0; k < colNull.size(); k++) {
      System.out.println("astro");
      tmp.set(colNull.get(k), "null");
    }
    TableRegister tr = new TableRegister(tmp);
    LinkedList<TableRegister> list = new LinkedList<TableRegister>();
    list.add(tr);
    TableData t = new TableData(list);

    return (new ResultSet(t, tableMetadata));
  }
示例#7
0
  /** 测试从AbstractSequentialList中继承的方法 */
  private static void testLinkedListFromASL() {
    System.out.println(
        "Test methods: add(), addAll(Collection<?> extends E c), get(int index), set(int index, E e), remove(int index), clear(), clone()");

    // 将"a", "b"添加到list中
    LinkedList<String> list = new LinkedList<String>();
    list.add("a");
    list.add("b");
    printList(list);

    // 将含有"c", "d"的集合list2添加到list中
    LinkedList<String> list2 = new LinkedList<String>();
    list2.add("c");
    list2.add("d");
    list.addAll(list.size(), list2);
    printList(list);

    // 将list中的最后一个元素设置成第一个元素
    list.set(list.size() - 1, list.get(0)); // list.set(index, e)、list.get(index)都不推荐使用!
    printList(list);

    // 将第一个"a"元素从list中移除
    list.remove(list.indexOf("a"));
    printList(list);

    // 将list克隆一份
    LinkedList<String> cloneList = (LinkedList<String>) list.clone();
    printList(cloneList);

    // 将list中元素清除
    list.clear();
    System.out.println("list elements : " + list + " list size : " + list.size());
  }
示例#8
0
 public void modifyCD(int id, int price, String name, double capacity) {
   CompactDisk temp = (CompactDisk) compactDisks.get(id);
   temp.setPrice(price);
   temp.setName(name);
   temp.setCapacity(capacity);
   compactDisks.set(id, temp);
 }
示例#9
0
  private boolean addItem(LinkedList<ItemInfo> items, ItemInfo itemInfo) {
    boolean added = false;

    int idx = items.indexOf(itemInfo);
    if (idx != -1) {
      // HACK: Always swap existing ItemInfos with our new one, since it will
      // more up-to-date information
      ItemInfo existing = items.set(idx, itemInfo);
      assert (existing != null);
      return (true);
    }
    if (itemInfo.hasCurrentPrice())
      assert (itemInfo.getCurrentPrice() > 0) : "Negative current price for " + itemInfo;

    // If we have room, shove it right in
    // We'll throw it in the back because we know it hasn't been used yet
    if (items.size() < AuctionMarkConstants.ITEM_ID_CACHE_SIZE) {
      items.addLast(itemInfo);
      added = true;

      // Otherwise, we can will randomly decide whether to pop one out
    } else if (this.rng.nextBoolean()) {
      items.pop();
      items.addLast(itemInfo);
      added = true;
    }
    return (added);
  }
示例#10
0
 public void modifyFurniture(int id, int price, String name, String color) {
   Furniture temp = (Furniture) furnitures.get(id);
   temp.setPrice(price);
   temp.setName(name);
   temp.setColor(color);
   furnitures.set(id, temp);
 }
  /**
   * Removes the specified module from the registry AND the simulation bus.
   *
   * @param index Index of the module to be removed.
   * @param sim Simulation core that is being run.
   */
  public int removeModule(int index) {
    if (index >= modules.size() || index < 0) {
      return Msg.E("removeModule: invalid index:" + index, Constants.PLP_GENERIC_ERROR, null);
    }

    plp.sim.bus.remove(positionInBus.get(index));
    positionInBus.remove(index);

    if (modules.get(index).threaded && modules.get(index).isAlive()) {
      modules.get(index).stop = true;
    }

    modules.get(index).remove();
    modules.remove(index);
    regSize.remove(index);
    type.remove(index);

    if (moduleFrames.get(index) != null && moduleFrames.get(index) instanceof JFrame)
      ((JFrame) moduleFrames.get(index)).dispose();

    moduleFrames.remove(index);

    // we have to update bus positions
    for (int i = index; i < positionInBus.size(); i++) {
      Integer val = positionInBus.get(i);
      positionInBus.set(i, val - 1);
    }

    return Constants.PLP_OK;
  }
示例#12
0
 private void recargarListaAvance() {
   tblAvance.removeAllItems();
   for (int i = 0; i < listaAvance.size(); i++) {
     LinkedList<Object> avance = listaAvance.get(i);
     avance.set(0, i + 1);
     tblAvance.addItem(avance.toArray(), null);
   }
 }
示例#13
0
 public void modifyCar(int id, int price, String name, int model, String color) {
   Car temp = (Car) cars.get(id);
   temp.setPrice(price);
   temp.setName(name);
   temp.setModel(model);
   temp.setColor(color);
   cars.set(id, temp);
 }
示例#14
0
 public void buttonAcOutletOffHandler(View target) {
   if (mSerialIoManager != null) {
     HanDevice hd = mHanDeviceLinkedList.get(2);
     hd.setWaitOnOff(false);
     mHanDeviceLinkedList.set(2, hd);
     sendPacket(RawData.CMBS_EV_DSR_HAN_MSG_RECV_AC_OUTLET_OFF);
   }
 }
示例#15
0
  /** Execute the command. */
  private Process startProcess(LinkedList<String> pArgs) throws IOException, InterruptedException {

    // if a global or per object search path is set, resolve the
    // the executable

    if (iSearchPath != null) {
      String cmd = pArgs.getFirst();
      cmd = searchForCmd(cmd, iSearchPath);
      pArgs.set(0, cmd);
    } else if (iGlobalSearchPath != null) {
      String cmd = pArgs.getFirst();
      cmd = searchForCmd(cmd, iGlobalSearchPath);
      pArgs.set(0, cmd);
    }
    ProcessBuilder builder = new ProcessBuilder(pArgs);
    return builder.start();
  }
 /**
  * Generate midis.
  *
  * @param struct the struct
  * @return the linked list
  */
 private static LinkedList<Double> generateMidis(CustomChord struct) {
   LinkedList<Double> values = new LinkedList<>();
   int prime = getLowest();
   values.add((double) prime);
   for (Interval in : struct.getStructure()) {
     values.add((double) (prime + in.getJfugueRep()));
   }
   if (struct.hasInversions()) {
     for (int i = 0; i < struct.getInversion().getIndex(); i++) {
       values.set(i, values.get(i) + 12);
     }
   }
   Collections.sort(values);
   double shift = prime - values.get(0);
   for (int i = 0; i < values.size(); i++) values.set(i, values.get(i) + shift);
   return values;
 }
示例#17
0
 public void buttonResetHandler(View target) {
   for (int i = 0; i < mHanDeviceLinkedList.size(); i++) {
     HanDevice hd = mHanDeviceLinkedList.get(i);
     hd.resetCnt();
     mHanDeviceLinkedList.set(i, hd);
   }
   updateHanDeviceTable();
 }
示例#18
0
  @Test
  public void isValid_test() {
    StarcraftAction spyAction = Mockito.spy(action);

    when(spyAction.getUnitType("Zerg Hydralisk")).thenReturn(unitType);

    params.removeLast();
    assertTrue(spyAction.isValid(act));
    params.add(new Numeral(2));

    assertFalse(action.isValid(act));
    params.remove(1);
    assertFalse(action.isValid(act));
    params.set(0, new Numeral(1));
    assertFalse(action.isValid(act));
    params.set(0, new Identifier("Hero Mojo"));
    assertFalse(action.isValid(act));
  }
示例#19
0
 public String createNewPowerupPacket() {
   String packet = "";
   LinkedList<Short> nextPowerups = (LinkedList) this.nextPowerups;
   for (int i = 0; i < nextPowerups.size(); i++) {
     Short powerUp = nextPowerups.get(i);
     if (powerUp != null && markedForTransmit(powerUp)) {
       packet += ServerBombiGui.POWERUP + (powerUp & TILE) + "\n";
       nextPowerups.set(i, unmarkForTransmit(powerUp));
     }
   }
   return packet;
 }
 public void add(String id, MergerEntry e) {
   if (!ids.containsKey(id)) throw new RuntimeException("Unknown id " + id);
   if (latestInputTs.get(ids.get(id)) != -1 && latestInputTs.get(ids.get(id)) > e.getTs())
     throw new RuntimeException(
         mergerId
             + " cannot add entry "
             + e
             + " from id "
             + id
             + ": decreasing timestamp! (latest entry: "
             + queues.get(ids.get(id)).peek()
             + ")");
   queues.get(ids.get(id)).add(e);
   latestInputTs.set(ids.get(id), e.getTs());
 }
示例#21
0
 public Object set(Object _index, Object _value) throws RuntimeErrorException {
   int index = -1;
   if (_index instanceof Numeric) {
     index = (int) Math.round((Double) ((Numeric) _index).getNativeValue());
   } else {
     interpreter.runtimeError(
         "OBJECT ARRAY::set>> Index must be type Numeric [" + _index.getClass() + "]",
         line_number);
   }
   if (index >= 0 && index < value.size()) {
     return value.set(index, _value);
   } else {
     interpreter.runtimeError(
         "OBJECT ARRAY::set>> Index out of range [" + index + "]", line_number);
   }
   return null;
 }
示例#22
0
  public LinkedList<Point> findKnearests2origin(ArrayList<Point> input, int K) {
    // Point p = new Point();
    LinkedList<Point> result = new LinkedList<Point>(); // use linkedlist to store the result
    Iterator<Point> it = input.iterator();
    while (it.hasNext()) {
      Point p = it.next();
      p.distance = Math.sqrt(p.x * p.x + p.y * p.y);

      for (int i = 0; i < result.size(); i++) {
        if (p.distance < result.get(i).distance) result.set(i, p);
      }
      if (result.size() > K) {
        result.removeLast();
      }
    }
    return result;
  }
示例#23
0
  /**
   * Converts Globus DN format "/O=C/OU=B/CN=A" into an X500Principal representation, which accepts
   * RFC 2253 or 1779 formatted DN's and also attribute types as defined in RFC 2459 (e.g.
   * "CN=A,OU=B,O=C"). This method should allow the forward slash, "/", to occur in attribute values
   * (see GFD.125 section 3.2.2 -- RFC 2252 allows "/" in PrintableStrings).
   *
   * @param globusID DN in Globus format
   * @return the X500Principal representation of the given DN
   */
  public static X500Principal toPrincipal(String globusID) {

    if (globusID == null) {
      return null;
    }
    String id = globusID.trim();
    StringTokenizer tokens = new StringTokenizer(id, "/");
    StringBuffer buf = new StringBuffer();
    String token;
    LinkedList<String> rdnList = new LinkedList<String>();

    while (tokens.hasMoreTokens()) {
      token = tokens.nextToken().trim();

      if (token.contains("=")) {
        // prepend an RDN type and at least part of its value
        rdnList.addFirst(token);
      } else {
        // insert part of an RDN value that was mistakenly removed
        // as a result of tokenizing on forward slash
        rdnList.set(0, rdnList.get(0) + "/" + token);
      }
    }

    for (String rdn : rdnList) {
      buf.append(",");
      buf.append(rdn);
    }

    if (buf.length() > 0) {
      // delete extra comma
      buf.deleteCharAt(0);
    }

    String dn = buf.toString();

    return new X500Principal(dn);
  }
示例#24
0
  private void findWinners(Integer pot, Table tab) {
    winnersCount = 0;
    initWinnersFalse(tab);
    int maxRank = 79000;
    int plRank;
    int plBet;
    for (int i = 0; i < tab.countPlayers(); i++) {
      plBet = tab.getSystemPlayer(i).getPlayerBet();
      plRank = cardRanks.get(i);

      if (plBet >= sumByPotsPerGamer(pot)) {
        if (plRank < maxRank) {
          maxRank = plRank;
        }
      }
    }

    for (int i = 0; i < tab.countPlayers(); i++) {
      if (cardRanks.get(i) == maxRank) {
        winnersCount += 1;
        winners.set(i, true);
      }
    }
  }
示例#25
0
 /**
  * Die Methode führt die Kontextanalyse für die aktuellen Parameter durch. (falls notwendig) Hier
  * wird geprueft, ob die aktuelle Parameter zu den formalen Parametern passen.
  *
  * @param declarations Die an dieser Stelle gültigen Deklarationen.
  * @throws CompileException Während der Kontextanylyse wurde ein Fehler gefunden.
  */
 void contextAnalysisForParameters(Declarations declarations) throws CompileException {
   if (identifier.declaration instanceof MethodDeclaration) {
     MethodDeclaration method = (MethodDeclaration) identifier.declaration;
     LinkedList<VarDeclaration> mdecl = method.params;
     // zu viele Parameter angegeben?
     if (params.size() > mdecl.size()) {
       throw new CompileException("Zu viele Parameter", position);
     }
     // zu wenige Parameter angegeben?
     if (params.size() < mdecl.size()) {
       throw new CompileException("Zu wenige Parameter", position);
     }
     // stimmt der Typ der Parameter?
     for (int p = 0; p < mdecl.size(); p++) {
       Expression v = params.get(p);
       v = v.contextAnalysis(declarations);
       // boxen/dereferenzieren
       v = v.box(declarations);
       params.set(p, v);
       ClassDeclaration mtype = (ClassDeclaration) mdecl.get(p).type.declaration;
       v.type.check(mtype, v.position);
     }
   }
 }
示例#26
0
 @Test
 public void execute_test() {
   params.set(0, new Identifier("null"));
   action.execute(unit, act);
   verify(unit).morph(null);
 }
示例#27
0
 /**
  * Add an edge along this line. Overlapping edges are merged.
  *
  * @param e1 The first edge end
  * @param e2 The second edge end
  */
 public void add(int e1, int e2) {
   // sort the ends
   int min = (e1 < e2) ? e1 : e2;
   e2 = (e1 > e2) ? e1 : e2;
   e1 = min;
   // state of the current segment end : first end or last end of the
   // current segment
   boolean first = true;
   boolean inMerge = false;
   for (int i = 0; i < edges.size(); ++i) {
     int end = edges.get(i).intValue();
     // wait till newsegment match this interval in edges list order
     if (e1 > end) {
       first = !first;
       continue;
     }
     // now e1<=end. Handle case where end is the first segment end
     if (first) {
       // If not already merging, see if merging is necessary
       if (!inMerge) {
         // segments overlap => extend existing segment to match
         // the new one
         if (end <= e2) {
           edges.set(i, new Integer(e1));
           inMerge = true; // now merging the new segment
         } else {
           // Segments do not overlap => add a new segment,
           // finished
           edges.add(i, new Integer(e2)); // insert e2 before
           // the current end
           edges.add(i, new Integer(e1)); // insert e1 before
           // e2
           return;
         }
         // In merge already => it normal that e1<=end. Let's
         // check e2
       } else {
         // new segment terminates before current segment
         // => add the new point, finished
         if (e2 < end) {
           edges.add(i, new Integer(e2));
           return;
           // new segment terminates after or inside current
           // segment => merge this end
         } else if (e2 >= end) {
           // remove this end, as the segments merge to make
           // one bigger segment
           edges.remove(i--); // remove corresponding index too
         }
       }
     }
     // Handle second case : end is the last end of the segment.
     // Note: e1<=end, see above
     else {
       // new segment terminates inside current one
       // => end of the merge, keep this segment's end
       if (e2 <= end) return;
       // New segment terminates strictly after current segment
       // remove this end, as the segments merge to make one bigger
       // segment
       edges.remove(i--); // remove corresponding index too
       // If not already merging, this is necessary
       inMerge = true; // now merging the new segment
     }
     first = !first;
   }
   // Still here? => new segment terminates after any existing segment
   // If not merging, must add the first end of the new segment since
   // it was larger than all existing segment ends
   if (!inMerge) edges.add(new Integer(e1));
   // Close the new segment
   edges.add(new Integer(e2));
 }
  public void atmintiesSunaudojimoTyrimas() {
    memDifference("Pradinis kodas");
    // pradžioje užkraunamos tiriamos klasės
    byte[] b = new byte[2];
    int[] k = new int[2];
    Integer[] j = new Integer[2];
    String[] s = new String[2];
    LinkedList<Integer> x = new LinkedList<Integer>();
    LinkedList<String> y = new LinkedList<String>();
    y.add(new String("abc6789"));

    ArrayList<Integer> a = new ArrayList<Integer>();
    a.add(11);
    memDifference("Klasių užkrovimas");
    memDifference("Klasių užkrovimas");
    memDifference("Klasių užkrovimas");
    // tyrimas prasideda nuo čia
    byte[] b1 = new byte[1000]; // byte
    memDifference("byte[] b1=new byte[1000];");
    byte[] b2 = new byte[1000];
    memDifference("byte[] b2=new byte[1000];");
    byte[] b3 = new byte[1000];
    memDifference("byte[] b3=new byte[1000];");
    int[] k1 = new int[1000];
    memDifference("int[] k1=new int[1000];"); // int
    int[] k2 = new int[1000];
    memDifference("int[] k2=new int[1000];");
    int[] k3 = new int[1000];
    memDifference("int[] k3=new int[1000];");
    Integer[] j1 = new Integer[1000]; // Integer
    memDifference("Integer[] j1= new Integer[1000];");
    Integer[] j2 = new Integer[1000];
    memDifference("Integer[] j2= new Integer[1000];");
    Integer[] j3 = new Integer[1000];
    memDifference("Integer[] j3= new Integer[1000];");
    for (int i = 0; i < 1000; i++) {
      j1[i] = new Integer(i);
    }
    memDifference("for (int i=0;i<1000;) j1[i]= new Integer(i);");
    for (int i = 0; i < 1000; i++) {
      j2[i] = new Integer(i);
    }
    memDifference("for (int i=0;i<1000;) j2[i]= new Integer(i);");
    for (int i = 0; i < 1000; i++) {
      j3[i] = new Integer(i);
    }
    memDifference("for (int i=0;i<1000;) j3[i]= new Integer(i);");
    String[] s1 = new String[1000]; // String
    memDifference("String[] j1= new String[1000];");
    String[] s2 = new String[1000];
    memDifference("String[] j2= new String[1000];");
    String[] s3 = new String[1000];
    memDifference("String[] j3= new String[1000];");
    for (int i = 0; i < 1000; i++) {
      s1[i] = new String("abc");
    }
    memDifference("for (int i=0;i<1000;) j1[i]= new String(abc);");
    for (int i = 0; i < 1000; i++) {
      s2[i] = new String("abc" + i);
    }
    memDifference("for (int i=0;i<1000;) j2[i]= new String(abc+i);");
    for (int i = 0; i < 1000; i++) {
      s3[i] = new String("abc" + i + 7000);
    }
    memDifference("for (int i=0;i<1000;) j3[i]= new String(i+7000);");

    LinkedList<Integer> r = new LinkedList<Integer>();
    for (int i = 0; i < 1000; i++) {
      r.add(null);
    }
    memDifference("new LinkedList<Integer>(1000*null);");
    for (int i = 0; i < 1000; i++) {
      r.set(i, new Integer(i));
    }
    memDifference("new LinkedList<Integer>(1000*Integer);");
    ArrayList<Integer> a1 = new ArrayList<Integer>(1000);
    memDifference("ArrayList<Integer> a1= new ArrayList<Integer>(1000);");
    ArrayList<String> a2 = new ArrayList<String>(1000);
    memDifference("ArrayList<String> a2= new ArrayList<String>(1000);");
  }
  public static LinkedList<String> alignTags(
      LinkedList<String> input, boolean minecraftChatFormat) {
    for (String fm : new String[] {"l", "r", "c"}) {
      while (input.get(1).contains("<" + fm)) {
        char repl = ' ';
        if (input
            .get(1)
            .matches("^.*<" + fm + ".>.*$")) { // || input.get(1).matches("^.*<r.>.*$")) {
          repl =
              input
                  .get(1)
                  .substring(input.get(1).indexOf("<" + fm) + 2)
                  .charAt(0); // , input.get(1).indexOf(">")
          for (int i = 0; i < input.size(); ++i) {
            input.set(i, input.get(i).replaceFirst("<" + fm + ".>", "<" + fm + ">"));
          }
        }

        int maxPos = 0;
        for (int i = 1; i < input.size(); ++i) {
          if (input.get(i).indexOf("<" + fm + ">") > maxPos) {
            maxPos = input.get(i).indexOf("<" + fm + ">");
          }
        }

        LinkedList<String> newinput = new LinkedList<String>();
        for (int i = 0; i < input.size(); ++i) {
          String line = input.get(i);
          if (line.indexOf("<" + fm + ">") != -1) {
            if (fm.equals("l")) {
              if (minecraftChatFormat) {
                newinput.add(
                    JMinecraftFontWidthCalculator.strPadRight(
                            line.substring(0, line.indexOf("<" + fm + ">")), maxPos, repl)
                        + line.substring(line.indexOf("<" + fm + ">") + 3));
              } else {
                newinput.add(
                    JMinecraftFontWidthCalculator.unformattedPadRight(
                            line.substring(0, line.indexOf("<" + fm + ">")), maxPos, repl)
                        + line.substring(line.indexOf("<" + fm + ">") + 3));
              }
            } else if (fm.equals("c")) {
              if (minecraftChatFormat) {
                newinput.add(
                    JMinecraftFontWidthCalculator.strPadCenter(
                            line.substring(0, line.indexOf("<" + fm + ">")), maxPos, repl)
                        + line.substring(line.indexOf("<" + fm + ">") + 3));
              } else {
                newinput.add(
                    JMinecraftFontWidthCalculator.unformattedPadCenter(
                            line.substring(0, line.indexOf("<" + fm + ">")), maxPos, repl)
                        + line.substring(line.indexOf("<" + fm + ">") + 3));
              }
            } else {
              if (minecraftChatFormat) {
                newinput.add(
                    JMinecraftFontWidthCalculator.strPadLeft(
                            line.substring(0, line.indexOf("<" + fm + ">")), maxPos, repl)
                        + line.substring(line.indexOf("<" + fm + ">") + 3));
              } else {
                newinput.add(
                    JMinecraftFontWidthCalculator.unformattedPadLeft(
                            line.substring(0, line.indexOf("<" + fm + ">")), maxPos, repl)
                        + line.substring(line.indexOf("<" + fm + ">") + 3));
              }
            }
          } else {
            newinput.add(line);
          }
        }
        input = newinput;
      }
    }
    return input;
  }
示例#30
0
 private void falseWinners() {
   for (int i = 0; i < winners.size(); i++) {
     winners.set(i, false);
   }
 }