Example #1
0
 public void solve() {
   n = ni();
   m = ni();
   map = new char[n][m];
   for (int i = 0; i < n; i++) {
     map[i] = nwrd().toCharArray();
   }
   boolean use[][] = new boolean[n][m];
   long ans = 0;
   LinkedList<Integer> ls = new LinkedList<Integer>();
   for (int i = 0; i < n; i++) {
     for (int j = 0; j < m; j++) {
       if (map[i][j] == '#') {
         ls.add(i * 10000 + j);
         while (ls.size() != 0) {
           int t = ls.pollFirst();
           int jx = t % 10000;
           int ix = t / 10000;
           use[ix][jx] = true;
           map[ix][jx] = '.';
           for (int k = 0; k < 4; k++) {
             if (is(ix + dx[k], jx + dy[k])
                 && !use[ix + dx[k]][jx + dy[k]]
                 && map[ix + dx[k]][jx + dy[k]] == '#') {
               ls.add((ix + dx[k]) * 10000 + jx + dy[k]);
               use[ix + dx[k]][jx + dy[k]] = true;
             }
           }
         }
         ans++;
       } else use[i][j] = true;
     }
   }
   pw.print(ans);
 }
Example #2
0
  private <T> Collection<T> generatePoints(
      TreeSet<Integer> grids_x,
      TreeSet<Integer> grids_y,
      PointFactory<T> factory,
      boolean collectExtremity)
      throws PointFactory.PFException {

    TreeMap<ViewComponentInfo, Collection<T>> map = new TreeMap<ViewComponentInfo, Collection<T>>();
    ViewComponentInfo hit;
    for (Integer x : grids_x) {
      for (Integer y : grids_y) {
        // System.out.println("("+x+","+y+")");
        hit = this.projectAbsoluteCoordinateRecursively(x, y);
        if (hit != null) {
          // Collection<T> iter = factory.get(x,y,hit);
          map.put(hit, factory.get(x, y, hit));
        }
      }
    }

    LinkedList<T> lst = new LinkedList<T>();
    for (Map.Entry<ViewComponentInfo, Collection<T>> entry : map.entrySet()) {
      for (T t : entry.getValue()) {
        if (collectExtremity) {
          if (entry.getKey().children == null
              || entry.getKey().isCollectionMember
              || entry.getKey().isSpinner
              || entry.getKey().hasOnClickListener()) {
            lst.add(t);
          }
        } else lst.add(t);
      }
    }
    return lst;
  }
Example #3
0
  /**
   * reads faculty list file
   *
   * @return LinkedList<Faculty>
   * @throws FileNotFoundException
   */
  public LinkedList<Faculty> readFacultyList() throws FileNotFoundException {
    FileInputStream fstream = new FileInputStream("facultyList.csv");
    LinkedList<Faculty> facultyList = new LinkedList<Faculty>();
    Scanner input = new Scanner(fstream);
    input.useDelimiter(",");

    try {
      // reads file
      while (input.hasNext()) {
        String firstName = input.next();
        String lastName = input.next();
        String userName = input.next();
        String password = input.next();
        String email = input.next();
        String office = input.next();
        String phoneNumber = input.nextLine();
        // creates faculty member
        Faculty newFaculty =
            new Faculty(userName, password, email, firstName, lastName, office, phoneNumber);

        facultyList.add(newFaculty);
      }
      fstream.close();
    } catch (Exception e) {
      facultyList = null;
    }

    Collections.sort(facultyList);

    return facultyList;
  }
Example #4
0
  /**
   * The read admin list reads in admin objects from a readfile
   *
   * @return
   * @throws FileNotFoundException
   */
  public LinkedList<Admin> readAdminList() throws FileNotFoundException {
    FileInputStream fstream = new FileInputStream("adminList.csv");
    LinkedList<Admin> adminList = new LinkedList<Admin>();
    Scanner input = new Scanner(fstream);
    input.useDelimiter(",");

    try {
      // reads file
      while (input.hasNext()) {
        String firstName = input.next();
        String lastName = input.next();
        String userName = input.next();
        String password = input.next();
        String email = input.next();
        String office = input.next();
        String phoneNumber = input.nextLine();

        // creates admin
        Admin newAdmin =
            new Admin(userName, password, email, firstName, lastName, office, phoneNumber);

        adminList.add(newAdmin);
      }
      fstream.close();
    } catch (Exception e) {
      adminList = null;
    }

    Collections.sort(adminList);

    return adminList;
  }
Example #5
0
  public void outANonstaticInvokeExpr(ANonstaticInvokeExpr node) {
    List args;

    if (node.getArgList() != null) args = (List) mProductions.removeLast();
    else args = new ArrayList();

    SootMethodRef method = (SootMethodRef) mProductions.removeLast();

    String local = (String) mProductions.removeLast();

    Local l = (Local) mLocals.get(local);
    if (l == null) throw new RuntimeException("did not find local: " + local);

    Node invokeType = (Node) node.getNonstaticInvoke();
    Expr invokeExpr;

    if (invokeType instanceof ASpecialNonstaticInvoke) {
      invokeExpr = Jimple.v().newSpecialInvokeExpr(l, method, args);
    } else if (invokeType instanceof AVirtualNonstaticInvoke) {
      invokeExpr = Jimple.v().newVirtualInvokeExpr(l, method, args);
    } else {
      if (debug)
        if (!(invokeType instanceof AInterfaceNonstaticInvoke))
          throw new RuntimeException("expected interface invoke.");
      invokeExpr = Jimple.v().newInterfaceInvokeExpr(l, method, args);
    }

    mProductions.addLast(invokeExpr);
  }
Example #6
0
  public void outALookupswitchStatement(ALookupswitchStatement node) {
    List lookupValues = new ArrayList();
    List targets = new ArrayList();
    UnitBox defaultTarget = null;

    if (node.getCaseStmt() != null) {
      int size = node.getCaseStmt().size();

      for (int i = 0; i < size; i++) {
        Object valueTargetPair = mProductions.removeLast();
        if (valueTargetPair instanceof UnitBox) {
          if (defaultTarget != null)
            throw new RuntimeException("error: can't ;have more than 1 default stmt");

          defaultTarget = (UnitBox) valueTargetPair;
        } else {
          Object[] pair = (Object[]) valueTargetPair;

          lookupValues.add(0, pair[0]);
          targets.add(0, pair[1]);
        }
      }
    } else {
      throw new RuntimeException("error: switch stmt has no case stmts");
    }

    Value key = (Value) mProductions.removeLast();
    Unit switchStmt = Jimple.v().newLookupSwitchStmt(key, lookupValues, targets, defaultTarget);

    mProductions.addLast(switchStmt);
  }
Example #7
0
  public String get_item_ids() {

    String jsonarry;

    try {

      krypton_database_get_my_tokens getxt = new krypton_database_get_my_tokens();

      String token_array[] = new String[network.listing_size];
      token_array = getxt.get_tokens(network.base58_id);

      LinkedList<String> list = new LinkedList<String>();
      for (int loop = 0; loop < token_array.length; loop++) { // ************

        if (!token_array[loop].contains("-")) {
          list.add(token_array[loop]);
        }
      } // *****************************************************************

      jsonarry = JSONValue.toJSONString(list);

    } catch (Exception e) {

      statex = "0";
      jsonarry = "Error";
    } // *****************

    return jsonarry;
  } // *************************************
  /**
   * Run all jobs in the work list (and any children they have) to completion. This method returns
   * <code>true</code> if all jobs were successfully completed. If all jobs were successfully
   * completed, then the worklist will be empty.
   *
   * <p>The scheduling of <code>Job</code>s uses two methods to maintain scheduling invariants:
   * <code>selectJobFromWorklist</code> selects a <code>SourceJob</code> from <code>worklist</code>
   * (a list of jobs that still need to be processed); <code>enforceInvariants</code> is called
   * before a pass is performed on a <code>SourceJob</code> and is responsible for ensuring all
   * dependencies are satisfied before the pass proceeds, i.e. enforcing any scheduling invariants.
   */
  public boolean runToCompletion() {
    boolean okay = true;

    while (okay && !worklist.isEmpty()) {
      SourceJob job = selectJobFromWorklist();

      if (Report.should_report(Report.frontend, 1)) {
        Report.report(1, "Running job " + job);
      }

      okay &= runAllPasses(job);

      if (job.completed()) {
        // the job has finished. Let's remove it from the map so it
        // can be garbage collected, and free up the AST.
        jobs.put(job.source(), COMPLETED_JOB);

        if (Report.should_report(Report.frontend, 1)) {
          Report.report(1, "Completed job " + job);
        }
      } else {
        // the job is not yet completed (although, it really
        // should be...)
        if (Report.should_report(Report.frontend, 1)) {
          Report.report(1, "Failed to complete job " + job);
        }
        worklist.add(job);
      }
    }

    if (Report.should_report(Report.frontend, 1))
      Report.report(1, "Finished all passes -- " + (okay ? "okay" : "failed"));

    return okay;
  }
Example #9
0
 protected Data(Object name) {
   super();
   data = new LinkedList();
   stored = new LinkedList();
   listeners = null;
   String n = "space" + File.separatorChar;
   if (name instanceof String) n += name;
   else n += "H" + Integer.toString(name.hashCode());
   dir = new File(n);
   dir.mkdirs();
   FilenameFilter filter =
       new FilenameFilter() {
         public boolean accept(File f, String name) {
           return name.toUpperCase().startsWith("S");
         }
       };
   File file[] = dir.listFiles(filter);
   Arrays.sort(file);
   for (int i = 0; file.length > i; i++) {
     if (cacheSize > data.size()) {
       Object value = readValue(file[i].getAbsolutePath());
       if (value == null) {
         (new File(file[i].getAbsolutePath())).delete();
       } else {
         stored.add(file[i].getAbsolutePath());
         data.add(value);
       }
     } else stored.add(file[i].getAbsolutePath());
   }
 }
Example #10
0
 protected void add(Object value) {
   File f = null;
   FileOutputStream fos = null;
   try {
     f = createTempFile("S", dir);
     fos = new FileOutputStream(f);
     ObjectOutputStream fout = new ObjectOutputStream(new BufferedOutputStream(fos));
     fout.writeObject(value);
     fout.flush();
     fos.getFD().sync();
   } catch (Exception e) {
     throw new SpaceError(e);
   } finally {
     if (fos != null) {
       try {
         fos.close();
       } catch (Exception e) {
         throw new SpaceError(e);
       }
     }
   }
   stored.add(f.getAbsolutePath());
   /* fill cache */
   if (cacheSize > data.size()) if ((data.size() + 1) == stored.size()) data.add(value);
 }
  /*
   * Similar to makeSureValInRange function except it is meant to return
   * more than one values of valid user input via LinkedList and it will
   * not return unless all of the input is valid
   * @param1 scanner object
   * @param2 lowerbound int
   * @param3 upperbound int
   * @param4 String that represents the entity we are entering the values for
   */
  public static LinkedList<Integer> makeSureValInRange2(
      Scanner scan, int lowerbound, int upperbound, String inputFor) {
    assert (lowerbound <= upperbound);
    LinkedList<Integer> list = new LinkedList<Integer>();
    System.out.println(
        SearchCriteria.prioritySetUpString(
            SearchCriteria.StringEnum.SELECT_CRITERIA, inputFor)); // prints the options to the user
    int value = scan.nextInt();
    if (valInRange(lowerbound, upperbound, value)) {
      list.add(value); // If the first inputted is in range then we add more values

      boolean done = false;
      int i = lowerbound;
      while (!done
          && i < upperbound) { // keep looking for input until user enters a duplicate value
        // or the LinkedList of input is full
        value = scan.nextInt();
        if (!list.contains(value) && valInRange(lowerbound, upperbound, value)) list.add(value);
        else done = true;
        i++;
      }
      return list;
    } else { // If the first value intered is not valid, then we return a null, which means that
      // we use default values (all values within range)
      System.out.println(
          SearchCriteria.prioritySetUpString(SearchCriteria.StringEnum.DEFAULT, inputFor));
      return null;
    }
  }
Example #12
0
 private synchronized void addRRset(Name name, RRset rrset) {
   if (!hasWild && name.isWild()) hasWild = true;
   Object types = data.get(name);
   if (types == null) {
     data.put(name, rrset);
     return;
   }
   int rtype = rrset.getType();
   if (types instanceof List) {
     List list = (List) types;
     for (int i = 0; i < list.size(); i++) {
       RRset set = (RRset) list.get(i);
       if (set.getType() == rtype) {
         list.set(i, rrset);
         return;
       }
     }
     list.add(rrset);
   } else {
     RRset set = (RRset) types;
     if (set.getType() == rtype) data.put(name, rrset);
     else {
       LinkedList list = new LinkedList();
       list.add(set);
       list.add(rrset);
       data.put(name, list);
     }
   }
 }
Example #13
0
  /** Initialise mod hooks */
  private void initHooks() {
    try {
      // Chat hook
      if ((chatListeners.size() > 0 || chatFilters.size() > 0) && !chatHooked) {
        chatHooked = true;
        HookChat.Register();
        HookChat.RegisterPacketHandler(this);
      }

      // Login hook
      if ((preLoginListeners.size() > 0 || loginListeners.size() > 0) && !loginHooked) {
        loginHooked = true;
        ModUtilities.registerPacketOverride(1, HookLogin.class);
        HookLogin.loader = this;
      }

      // Plugin channels hook
      if (pluginChannelListeners.size() > 0 && !pluginChannelHooked) {
        pluginChannelHooked = true;
        HookPluginChannels.Register();
        HookPluginChannels.RegisterPacketHandler(this);
      }

      // Tick hook
      if (!tickHooked) {
        tickHooked = true;
        PrivateFields.minecraftProfiler.SetFinal(minecraft, new HookProfiler(this, logger));
      }
    } catch (Exception ex) {
      logger.log(Level.WARNING, "Error creating hooks", ex);
      ex.printStackTrace();
    }
  }
 @Override
 public synchronized void write(byte[] ba, int str, int len) {
   try {
     curLength += len;
     if (bytesEndWith(ba, str, len, LINE_SEP)) {
       lineLengths.addLast(new Integer(curLength));
       curLength = 0;
       if (lineLengths.size() > maxLines) {
         textArea.replaceRange(null, 0, lineLengths.removeFirst().intValue());
       }
     }
     for (int xa = 0; xa < 10; xa++) {
       try {
         textArea.append(new String(ba, str, len));
         break;
       } catch (
           Throwable
               thr) { // sometimes throws a java.lang.Error: Interrupted attempt to aquire write
                      // lock
         if (xa == 9) {
           thr.printStackTrace();
         }
       }
     }
     textArea.setCaretPosition(textArea.getText().length());
   } catch (Throwable thr) {
     CharArrayWriter caw = new CharArrayWriter();
     thr.printStackTrace(new PrintWriter(caw, true));
     textArea.append(System.getProperty("line.separator", "\n"));
     textArea.append(caw.toString());
   }
 }
 public void addFinishedTarget(Target target) {
   // 向finishedTargets队列中加入一个任务
   synchronized (finishedTargets) {
     finishedTargets.notify();
     finishedTargets.add(target);
   }
 }
 private static <T> Iterator<T> reverse(Iterable<T> values) {
   LinkedList<T> reversed = new LinkedList<>();
   for (T value : values) {
     reversed.add(value);
   }
   return reversed.descendingIterator();
 }
Example #17
0
 private void resolveLocalFileHeaderData(
     final Map<ZipEntry, NameAndComment> entriesWithoutUTF8Flag) throws IOException {
   for (final Entry ze : this.entries) {
     final OffsetEntry offsetEntry = ze.getOffsetEntry();
     final long offset = offsetEntry.headerOffset;
     this.archive.seek(offset + 26L);
     this.archive.readFully(this.SHORT_BUF);
     final int fileNameLen = ZipShort.getValue(this.SHORT_BUF);
     this.archive.readFully(this.SHORT_BUF);
     final int extraFieldLen = ZipShort.getValue(this.SHORT_BUF);
     int skipped;
     for (int lenToSkip = fileNameLen; lenToSkip > 0; lenToSkip -= skipped) {
       skipped = this.archive.skipBytes(lenToSkip);
       if (skipped <= 0) {
         throw new IOException("failed to skip file name in local file header");
       }
     }
     final byte[] localExtraData = new byte[extraFieldLen];
     this.archive.readFully(localExtraData);
     ze.setExtra(localExtraData);
     offsetEntry.dataOffset = offset + 26L + 2L + 2L + fileNameLen + extraFieldLen;
     if (entriesWithoutUTF8Flag.containsKey(ze)) {
       final NameAndComment nc = entriesWithoutUTF8Flag.get(ze);
       ZipUtil.setNameAndCommentFromExtraFields(ze, nc.name, nc.comment);
     }
     final String name = ze.getName();
     LinkedList<ZipEntry> entriesOfThatName = this.nameMap.get(name);
     if (entriesOfThatName == null) {
       entriesOfThatName = new LinkedList<ZipEntry>();
       this.nameMap.put(name, entriesOfThatName);
     }
     entriesOfThatName.addLast(ze);
   }
 }
  public static void main(String[] args) throws FileNotFoundException {
    // Step 0: Initialize everything needed
    Scanner userinput = new Scanner(System.in);
    System.out.println("What is the name of the input file: ");
    String fileinput = userinput.nextLine();

    try {
      Scanner firstreading = new Scanner(new FileReader(fileinput));

      // Step 1: Create a Linked List with a dummy Node
      LinkedList wordlist = new LinkedList();

      while (firstreading.hasNext()) {
        // Step 2: Obtain data from data file
        wordlist.insert(firstreading.next());
      }

      wordlist.listPrint();

    } catch (FileNotFoundException e) {
      System.out.println("File not found!");
    }

    System.out.println();
  }
 // Test method
 public LinkedList<Integer> getLiveAuctionsIds() throws RemoteException {
   LinkedList<Integer> ll = new LinkedList<Integer>();
   for (AuctionItem t : liveAuctionItems.values()) {
     ll.add(t.getAuctionId());
   }
   return ll;
 }
Example #20
0
 public void outAFullIdentNonvoidType(AFullIdentNonvoidType node) {
   String typeName = (String) mProductions.removeLast();
   Type t = RefType.v(typeName);
   int dim = node.getArrayBrackets().size();
   if (dim > 0) t = ArrayType.v(t, dim);
   mProductions.addLast(t);
 }
Example #21
0
  public static String writeChemkinPdepReactions(ReactionSystem rs) {
    // #[ operation writeChemkinReactions(ReactionModel)

    StringBuilder result = new StringBuilder();
    result.append("REACTIONS	KCAL/MOLE\n");

    LinkedList rList = new LinkedList();
    LinkedList troeList = new LinkedList();
    LinkedList tbrList = new LinkedList();
    LinkedList duplicates = new LinkedList();
    LinkedList lindeList = new LinkedList();

    if (rs.dynamicSimulator instanceof JDASPK) {
      rList = ((JDASPK) rs.dynamicSimulator).rList;
      troeList = ((JDASPK) rs.dynamicSimulator).troeList;
      tbrList = ((JDASPK) rs.dynamicSimulator).thirdBodyList;
      duplicates = ((JDASPK) rs.dynamicSimulator).duplicates;
      lindeList = ((JDASPK) rs.dynamicSimulator).lindemannList;
    } else if (rs.dynamicSimulator instanceof JDASSL) {
      rList = ((JDASSL) rs.dynamicSimulator).rList;
      troeList = ((JDASSL) rs.dynamicSimulator).troeList;
      tbrList = ((JDASSL) rs.dynamicSimulator).thirdBodyList;
      duplicates = ((JDASSL) rs.dynamicSimulator).duplicates;
      lindeList = ((JDASSL) rs.dynamicSimulator).lindemannList;
    }

    for (Iterator iter = rList.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      // 10/26/07 gmagoon: changed to avoid use of Global.temperature; I am using
      // getPresentTemperature for the time being; it is possible that
      // getInitialStatus.getTemperature or something similar may be more appropriate
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n");
      // result.append(r.toChemkinString(Global.temperature)+"\n");
    }
    for (Iterator iter = troeList.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n");
      // result.append(r.toChemkinString(Global.temperature)+"\n");
    }
    for (Iterator iter = tbrList.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n");
      // result.append(r.toChemkinString(Global.temperature)+"\n");
    }
    for (Iterator iter = duplicates.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n\tDUP\n");
      // result.append(r.toChemkinString(Global.temperature)+"\n\tDUP\n");
    }
    for (Iterator iter = lindeList.iterator(); iter.hasNext(); ) {
      Reaction r = (Reaction) iter.next();
      result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n");
    }

    result.append("END\n");

    return result.toString();

    // #]
  }
Example #22
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;
    }
Example #23
0
  public static int close() {
    int count = 0;

    Iterator iterator = m_notUsedConnection.iterator();
    while (iterator.hasNext()) {
      try {
        ((ConnectionWrapper) iterator.next()).close();
        count++;
      } catch (Exception e) {
      }
    }
    m_notUsedConnection.clear();

    iterator = m_usedUsedConnection.iterator();
    while (iterator.hasNext()) {
      try {
        ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next();
        wrapper.close();
        if (DEBUG) {
          wrapper.debugInfo.printStackTrace();
        }
        count++;
      } catch (Exception e) {
      }
    }
    m_usedUsedConnection.clear();

    return count;
  }
