Java 8 SortedSet - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SortedSet class.

This code example shows how to use the following methods:comparator
	public boolean addAll(Collection<? extends E> c) {
		// Use linear-time version if applicable 
		if (m.size() == 0 && c.size() > 0 && c instanceof SortedSet && m instanceof OMVRBTree) {
			SortedSet<? extends E> set = (SortedSet<? extends E>) c;
			OMVRBTree<E, Object> map = (OMVRBTree<E, Object>) m;
			Comparator<? super E> cc = (Comparator<? super E>) set.comparator();
			Comparator<? super E> mc = map.comparator();
			if (cc == mc || (cc != null && cc.equals(mc))) {
				map.addAllForOTreeSet(set, PRESENT);
				return true; 
			} 
		} 
		return super.addAll(c);
	} 
 
	/** 
	 * @throws ClassCastException 
	 *           {@inheritDoc} 
	 * @throws NullPointerException 
	 *           if {@code fromElement} or {@code toElement} is null and this set uses natural ordering, or its comparator does not 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add
    if (child.parent != null) {
      throw new IllegalArgumentException(
          "The child is already under another node:" + child.parent);
    } 
    checkChildren(); 
    boolean retval = children.add(child);
    if (retval) child.parent = this;
    return retval;
  } 
 
  /** 
   * Does this node have any children? 
   * @return Boolean indicate whether this node has any children. 
   */ 
  public synchronized boolean hasChildren() { 
    return children != null && !children.isEmpty();
  } 
 
  /** 
   * Get the children of this node. 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isEmpty, first, tailSet
    if(confException != null) {
      LOG.error(confException.getMessage(), confException);
      return -1; 
    } 
 
    if(tabletInfoSet.isEmpty()) {
      LOG.error("tablet partition size is zero");
      return -1; 
    } 
    int partitionNumber = 0;
    Row.Key rowKey = new Row.Key(key.toString());
     
    SortedSet<RowKeyItem> tailSet = tabletInfoSet.tailSet(new RowKeyItem(rowKey, 0));
    if(!tailSet.isEmpty()) {
      partitionNumber = tailSet.first().index;
    } else { 
      partitionNumber = tabletInfoSet.last().index;
    } 
     
    if(partitionNumber >= numPartitions) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:comparator
		} 
		else if (collection instanceof List) {
			return new ArrayList<E>(initialCapacity);
		} 
		else if (collection instanceof SortedSet) {
			return new TreeSet<E>(((SortedSet<E>) collection).comparator());
		} 
		else { 
			return new LinkedHashSet<E>(initialCapacity);
		} 
	} 
 
	/** 
	 * Create the most appropriate collection for the given collection type. 
	 * <p>Creates an ArrayList, TreeSet or linked Set for a List, SortedSet 
	 * or Set, respectively. 
	 * @param collectionType the desired type of the target Collection 
	 * @param initialCapacity the initial capacity 
	 * @return the new Collection instance 
	 * @see java.util.ArrayList 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isEmpty, first
     *        whether the value being retrieved should be percent decoded 
     * @return the first value found for this parameter 
     */ 
    public String getFirst(Object key, boolean percentDecode) {
        SortedSet<String> values = wrappedMap.get(key);
        if (values == null || values.isEmpty()) {
            return null; 
        } 
        String value = values.first();
        return percentDecode ? OAuth.percentDecode(value) : value;
    } 
 
    /** 
     * Concatenates all values for the given key to a list of key/value pairs 
     * suitable for use in a URL query string. 
     *  
     * @param key 
     *        the parameter name 
     * @return the query string 
     */ 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add, isEmpty, size, toArray
    public synchronized Filter addFilter(final Filter filter, 
            final Long filterId, final int order, final String orderSource) {
        if (filterList == null) {
            filterList = new TreeSet<FilterHandle>();
        } 
        filterList.add(new FilterHandle(filter, filterId, order, orderSource));
        filters = getFiltersInternal();
        return filter; 
    } 
 
    public synchronized boolean removeFilterById(final Object filterId) { 
        if (filterList != null) {
            for (Iterator<FilterHandle> fi = filterList.iterator(); fi.hasNext();) {
                FilterHandle test = fi.next();
                if (test.getFilterId() == filterId
                    || (test.getFilterId() != null && test.getFilterId().equals(
                        filterId))) { 
                    fi.remove();
                    filters = getFiltersInternal();
                    return true; 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
      } else if (!id.equals(other.id))
         return false; 
      if (tasks == null) {
         if (other.tasks != null)
            return false; 
      } else if (!tasks.equals(other.tasks))
         return false; 
      return true; 
   } 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add, isEmpty, remove, first
    assertEquals(0, new VersionString("3.0").compareTo(new VersionString("3")));
    assertEquals(+1, new VersionString("1.8.11").compareTo(new VersionString("1.8")));
  } 
 
  public void testSorting() throws Exception { 
    SortedSet<VersionString> set = new TreeSet<VersionString>();
    set.add(v3);
    set.add(v0);
    set.add(v1);
    set.add(v4);
    set.add(v2);
    assertEquals(v0, set.first());
    assertTrue(set.remove(v0));
    assertEquals(v1, set.first());
    assertTrue(set.remove(v1));
    assertEquals(v2, set.first());
    assertTrue(set.remove(v2));
    assertEquals(v3, set.first());
    assertTrue(set.remove(v3));
    assertEquals(v4, set.first());

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:contains, remove, first, last
		navigableMap.put("ka", "xx");
		navigableMap.put("kb", "aa");
		navigableMap.put("kc", "zz");
		final NavigableSet<String> navigableSet = navigableMap
				.navigableKeySet();
		assertEquals("bad first element", "ka", navigableSet.first());
		assertEquals("bad last element", "kc", navigableSet.last());
		assertTrue(MUST_CONTAINS_KA, navigableSet.contains("ka"));
		assertTrue(MUST_CONTAINS_KB, navigableSet.contains("kb"));
		assertTrue(MUST_CONTAINS_KC, navigableSet.contains("kc"));
 
		navigableSet.remove("kb");
		assertEquals(BAD_SIZE, 2, navigableMap.size());
		assertFalse(MUST_NOT_BE_EMPTY, navigableMap.isEmpty());
		assertTrue("must contains key 'ka'", navigableMap.containsKey("ka"));
		assertFalse("must not contains key 'kb'", navigableMap
				.containsKey("kb"));
		assertTrue("must contains key 'kc'", navigableMap.containsKey("kc"));
	} 
// TODO implement this 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isEmpty
    return internalSet.size();
  } 
 
  @Override 
  public boolean isEmpty() { 
    return internalSet.isEmpty();
  } 
 
  @Override 
  public boolean contains(Object o) { 
    return internalSet.contains(o);
  } 
 
  @Override 
  public Iterator<E> iterator() {
    return internalSet.iterator();
  } 
 
  @Override 
  public Object[] toArray() { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 SortedSet Methods: