示例#1
1
  private void watchOpenedTCs() {
    ArrayList<TopComponent> windowsToWatch = findShowingTCs();
    ArrayList<TopComponent> toAddListeners = new ArrayList<>(windowsToWatch);
    toAddListeners.removeAll(watchedLkpResults.keySet());

    ArrayList<TopComponent> toRemoveListeners = new ArrayList<>(watchedLkpResults.keySet());
    toRemoveListeners.removeAll(windowsToWatch);

    toRemoveListeners
        .stream()
        .forEach(
            (tc) -> {
              Lookup.Result res = watchedLkpResults.get(tc);
              if (null != res) {
                res.removeLookupListener(this);
                watchedLkpResults.remove(tc);
              }
            });

    toAddListeners
        .stream()
        .forEach(
            (tc) -> {
              Lookup.Result res = tc.getLookup().lookupResult(LayoutScene.class);
              res.addLookupListener(this);
              res.allItems();
              watchedLkpResults.put(tc, res);
            });
  }
示例#2
1
  /**
   * this is the core if the h2_OwnPreferences is not the first for CMP to call
   *
   * @param candidatesKB
   */
  public HashMap<Integer, RuleEngine> core(HashMap<Integer, rule_engine.RuleEngine> candidatesKB) {

    ArrayList<Integer> preference_count = new ArrayList<>();
    ArrayList<Integer> candidateID = new ArrayList<>();
    ArrayList<Integer> toberemoved = new ArrayList<>();
    for (int i : candidatesKB.keySet()) {
      if (!preference_count.isEmpty()) {
        if (countActiveOwnPreferences(candidatesKB.get(i)) < Collections.min(preference_count)) {
          preference_count.removeAll(preference_count);
          candidateID.removeAll(candidateID);
          preference_count.add(countActiveOwnPreferences(candidatesKB.get(i)));
          candidateID.add(i);
        } else if (countActiveOwnPreferences(candidatesKB.get(i))
            == Collections.min(preference_count)) {
          preference_count.add(countActiveOwnPreferences(candidatesKB.get(i)));
          candidateID.add(i);
        }
      } else {
        preference_count.add(countActiveOwnPreferences(candidatesKB.get(i)));
        candidateID.add(i);
      }
    }
    for (int i : candidatesKB.keySet()) {
      if (!candidateID.contains(i)) {

        toberemoved.add(i);
      }
    }
    for (int i : toberemoved) {
      candidatesKB.remove(i);
    }
    return candidatesKB;
  }
 public void victory() {
   battleWon = true;
   player.expGain(totalExperience);
   enemies.removeAll(enemies);
   spellsThrown.removeAll(spellsThrown);
   staminaTimer.stop();
 }
示例#4
1
 @Override
 public SubscriptionResponse removesubscription(
     final long subscriptionid, final String[] subscriptions, final String[] exclusions) {
   final Subscriber subscriber = this.subscribers.get(subscriptionid);
   if (subscriber == null) {
     return new SubscriptionResponse();
   } else {
     synchronized (subscriber.getModifyLock()) {
       if (exclusions != null) {
         final ArrayList<String> newExclusions =
             new ArrayList<String>(Arrays.asList(subscriber.getExclusions()));
         newExclusions.removeAll(Arrays.asList(exclusions));
         subscriber.setExclusions(newExclusions.toArray(new String[] {}));
       }
       if (subscriptions != null) {
         final ArrayList<String> newSubscriptions =
             new ArrayList<String>(Arrays.asList(subscriber.getSubscriptions()));
         newSubscriptions.removeAll(Arrays.asList(subscriptions));
         subscriber.setSubscriptions(newSubscriptions.toArray(new String[] {}));
       }
     }
     final SubscriptionResponse ret = new SubscriptionResponse(subscriber);
     ret.setSubscribed(true);
     return ret;
   }
 }
  public void setUserRoles(
      Session session, final ITenant theTenant, final String userName, final String[] roles)
      throws RepositoryException, NotFoundException {
    if (hasAdminRole(getUserRoles(theTenant, userName)) && (roles.length == 0)) {
      throw new RepositoryException(
          Messages.getInstance()
              .getString("AbstractJcrBackedUserRoleDao.ERROR_0005_LAST_ADMIN_USER", userName));
    }

    Set<String> roleSet = new HashSet<String>();
    if (roles != null) {
      roleSet.addAll(Arrays.asList(roles));
    }
    roleSet.add(authenticatedRoleName);

    User jackrabbitUser = getJackrabbitUser(theTenant, userName, session);

    if ((jackrabbitUser == null)
        || !TenantUtils.isAccessibleTenant(
            theTenant == null
                ? tenantedUserNameUtils.getTenant(jackrabbitUser.getID())
                : theTenant)) {
      throw new NotFoundException(
          Messages.getInstance()
              .getString("AbstractJcrBackedUserRoleDao.ERROR_0003_USER_NOT_FOUND"));
    }
    HashMap<String, Group> currentlyAssignedGroups = new HashMap<String, Group>();
    Iterator<Group> currentGroups = jackrabbitUser.memberOf();
    while (currentGroups.hasNext()) {
      Group currentGroup = currentGroups.next();
      currentlyAssignedGroups.put(currentGroup.getID(), currentGroup);
    }

    HashMap<String, Group> finalCollectionOfAssignedGroups = new HashMap<String, Group>();
    ITenant tenant = theTenant == null ? JcrTenantUtils.getTenant(userName, true) : theTenant;
    for (String role : roleSet) {
      Group jackrabbitGroup = getJackrabbitGroup(tenant, role, session);
      if (jackrabbitGroup != null) {
        finalCollectionOfAssignedGroups.put(
            tenantedRoleNameUtils.getPrincipleId(tenant, role), jackrabbitGroup);
      }
    }

    ArrayList<String> groupsToRemove = new ArrayList<String>(currentlyAssignedGroups.keySet());
    groupsToRemove.removeAll(finalCollectionOfAssignedGroups.keySet());

    ArrayList<String> groupsToAdd = new ArrayList<String>(finalCollectionOfAssignedGroups.keySet());
    groupsToAdd.removeAll(currentlyAssignedGroups.keySet());

    for (String groupId : groupsToRemove) {
      currentlyAssignedGroups.get(groupId).removeMember(jackrabbitUser);
    }

    for (String groupId : groupsToAdd) {
      finalCollectionOfAssignedGroups.get(groupId).addMember(jackrabbitUser);
    }

    // Purge the UserDetails cache
    purgeUserFromCache(userName);
  }
示例#6
1
  public static <T> List<T> intersection(List<T> listOne, List<T> listTwo) {
    ArrayList<T> onlyInOne = new ArrayList<T>(listOne);
    onlyInOne.removeAll(listTwo);

    ArrayList<T> inBoth = new ArrayList<T>(listOne);
    inBoth.removeAll(onlyInOne);

    return inBoth;
  }
示例#7
1
  @Override
  public Command getCommand() {
    // edit command
    final ArrayList<Command> changes = new ArrayList<>();
    super.addEditCommands.accept(changes);

    if (productOwnerProperty().get() != modelWrapper.get().getProductOwner()) {
      changes.add(
          new EditCommand<>(modelWrapper.get(), "productOwner", productOwnerProperty().get()));
    }

    if (scrumMasterProperty().get() != modelWrapper.get().getScrumMaster()) {
      changes.add(
          new EditCommand<>(modelWrapper.get(), "scrumMaster", scrumMasterProperty().get()));
    }

    if (!(teamMembersProperty().get().containsAll(modelWrapper.get().getTeamMembers())
        && modelWrapper.get().getTeamMembers().containsAll(teamMembersProperty().get()))) {
      // BEWARE: magic
      ArrayList<Person> teamMembers = new ArrayList<>();
      teamMembers.addAll(teamMembersProperty().get());
      changes.add(new EditCommand<>(modelWrapper.get(), "teamMembers", teamMembers));
    }

    if (!(devTeamProperty().get().containsAll(modelWrapper.get().getDevTeam())
        && modelWrapper.get().getDevTeam().containsAll(devTeamProperty().get()))) {
      // BEWARE: magic
      ArrayList<Person> devTeam = new ArrayList<>();
      devTeam.addAll(devTeamProperty().get());
      changes.add(new EditCommand<>(modelWrapper.get(), "devTeam", devTeam));
    }

    final ArrayList<Person> newMembers = new ArrayList<>(teamMembersProperty().get());
    newMembers.removeAll(modelWrapper.get().observableTeamMembers());
    final ArrayList<Person> oldMembers =
        new ArrayList<>(modelWrapper.get().observableTeamMembers());
    oldMembers.removeAll(teamMembersProperty().get());

    // Loop through all the new members and add a command to set their team
    // Set the person's team field to this team
    changes.addAll(
        newMembers
            .stream()
            .map(person -> new EditCommand<>(person, "team", modelWrapper.get()))
            .collect(Collectors.toList()));

    // Loop through all the old members and add a command to remove their team
    // Set the person's team field to null, since they're no longer in the team
    changes.addAll(
        oldMembers
            .stream()
            .map(person -> new EditCommand<>(person, "team", null))
            .collect(Collectors.toList()));

    return new CompoundCommand("Edit Team", changes);
  }
示例#8
1
  /**
   * @param role
   * @param newer 更改中间键,设置为真,否则为读取中间键。
   */
  protected void relation(Role role, boolean newer) {
    // role -> actions
    String ALL_ACTIONID =
        "SELECT action.action_id FROM action RIGHT JOIN role_and_action ON role_id WHERE role_id = (?);";
    String REMOVE_ACTIONID =
        "DELETE FROM cucgp.`role_and_action` WHERE action_id = (?) AND role_id = (?);";
    String ADD_ACTIONID = "INSERT INTO cucgp.`role_and_action` (action_id, role_id) VALUES (?, ?);";

    List<Integer> actions =
        jdbcTemplate.queryForList(ALL_ACTIONID, new Object[] {role.getRoleId()}, Integer.class);
    ArrayList<Integer> remove = new ArrayList<Integer>();
    ArrayList<Integer> add = new ArrayList<Integer>();

    if (newer) {
      remove.addAll(actions);
      remove.removeAll(role.getActions());
      for (Integer actionId : remove) {
        jdbcTemplate.update(REMOVE_ACTIONID, actionId, role.getRoleId());
      }
      add.addAll(role.getActions());
      add.removeAll(actions);
      for (Integer actionId : add) {
        jdbcTemplate.update(ADD_ACTIONID, actionId, role.getRoleId());
      }
    } else {
      role.setActions(null);
      role.setActions(new TreeSet<Integer>(actions));
    }
    // role -> groups
    String ALL_GROUPID =
        "SELECT group.group_id FROM cucgp.`group` RIGHT JOIN role_has_group ON role_id WHERE role_id = (?);";
    String REMOVE_GROUPID =
        "DELETE FROM cucgp.`role_has_group` WHERE group_id = (?) AND role_id = (?);";
    String ADD_GROUPID = "INSERT INTO cucgp.`role_has_group` (group_id, role_id) VALUES (?, ?);";

    List<Integer> groups =
        jdbcTemplate.queryForList(ALL_GROUPID, new Object[] {role.getRoleId()}, Integer.class);
    if (newer) {
      remove.clear();
      add.clear();
      remove.addAll(groups);
      remove.removeAll(role.getActions());
      for (Integer r : remove) {
        jdbcTemplate.update(REMOVE_GROUPID, r, role.getRoleId());
      }
      add.addAll(role.getActions());
      add.removeAll(groups);
      for (Integer a : add) {
        jdbcTemplate.update(ADD_GROUPID, a, role.getRoleId());
      }
    } else {
      role.setGroups(null);
      role.setGroups(groups);
    }
  }
示例#9
1
  /**
   * Gets a list of candidate values for the element that can be used as input.
   *
   * <p>The candidates are judged by the values entered in element¡¦s associated sequences by
   * calling their getEnteredVals() method.
   *
   * @return
   */
  public ArrayList<Character> getCandidates() {
    ArrayList<Character> result = new ArrayList<Character>();

    for (int i = 0; i < Board.DIMENSION * Board.DIMENSION; i++) result.add(getAlphabet().get(i));

    result.removeAll(row.getEnteredVals());
    result.removeAll(col.getEnteredVals());
    result.removeAll(box.getEnteredVals());

    return result;
  }
示例#10
1
文件: Debug.java 项目: srnsw/xena
  public static boolean compare(
      String prefix, Map a, Map b, ArrayList ignore, StringBuffer buffer) {
    if ((a == null) && (b == null)) {
      log(buffer, prefix + " both maps null");
      return true;
    }
    if (a == null) {
      log(buffer, prefix + " map a: null, map b: map");
      return false;
    }
    if (b == null) {
      log(buffer, prefix + " map a: map, map b: null");
      return false;
    }

    ArrayList keys_a = new ArrayList(a.keySet());
    ArrayList keys_b = new ArrayList(b.keySet());

    if (ignore != null) {
      keys_a.removeAll(ignore);
      keys_b.removeAll(ignore);
    }

    boolean result = true;

    for (int i = 0; i < keys_a.size(); i++) {
      Object key = keys_a.get(i);
      if (!keys_b.contains(key)) {
        log(buffer, prefix + "b is missing key '" + key + "' from a");
        result = false;
      } else {
        keys_b.remove(key);
        Object value_a = a.get(key);
        Object value_b = b.get(key);
        if (!value_a.equals(value_b)) {
          log(
              buffer,
              prefix + "key(" + key + ") value a: " + value_a + ") !=  b: " + value_b + ")");
          result = false;
        }
      }
    }
    for (int i = 0; i < keys_b.size(); i++) {
      Object key = keys_b.get(i);

      log(buffer, prefix + "a is missing key '" + key + "' from b");
      result = false;
    }

    if (result) log(buffer, prefix + "a is the same as  b");

    return result;
  }
