Collection size - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:size
        } 
        if (value instanceof String) {
            return value.toString().trim().length() > 0;
        } 
        if (value instanceof Collection<?>) {
            return ((Collection<?>)value).size() > 0;
        } 
        if (value instanceof BinaryField) {
            return ((BinaryField)value).exists();
        } 
        if (value.getClass().isArray()) {
            try { 
                return java.lang.reflect.Array.getLength(value) > 0;
            } catch(Exception e) {
                throw new UnexpectedException(e);
            } 
        } 
        return true; 
    } 
} 
8
CodeRank
This code example shows how to use the following methods:size
    this(new DataList(initialCapacity));
  } 
 
  public LongArray(Collection<Long> c)
  { 
    this(new DataList(c.size()));
    addAll(c);
  } 
 
  public LongArray(DataList list)
  { 
    super(list, SCHEMA, Long.class, Long.class);
  } 
 
  @Override 
  public LongArray clone() throws CloneNotSupportedException 
  { 
    return (LongArray) super.clone(); 
  } 
 
8
CodeRank
This code example shows how to use the following methods:iterator, size
    Assert.assertEquals(jackFollowings.size(), 1);
 
    ODocument loadedKim = jackFollowings.iterator().next();
    Assert.assertEquals(loadedKim.field("name"), "Kim");
    Collection<ODocument> kimFollowings = loadedKim.field("following");
    Assert.assertNotNull(kimFollowings);
    Assert.assertEquals(kimFollowings.size(), 1);
 
    ODocument loadedTeri = kimFollowings.iterator().next();
    Assert.assertEquals(loadedTeri.field("name"), "Teri");
    Collection<ODocument> teriFollowings = loadedTeri.field("following");
    Assert.assertNotNull(teriFollowings);
    Assert.assertEquals(teriFollowings.size(), 1);
 
    Assert.assertEquals(teriFollowings.iterator().next().field("name"), "Jack");
 
    db.close();
  } 
} 
8
CodeRank
This code example shows how to use the following methods:size, empty, peek, get
		screen.setParent( this );
		m_children.add( m_children.size( ), screen );
	} 
 
	private void sendPopEvent() { 
		if( m_screenStack.empty( ) )
		{ 
			return; 
		} 
 
		// Only pop and send events if the stack is not empty 
		int poppedToScreenHandle = getHandle( );
		if( m_screenStack.size( ) >= 2 )
		{ 
			// Get the previous screen before the last one. 
			poppedToScreenHandle = m_screenStack.get(m_screenStack.size()-2).getHandle();
		} 
 
		EventQueue.getDefault( ).postWidgetStackScreenPoppedEvent( 
				getHandle(), 

7
CodeRank
This code example shows how to use the following methods:size
        delegate = Collections.checkedList(new ArrayList<T>(), valueClass);
        this.valueClass = valueClass;
    } 
 
    public AttachmentList(final Collection<? extends T> c, final Class<T> valueClass) {
        delegate = Collections.checkedList(new ArrayList<T>(c.size()), valueClass);
        delegate.addAll(c);
        this.valueClass = valueClass;
    } 
 
    public Class<T> getValueClass() {
        return valueClass;
    } 
 
    public int size() { 
        return delegate.size();
    } 
 
    public boolean isEmpty() { 
        return delegate.isEmpty();
7
CodeRank
This code example shows how to use the following methods:iterator, size
	 * Convert the collection of caches in a single expected element. 
	 * <p>Throw an {@link IllegalStateException} if the collection holds more than one element 
	 * @return the singe element or {@code null} if the collection is empty 
	 */ 
	static Cache extractFrom(Collection<? extends Cache> caches) {
		if (CollectionUtils.isEmpty(caches)) {
			return null; 
		} 
		else if (caches.size() == 1) {
			return caches.iterator().next();
		} 
		else { 
			throw new IllegalStateException("Unsupported cache resolution result " + caches +
					": JSR-107 only supports a single cache."); 
		} 
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:size
    this(new DataList(initialCapacity));
  } 
 
  public StringArray(Collection<String> c)
  { 
    this(new DataList(c.size()));
    addAll(c);
  } 
 
  public StringArray(DataList list)
  { 
    super(list, SCHEMA, String.class, String.class);
  } 
 
  @Override 
  public StringArray clone() throws CloneNotSupportedException 
  { 
    return (StringArray) super.clone(); 
  } 
 
8
CodeRank
This code example shows how to use the following methods:contains, size
    assertEquals("Incorrect navigableKeySet()", 1, set.size());
    assertTrue("Incorrect navigableKeySet()", set.contains(jobId));
 
    // check values() 
    Collection<HistoryFileInfo> values = mapWithSize.values();
    assertEquals("Incorrect values()", 1, values.size());
    assertTrue("Incorrect values()", values.contains(fileInfo1));
  } 
} 
7
CodeRank
This code example shows how to use the following methods:size
 
    protected int totalBlockFor() 
    { 
        // During bootstrap, we have to include the pending endpoints or we may fail the consistency level 
        // guarantees (see #833) 
        return consistencyLevel.blockFor(keyspace) + pendingEndpoints.size();
    } 
 
    protected abstract int ackCount(); 
 
    /** null message means "response from local write" */ 
    public abstract void response(MessageIn msg);
 
    public void assureSufficientLiveNodes() throws UnavailableException 
    { 
        consistencyLevel.assureSufficientLiveNodes(keyspace, Iterables.filter(Iterables.concat(naturalEndpoints, pendingEndpoints), isAlive));
    } 
 
    protected void signal() 
    { 
8
CodeRank
This code example shows how to use the following methods:size, toArray
size Method Overview
Returns the number of elements in this collection.
See Code Examples for other Java 8 Collection Methods: