Exemplo n.º 1
0
  protected TreeMap<Integer, String> createInitialLocationsForGA(
      TreeMap<Id, LinkRetailersImpl> availableLinks) {
    TreeMap<Integer, String> locations = new TreeMap<Integer, String>();
    int intCount = 0;
    for (ActivityFacility af : this.retailerFacilities.values()) {
      locations.put(
          Integer.valueOf(intCount),
          NetworkUtils.getNearestLink(
                  ((NetworkImpl) this.controler.getScenario().getNetwork()), af.getCoord())
              .getId()
              .toString());
      ++intCount;
      log.info(
          "The facility with Id: "
              + af.getId()
              + " has been added, this is located on the link: "
              + af.getLinkId());
    }
    for (LinkRetailersImpl l : availableLinks.values()) {
      if (locations.containsValue(l.getId().toString())) {
        log.info("The Link: " + l.getId() + " is already on the list");
      } else {
        locations.put(Integer.valueOf(intCount), l.getId().toString());
        ++intCount;
        log.info("The Link: " + l.getId() + " has been added");
      }
    }

    log.info("Initial Locations (with Free Links) = " + locations);
    return locations;
  }
  @Override
  public ThreeOfAKindKickers calculateKickers(final Hand hand)
      throws HandDoesNotContainThreeOfAKindException,
          HandDoesNotContainThreeDistinctCardCategoriesException {
    final TreeMap<CardCategory, Integer> cardCategoryIntegerTreeMap =
        sortedCardCategoryMapper.returnSortedCardCategoryAscending(hand);

    if (!cardCategoryIntegerTreeMap.containsValue(3)) {
      throw new HandDoesNotContainThreeOfAKindException();
    }

    if (3 != cardCategoryIntegerTreeMap.size()) {
      throw new HandDoesNotContainThreeDistinctCardCategoriesException();
    }

    CardCategory threeOfAKindCardCategory = null;
    CardCategory highestRemainingCardCategory = null;
    CardCategory lowestRemainingCardCategory = null;

    for (Map.Entry<CardCategory, Integer> entry : cardCategoryIntegerTreeMap.entrySet()) {
      if (3 == entry.getValue()) {
        threeOfAKindCardCategory = entry.getKey();
      } else if (null == lowestRemainingCardCategory) {
        lowestRemainingCardCategory = entry.getKey();
      } else if (null == highestRemainingCardCategory) {
        highestRemainingCardCategory = entry.getKey();
      } else {
        throw new RuntimeException("unexpected");
      }
    }

    return new ThreeOfAKindKickers(
        threeOfAKindCardCategory, highestRemainingCardCategory, lowestRemainingCardCategory);
  }
Exemplo n.º 3
0
 /**
  * Add new node to NodeList(treemap)
  *
  * @param address String ipaddress
  * @throws Exception Exception if allready in list
  */
 public void addNode(InetAddress address, String Naam) {
   Hasher myHasher = new Hasher();
   int nodeID = myHasher.Hash(Naam);
   if (!NodeList.containsKey(nodeID) && !NodeList.containsValue(address)) {
     NodeList.put(nodeID, address);
   }
 }
Exemplo n.º 4
0
 /**
  * Method to return if the map contains this value.
  *
  * @param value The value
  * @return Whether it is contained
  */
 public boolean containsValue(Object value) {
   return delegate.containsValue(value);
 }
Exemplo n.º 5
0
 public boolean containsEventWithValue(String V) {
   return event.containsValue(V);
 }
Exemplo n.º 6
0
 public boolean containsObjWithValue(String V) {
   return obj.containsValue(V);
 }