示例#11
1
  public static List<ScheduledWorkFlowJob> searchWorkflowJobs(
      String pageSize, String pageNumber, String workflowJobId, String workflowName, String status)
      throws IOException {

    String workflowsPath =
        LoaderServerConfiguration.instance().getJobFSConfig().getWorkflowJobsPath();
    File[] workflowDirs = new File(workflowsPath).listFiles();
    Arrays.sort(
        workflowDirs,
        new Comparator<File>() {
          public int compare(File f1, File f2) {
            return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
          }
        });
    ArrayList<ScheduledWorkFlowJob> result = new ArrayList<ScheduledWorkFlowJob>();
    for (File workflowDir : workflowDirs) {
      File f = new File(workflowDir.getAbsolutePath() + File.separator + "status.json");
      ScheduledWorkFlowJob scheduledWorkFlowJob =
          objectMapper.readValue(f, ScheduledWorkFlowJob.class);
      result.add(scheduledWorkFlowJob);
    }
    ArrayList<ScheduledWorkFlowJob> filter = new ArrayList<ScheduledWorkFlowJob>();
    if (!workflowJobId.equals("")) {
      for (ScheduledWorkFlowJob r : result) {
        if (r.getWorkFlowId().contains(workflowJobId)) filter.add(r);
      }
    }
    result.removeAll(filter);
    filter.clear();
    if (!workflowName.equals("")) {
      for (ScheduledWorkFlowJob r : result) {
        if (r.getWorkflowName().contains(workflowName)) filter.add(r);
      }
    }
    result.removeAll(filter);
    filter.clear();
    if (!status.equals("")) {
      for (ScheduledWorkFlowJob r : result) {
        if (r.getStatus().equals(status)) filter.add(r);
      }
    }
    result.removeAll(filter);
    filter.clear();
    int size = Integer.parseInt(pageSize);
    int numberOfPages = result.size() / size + 1;
    int startIndex = (Integer.parseInt(pageNumber) - 1) * size;
    int lastIndex = startIndex + size > result.size() ? result.size() : startIndex + size;
    return result.subList(startIndex, lastIndex);
  }
示例#12
1
  /** Scans through the invites list, removing expired invites. */
  private void updateInviteExpiry() {
    Date now = new Date();

    // Remove expired invites.
    for (Entry<String, ArrayList<InviteEntry>> entry : this.inviteEntries.entrySet()) {
      ArrayList<InviteEntry> invites = entry.getValue();
      ArrayList<InviteEntry> removeList = new ArrayList<InviteEntry>();

      for (InviteEntry thisInvite : invites) {
        if (thisInvite.getInviteExpires() != null) {
          if (thisInvite.getInviteExpires().getTime() < now.getTime()) {
            removeList.add(thisInvite);
          }
        }
      }

      invites.removeAll(removeList);

      this.inviteEntries.put(entry.getKey(), invites);
    }

    // Remove empty users.
    ArrayList<String> removeList = new ArrayList<String>();
    for (Entry<String, ArrayList<InviteEntry>> entry : this.inviteEntries.entrySet()) {
      ArrayList<InviteEntry> invites = entry.getValue();

      if (invites.size() == 0) {
        removeList.add(entry.getKey());
      }
    }

    for (String entry : removeList) {
      this.inviteEntries.remove(entry);
    }
  }
示例#13
1
    @Override
    public ArrayList<Date> apply(Date startDate, ArrayList<Date> candidates) {
      final Calendar cal = Calendar.getInstance(getTimeZone());

      List<Date> newCandidates = new ArrayList<Date>();
      List<Date> oldCandidates = new ArrayList<Date>();

      if (candidates.isEmpty()) {
        candidates.add(startDate);
      }

      oldCandidates.addAll(candidates);

      for (Date date : candidates) {
        for (Integer element : getValueSet()) {
          cal.setTime(date);
          cal.set(Calendar.MINUTE, element);
          newCandidates.add(cal.getTime());
        }
      }

      candidates.removeAll(oldCandidates);
      candidates.addAll(newCandidates);
      return candidates;
    }
  public void nextStep() {
    ArrayList<Game> selectedGames = new ArrayList<Game>();

    TreePath[] tps = this.checkboxTree.getCheckingPaths();

    for (TreePath tp : tps) {
      if (tp.getPathCount() == 3) {
        DefaultMutableTreeNode gameNode = (DefaultMutableTreeNode) tp.getLastPathComponent();
        Game g = (Game) gameNode.getUserObject();
        selectedGames.add(g);
      }
    }

    /*		for(Game g : selectedGames) {
    			System.out.println(g.getTitle() + " : " + g.getShortDescription());
    			System.out.println("-------");
    		}

    		System.out.println("####");
    */
    this.getController().setGamesToInstall(selectedGames);
    ArrayList<Game> unselectedGames = this.games;
    unselectedGames.removeAll(selectedGames);
    this.getController().setGamesToUninstall(unselectedGames);
    this.getController().nextStep();
  }
  @Bindable
  public void setSelectedDatasource(IWizardDatasource datasource) {
    IWizardDatasource prevSelection = activeDatasource;
    activeDatasource = datasource;
    if (datasource == null || prevSelection == activeDatasource) {
      return;
    }
    try {
      datasource.activating();
      if (prevSelection != null) {
        steps.removeAll(prevSelection.getSteps());
        prevSelection.deactivating();
      }

      for (int i = 1; i < datasource.getSteps().size(); i++) {
        steps.add(datasource.getSteps().get(i));
      }
      steps.addAll(datasource.getSteps());
      wizardModel.setSelectedDatasource(datasource);
      activeStep = 0;

      updateBindings();

    } catch (XulException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
  }
 /**
  * @param allCategories
  * @param categoryListInGroup
  * @return
  */
 @SuppressWarnings("unused")
 private String[] removeAll(String[] a, String[] b) {
   ArrayList<String> list = new ArrayList<String>();
   list.addAll(Arrays.asList(a));
   list.removeAll(Arrays.asList(b));
   return list.toArray(new String[list.size()]);
 }
  /**
   * Assign the given list of units to the emergency.
   *
   * @param units The given list of units.
   * @post All the units in the given list are assigned | forall (u in units) | u.isAssigned()
   * @post All the units in the given list are handling the emergency of this UnitNeeded | forall (u
   *     in units) | u.getEmergency().equals(this.getEmergency())
   * @throws InvalidEmergencyException If the units can't be assigned to the emergency (when
   *     canAssignUnitsToEmergency fails)
   * @see #canAssignUnitsToEmergency(Set)
   */
  @Override
  public synchronized void assignUnitsToEmergency(Set<Unit> units)
      throws InvalidEmergencyException {
    ArrayList<Unit> options = new ArrayList<Unit>(units.size());
    Iterator<Unit> it = units.iterator();
    while (it.hasNext()) {
      options.add(it.next());
    }

    if (!canAssignUnitsToEmergency(units)) {
      throw new InvalidEmergencyException(
          "Units can't be assigned to the emergency, harm to assignment constraints.");
    }
    for (Emergency e : getDisaster().getEmergencies()) {
      ConcreteUnitsNeeded CUN = e.getUnitsNeeded();
      Set<Unit> unitsForEmergency = CUN.generateProposal(options);
      try {
        e.assignUnits(unitsForEmergency);
      } catch (InvalidEmergencyStatusException ex) {
        // We assume this can't happen.
        Logger.getLogger(DerivedUnitsNeeded.class.getName()).log(Level.SEVERE, null, ex);
      }
      for (Unit u : unitsForEmergency) {
        addWorkingUnits(u);
      }
      options.removeAll(unitsForEmergency);
    }
  }
示例#18
1
 public final boolean onPreDraw() {
   a.getViewTreeObserver().removeOnPreDrawListener(this);
   View view = b.a();
   if (view != null) {
     if (!c.isEmpty()) {
       a.a(d, view);
       d.keySet().retainAll(c.values());
       Iterator iterator = c.entrySet().iterator();
       do {
         if (!iterator.hasNext()) {
           break;
         }
         java.util.Map.Entry entry = (java.util.Map.Entry) iterator.next();
         Object obj = (String) entry.getValue();
         obj = (View) d.get(obj);
         if (obj != null) {
           ((View) (obj)).setTransitionName((String) entry.getKey());
         }
       } while (true);
     }
     if (e != null) {
       a.a(f, view);
       f.removeAll(d.values());
       a.b(e, f);
     }
   }
   return true;
 }
示例#19
1
 private Path holePathVonNeuemLaufwerk(ArrayList<Path> initial, ArrayList<Path> aktuell) {
   ArrayList<Path> test, test1;
   test = (ArrayList<Path>) aktuell.clone();
   test1 = (ArrayList<Path>) initial.clone();
   test.removeAll(test1);
   return test.get(test.size() - 1);
 }
示例#20
1
 public boolean checkCyclicDependency() {
   ArrayList<ScheduledWorkflowEntities> temp =
       workflow; // I don't need workFlow so destroying it while checking
   while (!temp.isEmpty()) {
     ArrayList<String> runRow = new ArrayList<String>();
     ArrayList<String> blockRow = new ArrayList<String>();
     ArrayList<ScheduledWorkflowEntities> reqRow = new ArrayList<ScheduledWorkflowEntities>();
     for (ScheduledWorkflowEntities req : temp) {
       if (req.getDependsOn().isEmpty()) {
         runRow.add(req.getRunName());
         blockRow.add(req.getBlockName());
         reqRow.add(req);
       }
     }
     temp.removeAll(reqRow);
     for (String blockName : blockRow) {
       for (ScheduledWorkflowEntities req : temp) {
         if (req.getDependsOn().contains(blockName)) req.getDependsOn().remove(blockName);
       }
     }
     if (runRow.isEmpty()) return true;
     runMap.add(runRow);
   }
   //        for(ArrayList<String> wf: runMap){
   //            for(String runName: wf){
   //                System.out.print(runName + " ->");
   //            }
   //            System.out.println();
   //        }
   return false;
 }
示例#21
1
  /**
   * Update the system, request the assigned emitters update the particles
   *
   * @param delta The amount of time thats passed since last update in milliseconds
   */
  public void update(int delta) {
    if ((sprite == null) && (defaultImageName != null)) {
      loadSystemParticleImage();
    }

    ArrayList removeMe = new ArrayList();
    for (int i = 0; i < emitters.size(); i++) {
      ParticleEmitter emitter = (ParticleEmitter) emitters.get(i);
      if (emitter.isEnabled()) {
        emitter.update(this, delta);
        if (removeCompletedEmitters) {
          if (emitter.completed()) {
            removeMe.add(emitter);
            particlesByEmitter.remove(emitter);
          }
        }
      }
    }
    emitters.removeAll(removeMe);

    pCount = 0;

    if (!particlesByEmitter.isEmpty()) {
      Iterator it = particlesByEmitter.values().iterator();
      while (it.hasNext()) {
        ParticlePool pool = (ParticlePool) it.next();
        for (int i = 0; i < pool.particles.length; i++) {
          if (pool.particles[i].life > 0) {
            pool.particles[i].update(delta);
            pCount++;
          }
        }
      }
    }
  }
示例#22
1
  @Test
  private void testWinning() throws Exception {
    LotteryResultsLoader loader =
        new JSONLotteryResultsLoader<Lotto6aus9LotteryResults>(
            LOTTO6AUS9_RESULTS_FILE, Lotto6aus9LotteryResults.class);
    LotteryResults results = loader.load();
    results.shrink(10);
    FrequencyQuery fquery = new FrequencyQuery<Lotto6aus49>(results);
    FrequencyQuery reversefquery = new FrequencyQuery<Lotto6aus49>(results);
    //        reversefquery.setReverse(true);
    final ArrayList<Integer> topNumbersSet = fquery.topNumbersSet(30);
    topNumbersSet.removeAll(
        new Lotto6aus9LotteryResults(results, 1)
            .getGames()
            .iterator()
            .next()
            .getNumbers()
            .getNumbers());
    //        final Set<Integer> bottomNumbersSet = reversefquery.topNumbersSet(15);
    //        topNumbersSet.addAll(bottomNumbersSet);

    EffectivenessRank effectivenessRank = new EffectivenessRank(results);
    subsets(topNumbersSet, 6, effectivenessRank);

    for (Map.Entry<Double, GenericResult> entry : effectivenessRank.getRank().entrySet()) {
      System.out.println(entry.getKey() + ": ");
      entry.getValue().printResult();
      System.out.println();
    }
  }
示例#23
1
 protected static boolean _privk3_deepestConflictingTransition(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final ArrayList<Transition> activeTransitions) {
   final int res = activeTransitions.size();
   final ArrayList<Transition> toDelete = new ArrayList<Transition>();
   final Consumer<Transition> _function =
       (Transition x) -> {
         final Consumer<Transition> _function_1 =
             (Transition y) -> {
               AbstractState _source = x.getSource();
               if ((_source instanceof State)) {
                 ArrayList<AbstractState> children = new ArrayList<AbstractState>();
                 AbstractState _source_1 = x.getSource();
                 RegionAspect.getAllChildren(_self, ((State) _source_1), children);
                 AbstractState _source_2 = y.getSource();
                 boolean _contains = children.contains(_source_2);
                 if (_contains) {
                   toDelete.add(x);
                 }
               }
             };
         activeTransitions.forEach(_function_1);
       };
   activeTransitions.forEach(_function);
   activeTransitions.removeAll(toDelete);
   int _size = activeTransitions.size();
   return (res != _size);
 }
  private void unassignSelectedRoles() {
    List<ProxyPentahoUser> selectedUsers = usersList.getSelectedObjects();
    if (selectedUsers.size() == 1) {
      ArrayList<ProxyPentahoRole> assignedRoles = new ArrayList<ProxyPentahoRole>();
      assignedRoles.addAll(
          Arrays.asList(UserAndRoleMgmtService.instance().getRoles(selectedUsers.get(0))));
      final List<ProxyPentahoRole> rolesToUnassign = assignedRolesList.getSelectedObjects();
      assignedRoles.removeAll(rolesToUnassign);

      AsyncCallback<Object> callback =
          new AsyncCallback<Object>() {
            public void onSuccess(Object result) {
              assignedRolesList.removeObjects(rolesToUnassign);
            }

            public void onFailure(Throwable caught) {
              MessageDialogBox messageDialog =
                  new MessageDialogBox(
                      ExceptionParser.getErrorHeader(caught.getMessage()),
                      ExceptionParser.getErrorMessage(
                          caught.getMessage(), Messages.getString("errorUnassigningRoles")),
                      false,
                      false,
                      true); //$NON-NLS-1$
              messageDialog.center();
            }
          };
      UserAndRoleMgmtService.instance()
          .setRoles(
              selectedUsers.get(0),
              (ProxyPentahoRole[]) assignedRoles.toArray(new ProxyPentahoRole[0]),
              callback);
    }
  }
  private List<String> getAvailableScopes(Project project, List<Descriptor> descriptors) {
    final ArrayList<NamedScope> scopes = new ArrayList<NamedScope>();
    for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) {
      Collections.addAll(scopes, holder.getScopes());
    }
    scopes.remove(DefaultScopesProvider.getAllScope());

    CustomScopesProviderEx.filterNoSettingsScopes(project, scopes);

    final Set<NamedScope> used = new HashSet<NamedScope>();
    for (Descriptor descriptor : descriptors) {
      final List<ScopeToolState> nonDefaultTools =
          getSelectedProfile().getNonDefaultTools(descriptor.getKey().toString());
      if (nonDefaultTools != null) {
        for (ScopeToolState state : nonDefaultTools) {
          used.add(state.getScope(project));
        }
      }
    }
    scopes.removeAll(used);

    final List<String> availableScopes = new ArrayList<String>();
    for (NamedScope scope : scopes) {
      availableScopes.add(scope.getName());
    }
    return availableScopes;
  }
示例#26
0
  @MatchEventHandler
  public void matchCompleted(MatchCompletedEvent event) {
    Match am = event.getMatch();
    MatchResult r = am.getResult();
    Matchup m = null;
    if (r.getVictors() != null && !r.getVictors().isEmpty()) {
      m = getMatchup(r.getVictors().iterator().next(), round);
    } else if (r.getLosers() != null && !r.getLosers().isEmpty()) {
      m = getMatchup(r.getLosers().iterator().next(), round);
    } else if (r.getDrawers() != null && !r.getDrawers().isEmpty()) {
      m = getMatchup(r.getDrawers().iterator().next(), round);
    }
    if (m == null) { // / This match wasnt in our tournament
      return;
    }
    if (am.getState() == MatchState.ONCANCEL) {
      endEvent();
      return;
    }
    Team victor = null;
    if (r.isDraw()) { // / match was a draw, pick a random lucky winner
      victor = pickRandomWinner(r, r.getDrawers());
    } else if (r.hasVictor() && r.getVictors().size() != 1) {
      victor = pickRandomWinner(r, r.getVictors());
    } else if (r.hasVictor()) {
      victor = r.getVictors().iterator().next(); // / single winner
    }
    m.setResult(r);
    for (Team t : r.getLosers()) {
      super.removeTeam(t);
    }
    aliveTeams.removeAll(r.getLosers());

    if (roundFinished()) {
      TimeUtil.testClock();
      if (Defaults.DEBUG) System.out.println("ROUND FINISHED !!!!!   " + aliveTeams);

      if (round + 1 == nrounds || isFinished()) {
        Server server = Bukkit.getServer();
        Team t = aliveTeams.get(0);
        server.broadcastMessage(
            Log.colorChat(
                eventParams.getPrefix()
                    + "&e Congratulations to &6"
                    + t.getDisplayName()
                    + "&e for winning!"));
        HashSet<Team> losers = new HashSet<Team>(competingTeams);
        losers.remove(victor);
        Set<Team> victors = new HashSet<Team>(Arrays.asList(victor));
        eventVictory(victors, losers);
        PerformTransition.transition(am, MatchState.FIRSTPLACE, t, false);
        PerformTransition.transition(am, MatchState.PARTICIPANTS, losers, false);
        eventCompleted();
      } else {
        makeNextRound();
        startRound();
      }
    }
  }
示例#27
0
 private boolean exit() {
   if (!input.toLowerCase().equals("exit")) {
     return false;
   }
   playerList.removeAll(playerList);
   gui.dispose();
   return true;
 }
 public void removeMonitorsFor(Animation animation) {
   for (int i = 0; i < animationMonitors.size(); i++) {
     if (animationMonitors.get(i).getAnimation() == animation)
       animationMonitorsToRemove.add(animationMonitors.get(i));
   }
   animationMonitors.removeAll(animationMonitorsToRemove);
   animationMonitorsToRemove.clear();
 }
示例#29
0
  public void run() {
    if (!checkRealizeable()) {
      System.out.println("Project is not realizeable, quitting");
      System.exit(1);
    }

    int t = 0;
    ArrayList<Task> active_tasks = findTaskWithIndegreeZero();
    System.out.println("---------------- Starting project from");
    for (Task task : active_tasks) {
      System.out.println(task.toString());
      task.start(t);
    }
    boolean finished = false;
    while (true) {

      ArrayList<Task> to_be_removed = new ArrayList<>();
      ArrayList<Task> to_be_added = new ArrayList<>();
      for (Task task : active_tasks) {

        if (task.isFinished(t)) {
          for (Edge edge : task.outEdges) {
            if (edge.w.tell_finished_prerequisite(t)) {
              to_be_added.add(edge.w);
            }
          }
          to_be_removed.add(task);
        }
      }
      active_tasks.removeAll(to_be_removed);
      active_tasks.addAll(to_be_added);
      int current_staff = 0;

      for (Task task : active_tasks) {
        current_staff += task.staff;
      }
      System.out.println("Current staff: " + Integer.toString(current_staff));

      if (active_tasks.size() == 0) {
        for (Task task : tasks) {
          if (task.finished_at == -1) {
            System.out.println("Task " + Integer.toString(task.id) + " was not able to finish!");
          }
        }
        break;
      }
      t++;
      System.out.println(" ");
      System.out.println("t: " + Integer.toString(t));
    }
    minimum_completion_time = t;
    System.out.println(
        "*** Shortest possible execution time is "
            + Integer.toString(minimum_completion_time)
            + " ***");

    setSlack();
  }
