Example usage for java.util TreeSet remove

List of usage examples for java.util TreeSet remove

Introduction

In this page you can find the example usage for java.util TreeSet remove.

Prototype

public boolean remove(Object o) 

Source Link

Document

Removes the specified element from this set if it is present.

Usage

From source file:org.dasein.cloud.gogrid.network.lb.GoGridLBSupport.java

@Override
public void removeServers(String fromLoadBalancerId, String... serverIdsToRemove)
        throws CloudException, InternalException {
    if (serverIdsToRemove == null || serverIdsToRemove.length < 1) {
        return;// w  ww  .jav  a2s .c  om
    }
    LoadBalancer lb = getLoadBalancer(fromLoadBalancerId);

    if (lb == null) {
        throw new CloudException("No such load balancer: " + fromLoadBalancerId);
    }
    TreeSet<String> serverIds = new TreeSet<String>();

    if (lb.getProviderServerIds() != null) {
        Collections.addAll(serverIds, lb.getProviderServerIds());
    }
    for (String id : serverIdsToRemove) {
        serverIds.remove(id);
    }
    edit(lb, serverIds);
}

From source file:org.rhwlab.BHC.BHCTree.java

public TreeMap<Integer, TreeSet<NucleusLogNode>> allTreeCuts(int maxNodes) {
    TreeMap<Integer, TreeSet<NucleusLogNode>> ret = new TreeMap<>();

    TreeSet<NucleusLogNode> cut = firstTreeCut();
    ret.put(cut.size(), cut);/*from   w w w.j a v  a2  s. c  o m*/
    while (cut.size() < maxNodes) {
        NucleusLogNode[] next = nextTreeCut(cut);
        if (next == null) {
            return ret;
        }
        TreeSet<NucleusLogNode> nextSet = new TreeSet<>();
        nextSet.addAll(cut);
        nextSet.remove(next[2]);
        nextSet.add(next[0]);
        nextSet.add(next[1]);
        ret.put(nextSet.size(), nextSet);
        cut = nextSet;
    }
    return ret;
}

From source file:org.apache.uima.ruta.engine.HtmlConverter.java

private SortedSet<HtmlConverterPSpan> htmlDecoding(SortedSet<HtmlConverterPSpan> visibleSpansSoFar) {
    TreeSet<HtmlConverterPSpan> copy = new TreeSet<HtmlConverterPSpan>(visibleSpansSoFar);

    Pattern patt = Pattern.compile("(&[a-zA-Z0-9]{2,6};)|(&#\\d{2,5};)");

    for (HtmlConverterPSpan pSpan : visibleSpansSoFar) {
        String spanTxt = pSpan.getTxt();
        Matcher matcher = patt.matcher(spanTxt);

        if (matcher.find()) {
            copy.remove(pSpan);
            int pSpanBegin = pSpan.getBegin();
            int ioff = pSpan.getBegin();
            do {/*from  w  ww.  j  a v a  2 s .c  o  m*/
                String sourceString = matcher.group();
                String replacement = StringEscapeUtils.unescapeHtml4(sourceString);
                HtmlConverterPSpanReplacement replacementSpan = new HtmlConverterPSpanReplacement(
                        pSpanBegin + matcher.start(), pSpanBegin + matcher.end(), replacement);
                copy.add(replacementSpan);

                int replacementLength = sourceString.length();
                if (pSpanBegin + matcher.end() > ioff + replacementLength) {
                    int ib = ioff;
                    int ie = pSpanBegin + matcher.start();
                    String newTxt = spanTxt.substring(ib - pSpanBegin, ie - pSpanBegin);
                    copy.add(new HtmlConverterPSpan(ib, ie, newTxt));
                    ioff = ie;
                }
                ioff += replacementLength; //
            } while (matcher.find());
            if (ioff < pSpan.getEnd()) {
                int ib = ioff;
                int ie = pSpan.getEnd();
                String newTxt = spanTxt.substring(ib - pSpanBegin, ie - pSpanBegin);
                copy.add(new HtmlConverterPSpan(ioff, pSpan.getEnd(), newTxt));
            }
        }
    }
    return copy;
}

From source file:org.sonatype.mercury.mp3.delta.cli.DeltaManagerCli.java

private List<Artifact> getLocalVersions(final String containerId) {
    ArrayList<Artifact> res = new ArrayList<Artifact>(8);

    File cdDir = new File(_mavenHome, DeltaManager.CD_DIR);

    if (!cdDir.exists())
        return res;

    File[] files = cdDir.listFiles(new FileFilter() {
        public boolean accept(File pathname) {
            String name = pathname.getName();

            if (name.equals(MavenDeltaManager.DEFAULT_CONTAINER_ID + "." + DeltaManager.CD_EXT))
                return false;// current version

            //                                          if( name.matches( ".*-[0-9]{14}\\."+DeltaManager.CD_EXT ) )
            if (name.endsWith("." + DeltaManager.CD_EXT))
                return true;

            return false;
        }/*from   w  w  w .  j av a2 s  .c  o m*/
    });
    if (Util.isEmpty(files))
        return res;

    int count = files.length;

    TreeSet<String> sortedFiles = new TreeSet<String>();
    for (File f : files)
        sortedFiles.add(f.getName());

    while (count-- > 0) {
        String f = sortedFiles.last();

        DefaultArtifact da = new DefaultArtifact(new ArtifactMetadata("org.apache.maven:maven-cd:" + f));

        da.setFile(new File(cdDir, f));

        res.add(da);

        sortedFiles.remove(f);
    }

    return res;
}

From source file:org.apache.uima.ruta.engine.HtmlConverter.java

private SortedSet<HtmlConverterPSpan> handleConversion(SortedSet<HtmlConverterPSpan> visibleSpansSoFar,
        String patternString, String replacement) {
    TreeSet<HtmlConverterPSpan> copy = new TreeSet<HtmlConverterPSpan>(visibleSpansSoFar);

    Pattern patt = Pattern.compile(patternString);
    int replacementLength = patternString.length();

    for (HtmlConverterPSpan pSpan : visibleSpansSoFar) {
        String spanTxt = pSpan.getTxt();
        Matcher matcher = patt.matcher(spanTxt);

        if (matcher.find()) {
            copy.remove(pSpan);
            int pSpanBegin = pSpan.getBegin();
            int ioff = pSpan.getBegin();
            do {//from   ww  w .j a va2  s  .c  om
                if (!StringUtils.isEmpty(replacement)) {
                    HtmlConverterPSpanReplacement replacementSpan = new HtmlConverterPSpanReplacement(
                            pSpanBegin + matcher.start(), pSpanBegin + matcher.end(), replacement);
                    copy.add(replacementSpan);
                }
                if (pSpanBegin + matcher.end() > ioff + replacementLength) {
                    int ib = ioff;
                    int ie = pSpanBegin + matcher.start();
                    String newTxt = spanTxt.substring(ib - pSpanBegin, ie - pSpanBegin);
                    copy.add(new HtmlConverterPSpan(ib, ie, newTxt));
                    ioff = ie;
                }
                ioff += replacementLength; //
            } while (matcher.find());
            if (ioff < pSpan.getEnd()) {
                int ib = ioff;
                int ie = pSpan.getEnd();
                String newTxt = spanTxt.substring(ib - pSpanBegin, ie - pSpanBegin);
                copy.add(new HtmlConverterPSpan(ioff, pSpan.getEnd(), newTxt));
            }
        }
    }
    return copy;
}

From source file:net.sf.jabref.model.database.BibtexDatabase.java

public TreeSet<String> getAllVisibleFields() {
    TreeSet<String> allFields = new TreeSet<>();
    for (BibtexEntry e : getEntries()) {
        allFields.addAll(e.getFieldNames());
    }//from   w w  w . j av  a  2  s .c o m
    TreeSet<String> toberemoved = new TreeSet<>();
    for (String field : allFields) {
        if (field.startsWith("__")) {
            toberemoved.add(field);
        }
    }

    for (String field : toberemoved) {
        allFields.remove(field);
    }
    return allFields;
}

From source file:org.rhwlab.BHC.BHCTree.java

public TreeSet<NucleusLogNode> cutToExactlyN_Nodes(int n) {
    TreeSet<NucleusLogNode> cut = firstTreeCut();
    while (cut.size() < n) {
        NucleusLogNode[] next = nextTreeCut(cut);
        if (next == null)
            return cut;
        cut.remove(next[2]);
        cut.add(next[0]);/*from   w  w  w  .  j ava  2  s .  com*/
        cut.add(next[1]);
    }
    return cut;

}

From source file:ro.hasna.ts.math.representation.AdaptivePiecewiseConstantApproximation.java

@Override
public MeanLastPair[] transform(double[] values) {
    int length = values.length;
    if (length < 2 * segments) {
        throw new ArrayLengthIsTooSmallException(length, 2 * segments, true);
    }/*www . ja v  a 2  s.co m*/
    int numberOfSegments = length / 2;

    // create segments with two values
    Segment first = createSegments(values, length);

    if (numberOfSegments > segments) {
        // compute error by unifying current segment with the next segment
        TreeSet<Segment> set = createSegmentsSet(values, first);

        // unify concurrent segments with minimum error
        while (numberOfSegments > segments) {
            Segment minSegment = set.pollFirst();
            minSegment.mean = getUnifiedMean(minSegment, minSegment.next);
            minSegment.error = getUnifiedError(minSegment, minSegment.next, values, minSegment.mean);
            minSegment.end = minSegment.next.end;

            deleteSubsequentSegment(minSegment, set);

            if (minSegment.next != null) {
                double mean = getUnifiedMean(minSegment, minSegment.next);
                minSegment.errorWithNext = getUnifiedError(minSegment, minSegment.next, values, mean);
                set.add(minSegment);
            }

            if (minSegment.prev != null) {
                set.remove(minSegment.prev);

                double mean = getUnifiedMean(minSegment.prev, minSegment);
                minSegment.prev.errorWithNext = getUnifiedError(minSegment.prev, minSegment, values, mean);

                set.add(minSegment.prev);
            }

            numberOfSegments--;
        }
    }

    return getMeanLastPairs(first, numberOfSegments);
}

From source file:com.thoughtworks.go.server.dao.PipelineSqlMapDao.java

private void removeCompletedIfNotLatest(Stage stage,
        Map<CaseInsensitiveString, TreeSet<Long>> activePipelinesToIds, CaseInsensitiveString pipelineName) {
    if (stage.getState().completed()) {
        if (activePipelinesToIds.containsKey(pipelineName)) {
            TreeSet<Long> ids = activePipelinesToIds.get(pipelineName);
            if (!ids.last().equals(stage.getPipelineId())) {
                ids.remove(stage.getPipelineId());
            }/*w  w w .  j  a va2 s  . c  o  m*/
        }
    }
}