@Override
  public void setErrors(Set<ErrorDisplay> errors) {
    HashSet<ErrorDisplay> errorsToRemove = new HashSet<ErrorDisplay>(containedErrros);
    errorsToRemove.removeAll(errors);
    for (ErrorDisplay errorDisplay : errorsToRemove) {
      Widget widget = widgets.get(errorDisplay);
      errorsList.remove(widget);
      widgets.remove(widget);
    }

    HashSet<ErrorDisplay> errorsToAdd = new HashSet<ErrorView.ErrorDisplay>(errors);
    errorsToAdd.removeAll(containedErrros);
    String errorViewItemClass = ApplicationResources.INSTANCE.css().errorViewItemClass();
    String errorViewImageClass = ApplicationResources.INSTANCE.css().errorViewImageClass();
    for (ErrorDisplay errorDisplay : errorsToAdd) {
      SafeHtml html =
          template.errorDisplayTemplate(
              errorImageSafeUri, errorDisplay.getErrorInfo(), errorViewImageClass);
      HTML widget = new HTML(html);
      widget.setStyleName(errorViewItemClass);
      widgets.put(errorDisplay, widget);
      errorsList.add(widget);
    }
    containedErrros = new HashSet<ErrorView.ErrorDisplay>(errors);
    int height = 0;
    for (int i = 0; i < errorsList.getWidgetCount(); ++i) {
      Widget widget = errorsList.getWidget(i);
      widget.getElement().getStyle().setTop(height, Unit.PX);
      height += widget.getOffsetHeight() + 5;
    }
  }
Example #2
0
  public void addElement(String _currentFile, HashSet<Integer> npcSpawnIds, Element spawnElement) {
    npcSpawnIds.removeAll(_npcIds);
    npcSpawnIds.removeAll(_bossCollection);

    _currentFile = _currentFile.replace(".xml", "");

    if (npcSpawnIds.size() == 0) // dont have mob inside
    return;

    //		Element rootElement = npcSpawnIds.size() > 0 ? getMobRoot(_currentFile) :
    // getNpcRoot(_currentFile);

    getMobRoot(_currentFile).add(spawnElement.detach());
  }
Example #3
0
  public Row join(Row pRow, String pField) {
    // dbgMsg("Join!");
    RowFormat newFormat = mFormat.join(pRow.mFormat, pField);
    Row newRow = (Row) newFormat.getRowFactory().makeRow();
    // String[] ourFieldNames = mFormat.getFieldNames();
    // String[] theirFieldNames =pRow.mFormat.getFieldNames();
    // dbgMsg("ourFieldNames="+StringUtils.arrayToString(ourFieldNames, ", "));
    // dbgMsg("theirFieldNames="+StringUtils.arrayToString(theirFieldNames, ", "));

    HashSet ourFields = new HashSet(Arrays.asList(mFormat.getFieldNames()));
    HashSet theirFields = new HashSet(Arrays.asList(pRow.mFormat.getFieldNames()));
    ourFields.remove(pField);
    theirFields.remove(pField);
    HashSet commonFields = new HashSet(ourFields);
    commonFields.retainAll(theirFields);
    ourFields.removeAll(commonFields);
    theirFields.removeAll(commonFields);

    // dbgMsg("join field "+pField);
    // dbgMsg("our fields: "+StringUtils.collectionToString(ourFields, " "));
    // dbgMsg("their fields: "+StringUtils.collectionToString(theirFields, " "));
    // dbgMsg("common fields: "+StringUtils.collectionToString(commonFields, " "));

    // copy join field
    newRow.set(pField, get(pField)); // (copied arbitrarily from...us, as should be same!)

    // copy our fields
    Iterator ourFieldsIter = ourFields.iterator();
    while (ourFieldsIter.hasNext()) {
      String field = (String) ourFieldsIter.next();
      newRow.set(field, (get(field)));
    }

    // copy their fields
    Iterator theirFieldsIter = theirFields.iterator();
    while (theirFieldsIter.hasNext()) {
      String field = (String) theirFieldsIter.next();
      newRow.set(field, (pRow.get(field)));
    }

    // copy common fields (renaming fields becomes necessary)
    Iterator commonFieldsIter = commonFields.iterator();
    while (commonFieldsIter.hasNext()) {
      String field = (String) commonFieldsIter.next();
      newRow.set(field + "1", (get(field)));
      newRow.set(field + "2", (pRow.get(field)));
    }

    return newRow;
  }
Example #4
0
 /**
  * STRICT_VALUE_TYPES determines whether the changes of the returned collection affect this
  * collection, and if the returned is actually different from this collection. If this OclSet is
  * not backed by a java.util.HashSet, a new OclSet is created even if STRICT_VALUE_TYPES is set to
  * <CODE>false</CODE>.
  *
  * @return the OclSet containing all elements found in this OclSet or the argument, but not in
  *     both
  * @see OclCollection#STRICT_VALUE_TYPES
  */
 public OclSet symmetricDifference(OclSet set) {
   if (isUndefined()) return this;
   if (set.isUndefined()) return set;
   boolean bCreateCopy = !(collection instanceof HashSet);
   HashSet ret;
   HashSet other = new HashSet(set.collection);
   other.removeAll(collection);
   if (bCreateCopy) ret = new HashSet(collection);
   else ret = (HashSet) collection;
   ret.removeAll(set.collection);
   // now ret contains this-set and other contains set-this
   ret.addAll(other);
   if (bCreateCopy) return new OclSet(ret);
   else return this;
 }
Example #5
0
  public Message receiveDebug(
      final Message message, final BasicOperator from, final DebugStep debugstep) {
    Message msg = message;
    if (from != null) {
      debugstep.stepMessage(from, this, msg);
      Map<BasicOperator, Message> received = this.messages.get(msg.getId());
      if (received == null) {
        received = new HashMap<BasicOperator, Message>();
        this.messages.put(msg.getId(), received);
      }
      received.put(from, msg);

      final HashSet<BasicOperator> operatorsWithoutCycles = new HashSet<BasicOperator>();
      operatorsWithoutCycles.addAll(this.precedingOperators);
      operatorsWithoutCycles.removeAll(this.cycleOperands);

      if (!received.keySet().containsAll(operatorsWithoutCycles)) {
        return null;
      }

      if (received.keySet().containsAll(this.precedingOperators)) {
        this.messages.remove(msg.getId());
      }
      msg = msg.merge(received.values(), this);
    }
    msg = msg.preProcessDebug(this, debugstep);
    msg = forwardMessageDebug(msg, debugstep);
    if (msg == null) return null;
    else return msg.postProcessDebug(this, debugstep);
  }
Example #6
0
 void modelChanged(CanvasModelEvent event) {
   int action = event.getAction();
   switch (action) {
     case CanvasModelEvent.ACTION_REMOVED:
       Collection<? extends CanvasObject> affected = event.getAffected();
       if (affected != null) {
         selected.removeAll(affected);
         suppressed.keySet().removeAll(affected);
         Handle h = selectedHandle;
         if (h != null && affected.contains(h.getObject())) {
           setHandleSelected(null);
         }
       }
       break;
     case CanvasModelEvent.ACTION_HANDLE_DELETED:
       if (event.getHandle().equals(selectedHandle)) {
         setHandleSelected(null);
       }
       break;
     case CanvasModelEvent.ACTION_HANDLE_MOVED:
       HandleGesture gesture = event.getHandleGesture();
       if (gesture.getHandle().equals(selectedHandle)) {
         setHandleSelected(gesture.getResultingHandle());
       }
   }
 }
  private MyBooleanExpression(String expression) throws ParseException {
    expression = expression.replaceAll(" ", "").replaceAll("!", "~");
    this.repr = expression;
    Pattern pattern = Pattern.compile("[()~&|=>+]");
    String[] vars = pattern.split(expression);

    HashSet<String> varsSet = new HashSet<>(Arrays.asList(vars));
    varsSet.removeAll(Arrays.asList(new String[] {"", "1", "0"}));
    this.variables = varsSet.toArray(new String[0]);

    assert variables.length < 26;

    String shortExpr = new String(expression);
    for (int i = 0; i < variables.length; i++) {
      shortExpr = shortExpr.replaceAll(variables[i], "___" + i);
    }
    for (int i = 0; i < variables.length; i++) {
      shortExpr = shortExpr.replaceAll("___" + i, "" + (char) ('a' + i));
    }

    // System.out.println(shortExpr);

    BooleanExpression booleanExpression = new BooleanExpression(shortExpr);
    Map<Map<String, Boolean>, Map<BooleanExpression, Boolean>> truthTable =
        new TruthTable(booleanExpression).getResults();
    this.truthTable = new HashMap<>();

    for (Map<String, Boolean> map : truthTable.keySet()) {
      Map<BooleanExpression, Boolean> booleanMap = truthTable.get(map);
      boolean val = booleanMap.containsValue(true);
      satisfiabilitySetsCount += val ? 1 : 0;
      this.truthTable.put(map, val);
    }
  }
Example #8
0
 public MergeTestQuery andNoOtherTheirOps() {
   HashSet<AbstractOperation> theirs =
       new HashSet<AbstractOperation>(currentConflict().getTheirOperations());
   theirs.removeAll(theirSeen);
   assertEquals(theirs.size(), 0);
   return this;
 }
  public void testIterable() throws Exception {
    _store.clear();

    // Generate keys
    HashSet<String> keySet = new HashSet<String>(199);
    while (keySet.size() < 100) {
      keySet.add(UUID.randomUUID().toString());
    }
    assertEquals(100, keySet.size());

    // Populate store
    for (String key : keySet) {
      byte[] value = RandomBytes.getBytes();
      _store.put(key.getBytes(), value);
    }

    HashSet<String> keySet2 = new HashSet<String>(199);
    for (Entry<byte[], byte[]> e : _store) {
      keySet2.add(new String(e.getKey()));
    }

    assertEquals(keySet.size(), keySet2.size());

    keySet2.removeAll(keySet);
    assertEquals(0, keySet2.size());
  }
 /**
  * The inventories list is flushed with the current inventory list, so all that remains is the
  * ones still around this scan process. All packets we sent last tick, we'll remove from this
  * round, because no point sending them so quickly. NOTE: This means it's once a second by
  * default.
  *
  * <p>We clear the packetRequest list, so we can begin anew. Add all the inventories we want to
  * view. Clear the temp list, because we have no need of it, until next tick.
  */
 public void setLists() {
   inventories.retainAll(tempInv);
   tempInv.removeAll(requestedList);
   requestedList.clear();
   requestedList.addAll(tempInv);
   tempInv.clear();
 }
Example #11
0
  public void getTopics(
      ArrayList<HashSet<String>> aTopics, String argKey, double threshold, int num) {
    ArrayList<JObjectDoubleTuple<String>> aTA;
    Prob2dMap pTA, pAT;
    HashSet<String> topics, clone;

    outer:
    for (String id : m_ta.keySet()) {
      pTA = m_ta.get(id);
      pAT = m_at.get(id);
      if ((aTA = pTA.getProb1dList(argKey)) == null) continue;
      topics = new HashSet<String>();

      for (JObjectDoubleTuple<String> tup : aTA) {
        tup.value *= pAT.get1dProb(tup.object, argKey);
        if (tup.value >= threshold) topics.add(tup.object);
      }

      if (topics.size() >= num) {
        for (HashSet<String> pSet : aTopics) {
          clone = new HashSet<String>(topics);
          clone.removeAll(pSet);

          if (clone.size() < num) continue outer;
        }

        aTopics.add(topics);
      }
    }
  }
