Java Iterator.remove Examples

Java Iterator.remove - 30 examples found. These are the top rated real world Java examples of java.util.Iterator.remove extracted from open source projects. You can rate examples to help us improve the quality of examples.
  @Override
  public void refresh() {
    int tierfound = 2;
    Iterator<IConductor> it = this.conductors.iterator();
    while (it.hasNext()) {
      IConductor conductor = it.next();

      if (conductor == null) {
        it.remove();
        continue;
      }

      TileEntity tile = (TileEntity) conductor;
      World world = tile.getWorldObj();
      // Remove any conductors in unloaded chunks
      if (tile.isInvalid() || world == null) {
        it.remove();
        continue;
      }

      if (conductor.getTierGC() < 2) {
        tierfound = 1;
      }

      if (conductor.getNetwork() != this) {
        conductor.setNetwork(this);
        conductor.onNetworkChanged();
      }
    }

    // This will set the network tier to 2 if all the conductors are tier 2
    this.networkTierGC = tierfound;
  }
Example #2
0
  protected Collection<TransactionOutputEx> getSpendableOutputs() {
    Collection<TransactionOutputEx> list = _backing.getAllUnspentOutputs();

    // Prune confirmed outputs for coinbase outputs that are not old enough
    // for spending. Also prune unconfirmed receiving coins except for change
    int blockChainHeight = getBlockChainHeight();
    Iterator<TransactionOutputEx> it = list.iterator();
    while (it.hasNext()) {
      TransactionOutputEx output = it.next();
      if (output.isCoinBase) {
        int confirmations = blockChainHeight - output.height;
        if (confirmations < COINBASE_MIN_CONFIRMATIONS) {
          it.remove();
          continue;
        }
      }
      // Unless we allow zero confirmation spending we prune all unconfirmed outputs sent from
      // foreign addresses
      if (!_allowZeroConfSpending) {
        if (output.height == -1 && !isFromMe(output.outPoint.hash)) {
          // Prune receiving coins that is not change sent to ourselves
          it.remove();
        }
      }
    }
    return list;
  }
Example #3
0
  private void analyzeEdges(UniversalGraph<Node, Edge> graph, int colCount) {
    for (Node node : graph.getNodes()) {
      node.conLeft = false;
      node.conRight = false;
      node.conTop = false;
      node.conBottom = false;
      node.conLeftTop = 0;
      node.conLeftBottom = 0;
      node.conRightTop = 0;
      node.conRightBottom = 0;
    }

    int rowCount = coordinates.size();
    ArrayList<Edge> edgesList = new ArrayList<Edge>(graph.getEdges());
    for (int row = 0; row < rowCount; row++) {
      for (int jump = 0; jump < colCount - 1; jump++) {
        Iterator<Edge> edges = edgesList.iterator();
        while (edges.hasNext()) {
          Edge edge = edges.next();
          if (edge.forward() && edge.sameRow(row) && edge.jump() == jump) {
            analyzeEdge(row, jump, edge);
            edges.remove();
          }
        }
        edges = edgesList.iterator();
        while (edges.hasNext()) {
          Edge edge = edges.next();
          if (edge.backward() && edge.sameRow(row) && edge.jump() == jump) {
            analyzeEdge(row, jump, edge);
            edges.remove();
          }
        }
      }
    }
  }
    @SuppressLint("WorldReadableFiles")
    @Override
    protected FilterResults performFiltering(CharSequence constraint) {
      // NOTE: this function is *always* called from a background thread, and
      // not the UI thread.

      ArrayList<ApplicationInfo> items = new ArrayList<ApplicationInfo>();
      synchronized (this) {
        items.addAll(appList);
      }

      SharedPreferences prefs = getSharedPreferences(Common.PREFS, Context.MODE_WORLD_READABLE);

      FilterResults result = new FilterResults();
      if (constraint != null && constraint.length() > 0) {
        Pattern regexp =
            Pattern.compile(constraint.toString(), Pattern.LITERAL | Pattern.CASE_INSENSITIVE);
        for (Iterator<ApplicationInfo> i = items.iterator(); i.hasNext(); ) {
          ApplicationInfo app = i.next();
          if (!regexp.matcher(app.name == null ? "" : app.name).find()
              && !regexp.matcher(app.packageName).find()) {
            i.remove();
          }
        }
      }
      for (Iterator<ApplicationInfo> i = items.iterator(); i.hasNext(); ) {
        ApplicationInfo app = i.next();
        if (filteredOut(prefs, app)) i.remove();
      }

      result.values = items;
      result.count = items.size();

      return result;
    }
  private IName[] findDefinitions(
      IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding) throws CoreException {
    List<IASTName> declNames = new ArrayList<IASTName>();
    declNames.addAll(Arrays.asList(ast.getDefinitionsInAST(binding)));
    for (Iterator<IASTName> i = declNames.iterator(); i.hasNext(); ) {
      IASTName name = i.next();
      final IBinding b2 = name.resolveBinding();
      if (b2 instanceof ICPPUsingDeclaration) {
        i.remove();
      }
      if (binding != b2 && binding instanceof ICPPSpecialization) {
        // Make sure binding specializes b2 so that for instance we do not navigate from
        // one partial specialization to another.
        IBinding spec = binding;
        while (spec instanceof ICPPSpecialization) {
          spec = ((ICPPSpecialization) spec).getSpecializedBinding();
          if (spec == b2) break;
        }
        if (!(spec instanceof ICPPSpecialization)) {
          i.remove();
        }
      }
    }
    if (!declNames.isEmpty()) {
      return declNames.toArray(new IASTName[declNames.size()]);
    }

    // 2. Try definition in index.
    return index.findNames(
        binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
  }
Example #6
0
  public void testArrayIterators() {
    assertIteration(new Integer[] {});
    assertIteration(new Integer[] {new Integer(0)});
    assertIteration(new Integer[] {new Integer(0), new Integer(1)});
    assertIteration(new Integer[] {new Integer(0), new Integer(1), new Integer(2)});
    assertIteration(new Integer[] {new Integer(0), new Integer(1), new Integer(2), new Integer(3)});

    Object[] xs = new Object[] {"a", "b", "c"};
    assertNotNull(xs[1]);
    Iterator it = new Iterators.Array(xs);
    it.next();
    it.next();
    it.remove();
    assertNull(xs[1]);

    Object[] ys = new Object[] {"a"};
    assertNotNull(ys[0]);
    it = new Iterators.Array(ys);
    boolean threw = false;
    try {
      it.remove();
    } catch (IllegalStateException e) {
      threw = true;
    }
    assertTrue(threw);
    threw = false;
    it.next();
    it.remove();
    try {
      it.remove();
    } catch (IllegalStateException e) {
      threw = true;
    }
    assertTrue(threw);
  }