NavigableSet ceiling - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for NavigableSet ceiling method.

This code example shows how to use the following methods:ceiling, floor, higher, lower, add
 
public class SortedSetDemo 
{ 
  public static void main( String[] args )
  { 
    NavigableSet<Calendar> set = new TreeSet<Calendar>();
    set.add( new GregorianCalendar(2007, Calendar.MARCH, 10) );
    set.add( new GregorianCalendar(2007, Calendar.MARCH, 12) );
    set.add( new GregorianCalendar(2007, Calendar.APRIL, 12) );
     
    Calendar cal1 = set.lower( new GregorianCalendar(2007, Calendar.MARCH, 12) );
    System.out.printf( "%tF%n", cal1 );   // 2007-03-10
     
    Calendar cal2 = set.ceiling( new GregorianCalendar(2007, Calendar.MARCH, 12) );
    System.out.printf( "%tF%n", cal2 );   // 2007-03-12
     
    Calendar cal3 = set.floor( new GregorianCalendar(2007, Calendar.MARCH, 12) );
    System.out.printf( "%tF%n", cal3 );   // 2007-03-12
 
    Calendar cal4 = set.higher( new GregorianCalendar(2007, Calendar.MARCH, 12) );

6
CodeRank
This code example shows how to use the following methods:ceiling, floor, higher, lower
    assertNull(navigableSet.pollFirst());
  } 
 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetNearby() { 
    assertNull(navigableSet.lower(samples.e0));
    assertNull(navigableSet.floor(samples.e0));
    assertNull(navigableSet.ceiling(samples.e0));
    assertNull(navigableSet.higher(samples.e0));
  } 
 
  @CollectionFeature.Require(SUPPORTS_REMOVE) 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetPollLast() { 
    assertNull(navigableSet.pollLast());
  } 
 
  @CollectionFeature.Require(SUPPORTS_REMOVE) 
  @CollectionSize.Require(ONE) 
  public void testSingletonSetPollFirst() { 
6
CodeRank
This code example shows how to use the following methods:ceiling, floor, higher, lower
    assertNull(navigableSet.pollFirst());
  } 
 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetNearby() { 
    assertNull(navigableSet.lower(samples.e0));
    assertNull(navigableSet.floor(samples.e0));
    assertNull(navigableSet.ceiling(samples.e0));
    assertNull(navigableSet.higher(samples.e0));
  } 
 
  @CollectionFeature.Require(SUPPORTS_REMOVE) 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetPollLast() { 
    assertNull(navigableSet.pollLast());
  } 
 
  @CollectionFeature.Require(SUPPORTS_REMOVE) 
  @CollectionSize.Require(ONE) 
  public void testSingletonSetPollFirst() { 
5
CodeRank
This code example shows how to use the following methods:ceiling, floor, higher, lower
    assertNull(navigableSet.pollFirst());
  } 
 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetNearby() { 
    assertNull(navigableSet.lower(samples.e0));
    assertNull(navigableSet.floor(samples.e0));
    assertNull(navigableSet.ceiling(samples.e0));
    assertNull(navigableSet.higher(samples.e0));
  } 
 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetLast() { 
    try { 
      navigableSet.last();
      fail(); 
    } catch (NoSuchElementException e) {
    } 
  } 
 
5
CodeRank
This code example shows how to use the following methods:ceiling, floor, higher, lower
    assertNull(navigableSet.pollFirst());
  } 
 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetNearby() { 
    assertNull(navigableSet.lower(samples.e0));
    assertNull(navigableSet.floor(samples.e0));
    assertNull(navigableSet.ceiling(samples.e0));
    assertNull(navigableSet.higher(samples.e0));
  } 
 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetLast() { 
    try { 
      navigableSet.last();
      fail(); 
    } catch (NoSuchElementException e) {
    } 
  } 
 
5
CodeRank
This code example shows how to use the following methods:ceiling, floor, higher, lower
    assertNull(navigableSet.pollFirst());
  } 
 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetNearby() { 
    assertNull(navigableSet.lower(e0()));
    assertNull(navigableSet.floor(e0()));
    assertNull(navigableSet.ceiling(e0()));
    assertNull(navigableSet.higher(e0()));
  } 
 
  @CollectionFeature.Require(SUPPORTS_REMOVE) 
  @CollectionSize.Require(ZERO) 
  public void testEmptySetPollLast() { 
    assertNull(navigableSet.pollLast());
  } 
 
  @CollectionFeature.Require(SUPPORTS_REMOVE) 
  @CollectionSize.Require(ONE) 
  public void testSingletonSetPollFirst() { 
5
CodeRank
This code example shows how to use the following methods:ceiling, comparator
    } 
    return delegate.addAll(collection);
  } 
 
  @Override public E ceiling(E e) {
    return delegate.ceiling(checkValid(e));
  } 
 
  @Override public void clear() { 
    delegate.clear();
  } 
 
  @SuppressWarnings("unchecked") 
  @Override public Comparator<? super E> comparator() {
    Comparator<? super E> comparator = delegate.comparator();
    if (comparator == null) {
      comparator = NATURAL_ORDER;
    } 
    return comparator;
  } 
5
CodeRank
This code example shows how to use the following methods:ceiling
    return Iterators.getNext(headSet(e, true).descendingIterator(), null);
  } 
 
  @Override 
  public E ceiling(E e) {
    return delegate().ceiling(e);
  } 
 
  /** 
   * A sensible definition of {@link #ceiling} in terms of the {@code iterator} method of 
   * {@link #tailSet(Object, boolean)}. If you override {@link #tailSet(Object, boolean)}, you may 
   * wish to override {@link #ceiling} to forward to this implementation. 
   */ 
  protected E standardCeiling(E e) {
    return Iterators.getNext(tailSet(e, true).iterator(), null);
  } 
 
  @Override 
  public E higher(E e) {
    return delegate().higher(e);
5
CodeRank
This code example shows how to use the following methods:ceiling, add, toArray
  } 
 
  public void testCeiling() { 
    NavigableSet<E> set = createNavigableSet();
 
    set.add(getKeys()[0]);
    assertEquals(getKeys()[0], set.ceiling(getKeys()[0]));
    assertEquals(getKeys()[0], set.ceiling(getLessThanMinimumKey()));
    assertEquals(set.toArray()[0], set.ceiling(getLessThanMinimumKey()));
 
    set.add(getKeys()[1]);
    assertEquals(getKeys()[0], set.ceiling(getLessThanMinimumKey()));
    assertEquals(getKeys()[0], set.ceiling(getKeys()[0]));
    assertEquals(getKeys()[1], set.ceiling(getKeys()[1]));
    assertEquals(null, set.ceiling(getGreaterThanMaximumKey()));
  } 
 
  /** 
   * Test method for 'java.util.Set.clear()'. 
   *  
5
CodeRank
This code example shows how to use the following methods:ceiling, first
    public ValueResult getTimeAfter(final Calendar afterTimeCalendar) {
 
        ValueResult valueResult = new ValueResult();
        int currentFieldValue = afterTimeCalendar.get(getCalendarField());
 
        Integer foundValue = this.allValues.ceiling(currentFieldValue);
        if (foundValue != null) {
            valueResult.setResult(foundValue.intValue());
        } else { 
            // use the next first available value 
            valueResult.setResult(this.allValues.first());
            valueResult.setNeedsIncrement(true);
        } 
        return valueResult;
    } 
 
 
 
    /** 
     * @return string representation 
5
CodeRank
ceiling Method Overview
Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
See Code Examples for other Java 8 NavigableSet Methods: