Java SortedSet Usage findLT(SortedSet ss, T x)

Here you can find the source of findLT(SortedSet ss, T x)

Description

Finds the largest value that is smaller than x in a SortedSet

License

Creative Commons License

Parameter

Parameter Description
T a parameter
ss a SortedSet
x the value to search for

Return

the largest value in ss that is less than x, or null if no such value exists

Declaration

protected static <T> T findLT(SortedSet<T> ss, T x) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

import java.util.SortedSet;

public class Main {
    /**/*from ww  w . jav a  2s.  co  m*/
     * Finds the largest value that is smaller than x in a SortedSet
     * 
     * @param <T>
     * @param ss
     *            a SortedSet
     * @param x
     *            the value to search for
     * @return the largest value in ss that is less than x, or null if no such
     *         value exists
     */
    protected static <T> T findLT(SortedSet<T> ss, T x) {
        SortedSet<T> p = ss.headSet(x);
        return p.isEmpty() ? null : p.last();
    }
}

Related

  1. concatStringList(SortedSet sortedDependencies)
  2. findPositionFor(final T item, final SortedSet values)
  3. firstOrNull(SortedSet set)
  4. nextValue(SortedSet valueSet, int startValue)
  5. sortedSetIsAssignableFrom(Class aClass)