示例#30
0
  void prescanTwoTrees() throws IOException {
    new IndexTreeWalker(
            index,
            head,
            merge,
            root,
            new AbstractIndexTreeVisitor() {
              public void visitEntry(
                  TreeEntry treeEntry, TreeEntry auxEntry, Entry indexEntry, File file)
                  throws IOException {
                if (treeEntry instanceof Tree || auxEntry instanceof Tree) {
                  throw new IllegalArgumentException(JGitText.get().cantPassMeATree);
                }
                processEntry(treeEntry, auxEntry, indexEntry);
              }

              @Override
              public void finishVisitTree(Tree tree, Tree auxTree, String curDir)
                  throws IOException {
                if (curDir.length() == 0) return;

                if (auxTree != null) {
                  if (index.getEntry(curDir) != null) removed.add(curDir);
                }
              }
            })
        .walk();

    // if there's a conflict, don't list it under
    // to-be-removed, since that messed up our next
    // section
    removed.removeAll(conflicts);

    for (String path : updated.keySet()) {
      if (index.getEntry(path) == null) {
        File file = new File(root, path);
        if (file.isFile()) conflicts.add(path);
        else if (file.isDirectory()) {
          checkConflictsWithFile(file);
        }
      }
    }

    conflicts.removeAll(removed);
  }