Example #24
0
  /**
   * On créé le paquet de cartes Kokus
   *
   * @return
   */
  public LinkedList<Kokus> initialisationPaquetKokus() {
    LinkedList<Kokus> llk = new LinkedList<Kokus>();

    for (Kokus k : this.hashKokus) {
      // 12 cartes kokus de 1 unité
      if (k.getNbkoku() == 1) {
        for (int i = 0; i < 12; i++) {
          llk.add(k);
        }
      }

      // 8 cartes kokus de 2 unités
      if (k.getNbkoku() == 2) {
        for (int i = 0; i < 8; i++) {
          llk.add(k);
        }
      }

      // 4 cartes kokus de 3 unités
      if (k.getNbkoku() == 3) {
        for (int i = 0; i < 4; i++) {
          llk.add(k);
        }
      }
    }
    Collections.shuffle(llk);

    return llk;
  }
Example #25
0
  public static void maxFlow(ListGraph g) {
    ListGraph residualG = g.residualGraph();

    LinkedList<DirEdge> path = residualG.getFlowPath();
    while (path != null) {
      // System.out.println("Got path");
      int minCapacity = ListGraph.minCapacityInPath(path);

      assert minCapacity > 0;
      // augment every edge on the path in the original graph
      int head = g.getSource();
      ListIterator it = path.listIterator();
      while (it.hasNext()) {
        DirEdge rEdge = (DirEdge) it.next();
        int tail = rEdge.end;

        DirEdge e = g.getEdge(head, tail);
        e.flow += minCapacity;

        // System.out.println("Augmenting (" + head + "," + tail + ") to be " + e.flow);

        head = tail;
      }

      residualG = g.residualGraph();

      // System.out.println("g:");
      // g.print();

      // System.out.println("Residual graph:");
      // residualG.print();

      path = residualG.getFlowPath();
    }
  }
Example #26
0
  /**
   * On créé la paquet de carte Troupes
   *
   * @return
   */
  public LinkedList<CarteTroupe> initialisationPaquetTroupe() {
    LinkedList<CarteTroupe> llct = new LinkedList<CarteTroupe>();
    int i = 1;

    for (Troupes t : hashTroupes) {
      CarteTroupe ct = new CarteTroupe(t);
      // On met 6 fois la même carte dans la liste
      for (int k = 0; k < 6; k++) {
        llct.add(ct);
      }
      // il faut également mettre un carte avec deux troupes (en tout 6 cartes)
      int j = 1;
      for (Troupes t2 : hashTroupes) {
        // On ne reprend pas les cartes précédentes (elles ont déjà ét traitées)
        if (i == j || i < j) {
          CarteTroupe ct2 = new CarteTroupe(t, t2);
          llct.add(ct2);
        }
        j++;
      }
      i++;
    }
    // On mélange le paquet
    Collections.shuffle(llct);

    return llct;
  }
Example #27
0
  public void outALocalImmediate(ALocalImmediate node) {
    String local = (String) mProductions.removeLast();

    Local l = (Local) mLocals.get(local);
    if (l == null) throw new RuntimeException("did not find local: " + local);
    mProductions.addLast(l);
  }
Example #28
0
  public void outAInvokeStatement(AInvokeStatement node) {
    Value op = (Value) mProductions.removeLast();

    Unit u = Jimple.v().newInvokeStmt(op);

    mProductions.addLast(u);
  }
Example #29
0
  public void outAAssignStatement(AAssignStatement node) {
    Value rvalue = (Value) mProductions.removeLast();
    Value variable = (Value) mProductions.removeLast();

    Unit u = Jimple.v().newAssignStmt(variable, rvalue);
    mProductions.addLast(u);
  }
Example #30
0
  public void outAIdentityNoTypeStatement(AIdentityNoTypeStatement node) {
    mProductions.removeLast(); // get rid of @caughtexception string presently on top of the stack
    Value local =
        (Value) mLocals.get(mProductions.removeLast()); // the local ref from it's identifier

    Unit u = Jimple.v().newIdentityStmt(local, Jimple.v().newCaughtExceptionRef());
    mProductions.addLast(u);
  }