Example #12
0
 public Vector<Node> getTopologicalorder() {
   Vector<Node> topOrder = new Vector<Node>();
   HashSet<Node> nodesLeft = new HashSet<Node>();
   nodesLeft.addAll(nodes);
   for (Node n : nodes) {
     if (n.parents.isEmpty()) {
       topOrder.add(n);
       nodesLeft.remove(n);
     }
   }
   // out.println("Start topological order with "
   // +StringTool.join(", ", topOrder));
   int i = 0;
   while (!nodesLeft.isEmpty() && i < 10) {
     HashSet<Node> removeNodes = new HashSet<Node>();
     // out.println(" Current order: " +StringTool.join(", ",
     // topOrder));
     for (Node n : nodesLeft) {
       // out.println("   - Check for " + n.getShortName() +
       // " with parents " + StringTool.join(", ", n.mb.parents));
       if (topOrder.containsAll(n.parents)) {
         // out.println("    -- Can be inserted!");
         topOrder.add(n);
         removeNodes.add(n);
       }
     }
     nodesLeft.removeAll(removeNodes);
     // i++;
   }
   return topOrder;
 }
  void RemoveColidingBids(
      HashSet<Integer> regions,
      HashSet<Integer> companies,
      Double minValue,
      HashSet<Integer> AvailSet) {
    HashSet<Integer> RemoveSet =
        new HashSet<Integer>(); // HashSet to hold the items to remove from the AvailSet

    // Get an iterator to iterate over all the integers in the availble HashSet
    Iterator<Integer> it = AvailSet.iterator();

    // While there are any left
    while (it.hasNext()) {

      // Get the next integer
      Integer k = it.next();

      if ((_bids.get(k).value <= minValue)
          || // if the value is less than the target
          (companies.contains(_bids.get(k).company))
          || // if the company is already represented
          !Collections.disjoint(
              _bids.get(k).region, regions)) { // if it contains a region already bid on
        // add K to the "Remove" set
        RemoveSet.add(k);
      }
    }
    // Remove every bid from the remove set from the Avail list.
    AvailSet.removeAll(RemoveSet);
  }
  void renderAll(Tessellator var1) {
    HashSet var2 = new HashSet();
    Iterator var3 = this.skies.iterator();

    while (var3.hasNext()) {
      SkyRenderer$Layer var4 = (SkyRenderer$Layer) var3.next();

      if (var4.prepare()) {
        var2.add(SkyRenderer$Layer.access$300(var4));
      }
    }

    HashSet var6 = new HashSet();
    var6.addAll(this.textures);
    var6.removeAll(var2);
    Iterator var7 = var6.iterator();

    while (var7.hasNext()) {
      String var5 = (String) var7.next();
      TexturePackAPI.unloadTexture(var5);
    }

    var7 = this.skies.iterator();

    while (var7.hasNext()) {
      SkyRenderer$Layer var8 = (SkyRenderer$Layer) var7.next();

      if (var8.brightness > 0.0F) {
        var8.render(var1);
        SkyRenderer$Layer.clearBlendingMethod();
      }
    }
  }
Example #15
0
  public static void updateSensors(MMMinecart minecart, MMMinecart input) {

    HashSet<Block> blockList = minecart.getAdjacentBlocks(1);
    blockList.addAll(minecart.getBlocksBeneath(3));
    HashSet<Block> oldBlockList = minecart.getPreviousLocationAdjacentBlocks(1);
    oldBlockList.addAll(minecart.getPreviousLocationBlocksBeneath(3));
    oldBlockList.removeAll(blockList);

    // Activate new sensors
    for (Block block : blockList) {
      Sensor s = SensorManager.getSensor(block);
      if (s != null) {
        try {
          s.input(input);
        } catch (Exception e) {
          SensorManager.delSensor(s.getLocation());
        }
      }
    }

    // deactivate old sensors
    for (Block block : oldBlockList) {
      Sensor s = SensorManager.getSensor(block);
      if (s != null) {
        try {
          s.input(null);
        } catch (Exception e) {
          SensorManager.delSensor(s.getLocation());
        }
      }
    }
  }
 private void editSpeakertable() {
   BasicTranscription transcription = table.getModel().getTranscription();
   String[] speakerIDsBefore = transcription.getHead().getSpeakertable().getAllSpeakerIDs();
   int[] tiersWithAutoDisplayName = transcription.getTierNumbersWithAutoDisplayName();
   EditSpeakerTableDialog dialog =
       new EditSpeakerTableDialog(table.parent, true, transcription.getHead().getSpeakertable());
   if (dialog.editSpeakertable()) {
     transcription.getHead().setSpeakertable(dialog.getSpeakertable());
     table.getModel().getTranscription().checkSpeakers();
     if (dialog.getAutoAdd()) {
       // auto add tiers for new speakers
       HashSet<String> before = new HashSet<String>();
       Collections.addAll(before, speakerIDsBefore);
       HashSet<String> after = new HashSet<String>();
       Collections.addAll(after, dialog.getSpeakertable().getAllSpeakerIDs());
       if (after.removeAll(before)) {
         for (String newID : after) {
           Tier newTier = new Tier(transcription.getBody().getFreeID(), newID, "v", "t");
           String displayName = newTier.getDescription(dialog.getSpeakertable());
           newTier.setDisplayName(displayName);
           table.getModel().addTier(newTier);
           System.out.println("Tier inserted for " + newID);
         }
       }
     }
     transcription.makeAutoDisplayName(tiersWithAutoDisplayName);
     table.getModel().fireRowLabelsChanged();
     table.transcriptionChanged = true;
     table.status("Speaker table edited");
   }
 }
Example #17
0
 public MergeTestQuery andNoOtherMyOps() {
   HashSet<AbstractOperation> my =
       new HashSet<AbstractOperation>(currentConflict().getMyOperations());
   my.removeAll(mySeen);
   assertEquals(0, my.size());
   return this;
 }
  private void clearSelections() {
    selectedHospitalIDs.removeAll(selectedHospitalIDs);
    selectedRows.removeAll(selectedRows);

    individualsSTP.setToggledRows(null);
    refreshSelectionIndicator();
  }
  @POST
  @Path("{id}/imagenes/remove")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public Response removeImages(@PathParam(value = "id") Long id, List<String> images) {
    try {
      Producto p = em.find(Producto.class, id);
      List<String> images_old = new ArrayList<>();
      if (p.getImagenes() != null && !p.getImagenes().equals("")) {
        images_old = Arrays.asList(p.getImagenes().split(","));
      }
      HashSet<String> set = new HashSet<>(images_old);
      set.removeAll(images);
      String joined = String.join(",", set);
      p.setImagenes(joined);

      // update doc mongo
      DataProducto dp = p.getDataProducto();
      new MongoController().upsertProduct(dp);

      return Response.status(200).entity(dp).build();

    } catch (Exception e) {
      e.printStackTrace();
      DataResponse dr = new DataResponse();
      dr.setMensaje("Error remover imagenes");
      dr.setDescripcion("Problema en mongodb");
      return Response.status(500).entity(dr).build();
    }
  }
Example #20
0
  private static double jaccardSimilarity(String similar1, String similar2) {
    HashSet<String> h1 = new HashSet<String>();
    HashSet<String> h2 = new HashSet<String>();

    for (String s : similar1.split("\\s+")) {
      h1.add(s);
    }

    for (String s : similar2.split("\\s+")) {
      h2.add(s);
    }

    int sizeh1 = h1.size();
    // Retains all elements in h3 that are contained in h2 ie intersection
    h1.retainAll(h2);
    // h1 now contains the intersection of h1 and h2

    h2.removeAll(h1);
    // h2 now contains unique elements

    // Union
    int union = sizeh1 + h2.size();
    int intersection = h1.size();

    return (double) intersection / union;
  }
Example #21
0
  public void doTrackStyle() {
    if (null == stylist) {
      return;
    }
    gui.logger.setStatus("Setting style.");

    graph.getModel().beginUpdate();
    try {

      // Collect edges
      Set<Integer> trackIDs = model.getTrackModel().trackIDs(true);
      HashMap<Integer, Set<mxCell>> edgeMap = new HashMap<Integer, Set<mxCell>>(trackIDs.size());
      for (Integer trackID : trackIDs) {
        Set<DefaultWeightedEdge> edges = model.getTrackModel().trackEdges(trackID);
        HashSet<mxCell> set = new HashSet<mxCell>(edges.size());
        for (DefaultWeightedEdge edge : edges) {
          set.add(graph.getCellFor(edge));
        }
        edgeMap.put(trackID, set);
      }

      // Give them style
      Set<mxICell> verticesUpdated = stylist.execute(edgeMap);

      // Take care of vertices
      HashSet<mxCell> missedVertices = new HashSet<mxCell>(graph.getVertexCells());
      missedVertices.removeAll(verticesUpdated);
      stylist.updateVertexStyle(missedVertices);

    } finally {
      graph.getModel().endUpdate();
    }
  }
Example #22
0
 public static final void main(final String[] array) {
   try {
     final Scanner scanner = new Scanner(System.in);
     final DFA dfa = new DFA();
     dfa.read(scanner);
     final DFA dfa2 = new DFA();
     dfa2.read(scanner);
     final HashSet set = new HashSet<String>(dfa.alphabet);
     final HashSet set2 = new HashSet<String>(dfa2.alphabet);
     final HashSet set3 = new HashSet<String>(set);
     set3.removeAll(set2);
     if (set3.size() > 0) {
       System.out.println(
           "Your alphabet lacks the following symbol(s): "
               + formatString(new ArrayList<String>((Collection<? extends String>) set3)));
       System.exit(1);
     }
     final HashSet set4 = new HashSet<String>(set2);
     set4.removeAll(set);
     if (set4.size() > 0) {
       System.out.println(
           "Your alphabet contains the following symbol(s) that it should not: "
               + formatString(new ArrayList<String>((Collection<? extends String>) set4)));
       System.exit(1);
     }
     final List<String> anyString = dfa.diff(dfa2).anyString();
     if (anyString != null) {
       System.out.println("The following word is NOT matched by your DFA, but it SHOULD be:");
       System.out.println(formatString(anyString));
       System.exit(1);
     } else {
       final List<String> anyString2 = dfa2.diff(dfa).anyString();
       if (anyString2 != null) {
         System.out.println("The following word IS matched by your DFA, but it should NOT be:");
         System.out.println(formatString(anyString2));
         System.exit(1);
       } else {
         System.out.println("Correct.");
         System.exit(0);
       }
     }
   } catch (Error error) {
     System.err.println(error);
     System.exit(1);
   }
 }
Example #23
0
 public void FV(HashSet<String> vars) {
   HashSet<String> bound = new HashSet<String>();
   for (Binding b : Binding.valueBindings(bindings)) {
     bound.add(b.getName());
   }
   for (Binding b : Binding.valueBindings(bindings)) {
     HashSet<String> free = new HashSet<String>();
     b.FV(free);
     free.removeAll(bound);
     vars.addAll(free);
   }
   HashSet<String> free = new HashSet<String>();
   for (BArm arm : arms) arm.FV(vars);
   init.FV(vars);
   name.FV(vars);
   free.removeAll(bound);
   vars.addAll(free);
 }
  private void updateModel(final IFile file) {
    final TransactionalEditingDomain domain =
        TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
    final ResourceSet resourceSet = domain.getResourceSet();
    EObject diagramRoot = null;
    try {
      final URI domainModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
      final Resource resource = resourceSet.getResource(domainModelURI, true);
      diagramRoot = resource.getContents().get(0);
    } catch (final Exception ex) {
      ex.printStackTrace();
    }

    PetriNet petriNet = null;
    if (diagramRoot == null || !(diagramRoot instanceof PetriNet)) {
      throw new NotAPetriNetException("The diagram root is not a Petri net", diagramRoot);
    } else {
      petriNet = (PetriNet) diagramRoot;
    }

    if (fileToTreeMap == null) {
      fileToTreeMap = new HashMap<IFile, SimpleTree<Object>>();
    }
    final HashSet<String> primePages = new HashSet<String>();
    final HashSet<String> notPrimePages = new HashSet<String>();
    final Map<String, Page> idToPageMap = new HashMap<String, Page>();

    for (final Page page : petriNet.getPage()) {
      idToPageMap.put(page.getId(), page);
      for (final Instance instance : page.instance()) {
        notPrimePages.add(instance.getSubPageID());
      }
      primePages.add(page.getId());
    }
    primePages.removeAll(notPrimePages);

    final SimpleTree<Object> root = new SimpleTree<Object>("Root");
    final SimpleTree<Object> declarations =
        new SimpleTree<Object>(root, CPNModelContentProvider.DECLARATION_HEADER);
    for (final HLDeclaration decl : petriNet.declaration()) {
      String declText = decl.getStructure().asShortString().replace('\n', ' ');
      declText = declText.replace('\r', ' ');
      final int maxLength = 30;
      if (declText.length() > maxLength) {
        declText = declText.substring(0, maxLength) + "...";
      }

      new SimpleTree<Object>(declarations, declText, decl);
    }

    for (final String pageId : primePages) {
      buildTree(root, idToPageMap, pageId);
    }

    fileToTreeMap.put(file, root);
  }
 /*
  * removes dead entities from the modifiedEntities list
  */
 private void removeDeadEntities() {
   ArrayList<LivingEntity> remove = new ArrayList<LivingEntity>();
   synchronized (modifiedEntities) {
     for (LivingEntity ent : modifiedEntities) {
       if (ent.getHealth() == 0) {
         remove.add(ent);
       }
     }
     modifiedEntities.removeAll(remove);
   }
 }
  public void conjoinAllNeighbors() {
    if (!this.isCeiling()) {
      this.conjoinedelevators.clear();
      HashSet var1 = new HashSet();
      this.conjoinedelevators.addAll(this.getNeighbors());
      var1.addAll(this.conjoinedelevators);
      var1.remove(this);
      Iterator var2;

      while (!var1.isEmpty()) {
        var2 = var1.iterator();
        HashSet var3 = new HashSet();

        while (var2.hasNext()) {
          EntityElevator var4 = (EntityElevator) var2.next();
          var3.addAll(var4.getNeighbors());
        }

        var1.clear();
        var3.removeAll(this.conjoinedelevators);
        this.conjoinedelevators.addAll(var3);
        var1.addAll(var3);
      }

      var2 = this.conjoinedelevators.iterator();

      while (var2.hasNext()) {
        EntityElevator var5 = (EntityElevator) var2.next();

        if (!var5.center && !this.isClient) {
          var5.center = false;
          var5.centerElevator = this;

          if (var5.ceiling != null) {
            var5.ceiling.centerElevator = this;
            var5.ceiling.conjoinedHasBeenSet = true;
            var5.ceiling.center = false;
          }
        } else {
          var5.setConjoined(this.conjoinedelevators);
          var5.centerElevator = var5;

          if (var5.ceiling != null) {
            var5.ceiling.centerElevator = var5;
            var5.ceiling.conjoinedHasBeenSet = true;
          }

          var5.center = true;
        }
      }

      this.conjoinedHasBeenSet = true;
    }
  }
Example #27
0
    Match(Set<String> parameterNames, M method) {
      this.method = method;

      // The number of matched parameters
      HashSet<String> a = new HashSet<String>(parameterNames);
      a.retainAll(getParameterNames(method));
      this.score1 = a.size();

      // The number of unmatched arguments
      a = new HashSet<String>(getParameterNames(method));
      a.removeAll(parameterNames);
      this.score2 = a.size();

      // The number of unmatched parameters
      a = new HashSet<String>(parameterNames);
      a.removeAll(getParameterNames(method));
      this.score3 = a.size();

      // The default method
      this.score4 = isDefault(method) ? 0 : 1;
    }
Example #28
0
 private void cleanupExpandedItems() {
   Set<Object> removedItemIds = new HashSet<Object>();
   for (Object expandedItemId : expanded) {
     if (getItem(expandedItemId) == null) {
       removedItemIds.add(expandedItemId);
       if (this.expandedItemId == expandedItemId) {
         this.expandedItemId = null;
       }
     }
   }
   expanded.removeAll(removedItemIds);
 }
  private void update() {
    // Register all our services...
    synchronized (registeredServices) {
      for (String service : registeredServices) {
        doRegister(service);
      }
    }

    // Find new registered services...
    DiscoveryListener discoveryListener = this.discoveryListener.get();
    if (discoveryListener != null) {
      Set<String> activeServices = doLookup(updateInterval * 3);
      // If there is error talking the the central server, then
      // activeServices == null
      if (activeServices != null) {
        synchronized (discoveredServices) {
          HashSet<String> removedServices = new HashSet<String>(discoveredServices.keySet());
          removedServices.removeAll(activeServices);

          HashSet<String> addedServices = new HashSet<String>(activeServices);
          addedServices.removeAll(discoveredServices.keySet());
          addedServices.removeAll(removedServices);

          for (String service : addedServices) {
            SimpleDiscoveryEvent e = new SimpleDiscoveryEvent(service);
            discoveredServices.put(service, e);
            discoveryListener.onServiceAdd(e);
          }

          for (String service : removedServices) {
            SimpleDiscoveryEvent e = discoveredServices.remove(service);
            if (e != null) {
              e.removed.set(true);
            }
            discoveryListener.onServiceRemove(e);
          }
        }
      }
    }
  }
Example #30
0
 public void addLine(CodeLine line) {
   String[] tokens = line.op.split(" ");
   if (line instanceof ClassLine) {
     declaredVars.add(((ClassLine) line).defined.name);
     referencedExternalVars.addAll(((ClassLine) line).defined.internals.referencedExternalVars);
     referencedExternalVars.removeAll(declaredVars);
   } else if (line instanceof DefLine) {
     declaredVars.add(((DefLine) line).defined.name);
     referencedExternalVars.addAll(((DefLine) line).defined.internals.referencedExternalVars);
     referencedExternalVars.removeAll(declaredVars);
   } else if (line instanceof LambdaLine) {
     referencedExternalVars.addAll(((LambdaLine) line).defined.internals.referencedExternalVars);
     referencedExternalVars.removeAll(declaredVars);
   } else if (tokens[0].equals("PUSH") && tokens.length == 2) {
     if (!declaredVars.contains(tokens[1])) {
       referencedExternalVars.add(tokens[1]);
     }
   } else if (tokens[0].equals("POP") && tokens.length == 2) {
     declaredVars.add(tokens[1]);
   }
   code.add(line);
 }