Example usage for java.util TreeSet lower

List of usage examples for java.util TreeSet lower

Introduction

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

Prototype

public E lower(E e) 

Source Link

Usage

From source file:Main.java

public static void main(String[] args) {

    TreeSet<Integer> treeadd = new TreeSet<Integer>();

    treeadd.add(1);/*w  w w.j  ava  2 s  . com*/
    treeadd.add(3);
    treeadd.add(17);
    treeadd.add(2);
    treeadd.add(20);

    // displaying the greatest element < 17
    System.out.println("Greatest element less than 17 is: " + treeadd.lower(17));
}

From source file:Main.java

public static void main(String args[]) {
    Set<String> hs = new HashSet<String>();

    hs.add("one");
    hs.add("two");
    hs.add("three");

    System.out.println("Here is the HashSet: " + hs);

    if (!hs.add("three"))
        System.out.println("Attempt to add duplicate. " + "Set is unchanged: " + hs);

    TreeSet<Integer> ts = new TreeSet<Integer>();

    ts.add(8);//from   w  w  w. j ava2  s .com
    ts.add(19);
    ts.add(-2);
    ts.add(3);

    System.out.println(ts);

    System.out.println("First element in ts: " + ts.first());
    System.out.println("Last element in ts: " + ts.last());

    System.out.println("First element > 15: " + ts.higher(15));
    System.out.println("First element < 15: " + ts.lower(15));
}

From source file:org.apache.hadoop.hbase.zookeeper.lock.HWriteLockImpl.java

/**
 * {@inheritDoc}/*ww  w.  j a  va 2 s. com*/
 */
@Override
protected String getLockPath(String createdZNode, List<String> children)
        throws IOException, InterruptedException {
    TreeSet<String> sortedChildren = new TreeSet<String>(new ZNodeComparator(zkWrapper.getIdentifier()));
    sortedChildren.addAll(children);
    String pathToWatch = sortedChildren.lower(createdZNode);
    if (pathToWatch != null) {
        String nodeHoldingLock = sortedChildren.first();
        try {
            handleLockMetadata(nodeHoldingLock);
        } catch (IOException e) {
            LOG.warn("Error processing lock metadata in " + nodeHoldingLock, e);
        }
    }
    return pathToWatch;
}

From source file:org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessWriteLock.java

/**
 * {@inheritDoc}/*from   w w  w.ja v a  2 s . c  o m*/
 */
@Override
protected String getLockPath(String createdZNode, List<String> children) throws IOException {
    TreeSet<String> sortedChildren = new TreeSet<String>(ZNodeComparator.COMPARATOR);
    sortedChildren.addAll(children);
    String pathToWatch = sortedChildren.lower(createdZNode);
    if (pathToWatch != null) {
        String nodeHoldingLock = sortedChildren.first();
        String znode = ZKUtil.joinZNode(parentLockNode, nodeHoldingLock);
        handleLockMetadata(znode);
    }
    return pathToWatch;
}

From source file:org.openmainframe.ade.scores.LastSeenLoggingScorerContinuous.java

/**
 * Processes the previous time line of the current message ID. 
 * @param messageID String value that contains the message ID
 * @param contextElement AnalyzedInterval object that contains summary results of interval.
 * @param sc Contains statistics for message ID.
 * @param timeLineSet time line of current message ID. 
 * @throws AdeInternalException/*w w w .ja  v a2  s . c  o m*/
 */
public void processPrevTimeLine(String messageID, IAnalyzedInterval contextElement, StatisticsChart sc,
        Set<Long> timeLineSet) throws AdeInternalException {
    final TreeSet<Long> prevTimeLine = m_prevIntervalTimelineMap.get(messageID);
    if (prevTimeLine == null) {
        m_mainStat = MainStatVal.NEW;
        m_deltasInSeconds
                .add((m_firstMsgTime - contextElement.getIntervalStartTime()) / DateTimeUtils.MILLIS_IN_SECOND);
    } else {
        final Long prevLastTime = prevTimeLine.lower(m_firstMsgTime);
        if (prevLastTime != null) {
            m_gc.setTimeInMillis(prevLastTime);
            sc.setStat("LastTime", String.valueOf(m_dataTypeFactory.newXMLGregorianCalendar(m_gc)));
            final long delta = (m_firstMsgTime - prevLastTime) / DateTimeUtils.MILLIS_IN_SECOND;
            m_deltasInSeconds.add(delta);
            timeLineSet.add(prevLastTime);
        }
    }
}