Java Iterator.next Examples

Java Iterator.next - 30 examples found. These are the top rated real world Java examples of java.util.Iterator.next extracted from open source projects. You can rate examples to help us improve the quality of examples.
  @Override
  public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTextures(
      GameProfile profile, boolean requireSecure) {
    LogHelper.debug("getTextures, Username: '%s'", profile.getName());
    Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures =
        new EnumMap<>(MinecraftProfileTexture.Type.class);

    // Add skin URL to textures map
    Iterator<Property> skinURL =
        profile.getProperties().get(ClientLauncher.SKIN_URL_PROPERTY).iterator();
    Iterator<Property> skinHash =
        profile.getProperties().get(ClientLauncher.SKIN_DIGEST_PROPERTY).iterator();
    if (skinURL.hasNext() && skinHash.hasNext()) {
      String urlValue = skinURL.next().getValue();
      String hashValue = skinHash.next().getValue();
      textures.put(
          MinecraftProfileTexture.Type.SKIN, new MinecraftProfileTexture(urlValue, hashValue));
    }

    // Add cloak URL to textures map
    Iterator<Property> cloakURL =
        profile.getProperties().get(ClientLauncher.CLOAK_URL_PROPERTY).iterator();
    Iterator<Property> cloakHash =
        profile.getProperties().get(ClientLauncher.CLOAK_DIGEST_PROPERTY).iterator();
    if (cloakURL.hasNext() && cloakHash.hasNext()) {
      String urlValue = cloakURL.next().getValue();
      String hashValue = cloakHash.next().getValue();
      textures.put(
          MinecraftProfileTexture.Type.CAPE, new MinecraftProfileTexture(urlValue, hashValue));
    }

    // Return filled textures
    return textures;
  }
  /* (non-Javadoc)
   * @see org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet#containsAll(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet)
   */
  @Override
  public boolean containsAll(TypeSet other) {
    // Optimization: if other is also a SubTypeOfSingleton, just compare bounds
    if (other instanceof SuperTypesOfSingleton) {
      SuperTypesOfSingleton otherSuper = (SuperTypesOfSingleton) other;
      return TTypes.canAssignTo(fLowerBound, otherSuper.fLowerBound);
    }
    // Optimization: if other is a SubTypesSet, just compare all its bounds to mine
    if (other instanceof SuperTypesSet) {
      SuperTypesSet otherSuper = (SuperTypesSet) other;
      TypeSet otherLowerBounds = otherSuper.lowerBound();

      for (Iterator<TType> iter = otherLowerBounds.iterator(); iter.hasNext(); ) {
        TType t = iter.next();
        if (!TTypes.canAssignTo(fLowerBound, t)) return false;
      }
      return true;
    }
    if (other.isUniverse()) {
      return false;
    }
    // For now, no more tricks up my sleeve; get an iterator
    for (Iterator<TType> iter = other.iterator(); iter.hasNext(); ) {
      TType t = iter.next();

      if (!TTypes.canAssignTo(fLowerBound, t)) return false;
    }
    return true;
  }
Example #3
0
  public double getNormalizedActivatedRate() {
    LoadUnloadEdge labeledEdge = (LoadUnloadEdge) this.getEdge();

    Node source = labeledEdge.getA();
    PacketStyleTransportSystem transSystem =
        (PacketStyleTransportSystem)
            ((labeledEdge.isLoadingEdge()) ? (labeledEdge.getB()) : (labeledEdge.getA()));

    Collection<NodeLabel> lbls = source.getLabels();
    double sourcePop = 0;

    // Get the population size of the source node
    for (Iterator<NodeLabel> it = lbls.iterator(); it.hasNext(); ) {
      NodeLabel lbl = it.next();
      if (lbl instanceof PopulationLabel) {
        sourcePop = ((PopulationLabelValue) ((PopulationLabel) lbl).getCurrentValue()).getCount();
        break;
      }
    }
    assert sourcePop > 0;

    lbls = transSystem.getLabels();
    double transCapacity = 0;

    // Get the capacity of the packet transport label
    for (Iterator<NodeLabel> it = lbls.iterator(); it.hasNext(); ) {
      NodeLabel lbl = it.next();
      if (lbl instanceof PacketTransportLabel) {
        transCapacity = ((PacketTransportLabel) lbl).getCurrentValue().getCapacity();
        break;
      }
    }

    return getActivatedRate() * transCapacity / sourcePop;
  }
Example #4
0
  /** @param config */
  public DecorateHandler(TagConfig config) {
    super(config);
    this.template = this.getRequiredAttribute("template");
    this.handlers = new HashMap();

    Iterator itr = this.findNextByType(DefineHandler.class);
    DefineHandler d = null;
    while (itr.hasNext()) {
      d = (DefineHandler) itr.next();
      this.handlers.put(d.getName(), d);
      if (log.isLoggable(Level.FINE)) {
        log.fine(tag + " found Define[" + d.getName() + "]");
      }
    }
    List paramC = new ArrayList();
    itr = this.findNextByType(ParamHandler.class);
    while (itr.hasNext()) {
      paramC.add(itr.next());
    }
    if (paramC.size() > 0) {
      this.params = new ParamHandler[paramC.size()];
      for (int i = 0; i < this.params.length; i++) {
        this.params[i] = (ParamHandler) paramC.get(i);
      }
    } else {
      this.params = null;
    }
  }
  /**
   * Returns submap of x and y values according to the given start and end
   *
   * @param start start x value
   * @param stop stop x value
   * @return a submap of x and y values
   */
  public synchronized SortedMap<Double, Double> getRange(
      double start, double stop, int beforeAfterPoints) {
    // we need to add one point before the start and one point after the end (if
    // there are any)
    // to ensure that line doesn't end before the end of the screen

    // this would be simply: start = mXY.lowerKey(start) but NavigableMap is
    // available since API 9
    SortedMap<Double, Double> headMap = mXY.headMap(start);
    if (!headMap.isEmpty()) {
      start = headMap.lastKey();
    }

    // this would be simply: end = mXY.higherKey(end) but NavigableMap is
    // available since API 9
    // so we have to do this hack in order to support older versions
    SortedMap<Double, Double> tailMap = mXY.tailMap(stop);
    if (!tailMap.isEmpty()) {
      Iterator<Double> tailIterator = tailMap.keySet().iterator();
      Double next = tailIterator.next();
      if (tailIterator.hasNext()) {
        stop = tailIterator.next();
      } else {
        stop += next;
      }
    }
    return new TreeMap<Double, Double>(mXY.subMap(start, stop));
  }
Example #6
0
  /**
   * Given a new LimitOrder, it will replace and old matching limit order in the orderbook or simply
   * get added. Finally, it is sorted.
   *
   * @param limitOrder
   */
  public void update(LimitOrder limitOrder) {

    if (limitOrder.getType().equals(OrderType.ASK)) {

      Iterator<LimitOrder> it = asks.iterator();
      while (it.hasNext()) {
        LimitOrder order = it.next();
        if (order.getLimitPrice().compareTo(limitOrder.getLimitPrice())
            == 0) { // they are equal. found it!
          it.remove();
          break;
        }
      }
      asks.add(limitOrder); // just add it
      Collections.sort(asks); // finally sort

    } else {

      Iterator<LimitOrder> it = bids.iterator();
      while (it.hasNext()) {
        LimitOrder order = it.next();
        if (order.getLimitPrice().compareTo(limitOrder.getLimitPrice())
            == 0) { // they are equal. found it!
          it.remove();
          break;
        }
      }
      bids.add(limitOrder); // just add it
      Collections.sort(bids); // finally sort
    }
  }