本文整理了Java中org.apache.commons.collections.Buffer.size()
方法的一些代码示例,展示了Buffer.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.size()
方法的具体详情如下:
包路径:org.apache.commons.collections.Buffer
类名称:Buffer
方法名:size
暂无
代码示例来源:origin: commons-collections/commons-collections
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException(
"Buffer size cannot exceed " + maximumSize);
while (timeLeft > 0 && getBuffer().size() + nAdditions > maximumSize) {
try {
lock.wait(timeLeft);
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException("Timeout expired");
代码示例来源:origin: wildfly/wildfly
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException(
"Buffer size cannot exceed " + maximumSize);
while (timeLeft > 0 && getBuffer().size() + nAdditions > maximumSize) {
try {
lock.wait(timeLeft);
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException("Timeout expired");
代码示例来源:origin: commons-collections/commons-collections
public void testTransformedBuffer() {
Buffer buffer = TransformedBuffer.decorate(new ArrayStack(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(0, buffer.size());
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
for (int i = 0; i < els.length; i++) {
buffer.add(els[i]);
assertEquals(i + 1, buffer.size());
assertEquals(true, buffer.contains(new Integer((String) els[i])));
assertEquals(false, buffer.contains(els[i]));
}
assertEquals(false, buffer.remove(els[0]));
assertEquals(true, buffer.remove(new Integer((String) els[0])));
}
}
代码示例来源:origin: commons-collections/commons-collections
public void testAddAllToFullBufferRemoveViaIterator() {
final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 2, 500);
bounded.add( "Hello" );
bounded.add( "World" );
new DelayedIteratorRemove( bounded, 200, 2 ).start();
bounded.addAll( Arrays.asList( new String[] { "Foo", "Bar" } ) );
assertEquals( 2, bounded.size() );
assertEquals( "Foo", bounded.remove() );
assertEquals( "Bar", bounded.remove() );
}
代码示例来源:origin: commons-collections/commons-collections
public void testBufferEmpty() {
resetEmpty();
Buffer buffer = (Buffer) collection;
assertEquals(0, buffer.size());
assertEquals(true, buffer.isEmpty());
try {
buffer.get();
fail();
} catch (BufferUnderflowException ex) {}
try {
buffer.remove();
fail();
} catch (BufferUnderflowException ex) {}
}
代码示例来源:origin: commons-collections/commons-collections
public void testAddToFullBufferRemoveViaIterator() {
final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 1, 500);
bounded.add( "Hello" );
new DelayedIteratorRemove( bounded, 200 ).start();
bounded.add( "World" );
assertEquals( 1, bounded.size() );
assertEquals( "World", bounded.get() );
}
代码示例来源:origin: commons-collections/commons-collections
public void testAddAllToFullBufferWithTimeout() {
final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 2, 500);
bounded.add( "Hello" );
bounded.add( "World" );
new DelayedRemove( bounded, 200, 2 ).start();
bounded.addAll( Arrays.asList( new String[] { "Foo", "Bar" } ) );
assertEquals( 2, bounded.size() );
assertEquals( "Foo", bounded.get() );
try {
bounded.add( "!" );
fail();
}
catch( BufferOverflowException e ) {
}
}
代码示例来源:origin: commons-collections/commons-collections
public void testAddToFullBufferWithTimeout() {
final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 1, 500);
bounded.add( "Hello" );
new DelayedRemove( bounded, 200 ).start();
bounded.add( "World" );
assertEquals( 1, bounded.size() );
assertEquals( "World", bounded.get() );
try {
bounded.add( "!" );
fail();
}
catch( BufferOverflowException e ) {
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-search-lucene-api
/**
* Returns the number of elements in the queue.
*
* @return Number of elements in the queue.
*/
public synchronized int getSize()
{
return this.namesQueue.size();
}
}
代码示例来源:origin: PerfCake/PerfCake
@Override
public Double getResult() {
double accum = 0;
double size;
synchronized (fifo) {
for (final Object o : fifo) {
accum = accum + (Double) o;
}
size = fifo.size();
}
return size == 0 ? 0d : accum / size;
}
}
代码示例来源:origin: PerfCake/PerfCake
@Override
public Double getResult() {
double accum = 0;
double size;
synchronized (fifo) {
for (final Object o : fifo) {
accum = accum + (Double) o;
}
size = fifo.size();
}
return size == 0 ? 0d : size / accum;
}
}
代码示例来源:origin: com.atlassian.core/atlassian-core
public int size() {
return buffer.size();
}
代码示例来源:origin: org.apache.excalibur.components/excalibur-pool-impl
public final int size()
{
synchronized( this )
{
// this is actually not 100% correct as the pool should always
// reflect the current size (i.e. m_ready.size()) and not the
// total size.
return this.m_active.size() + this.m_ready.size();
}
}
代码示例来源:origin: PerfCake/PerfCake
@Override
public synchronized Double getResult() {
double max = Double.MIN_VALUE;
synchronized (fifo) {
for (final Object o : fifo) {
max = Math.max(max, (Double) o);
}
}
return fifo.size() == 0 ? Double.NaN : max;
}
}
代码示例来源:origin: PerfCake/PerfCake
@Override
public Double getResult() {
double min = Double.POSITIVE_INFINITY;
synchronized (fifo) {
for (final Object o : fifo) {
min = Math.min(min, (Double) o);
}
}
return fifo.size() == 0 ? Double.NaN : min;
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException(
"Buffer size cannot exceed " + maximumSize);
while (timeLeft > 0 && getBuffer().size() + nAdditions > maximumSize) {
try {
lock.wait(timeLeft);
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException("Timeout expired");
代码示例来源:origin: org.jboss.eap/wildfly-client-all
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException(
"Buffer size cannot exceed " + maximumSize);
while (timeLeft > 0 && getBuffer().size() + nAdditions > maximumSize) {
try {
lock.wait(timeLeft);
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException("Timeout expired");
代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException(
"Buffer size cannot exceed " + maximumSize);
while (timeLeft > 0 && getBuffer().size() + nAdditions > maximumSize) {
try {
lock.wait(timeLeft);
if (getBuffer().size() + nAdditions > maximumSize) {
throw new BufferOverflowException("Timeout expired");
代码示例来源:origin: org.apache.excalibur.components/excalibur-pool-impl
protected void internalShrink( final int amount )
throws Exception
{
for( int i = 0; i < amount; i++ )
{
if( m_ready.size() > m_min )
{
try
{
this.removePoolable( (Poolable)m_ready.remove() );
}
catch( final Exception e )
{
if( null != getLogger() && getLogger().isDebugEnabled() )
{
getLogger().debug( m_factory.getCreatedClass().getName() +
": improperly decommissioned.", e );
}
}
}
}
}
}
代码示例来源:origin: org.apache.excalibur.components/excalibur-pool-impl
public final void dispose()
{
try
{
m_mutex.acquire();
try
{
while( m_ready.size() > 0 )
{
this.removePoolable( (Poolable)m_ready.remove() );
}
}
finally
{
m_mutex.release();
}
}
catch( Exception e )
{
if( getLogger().isWarnEnabled() )
{
getLogger().warn( "Caught an exception disposing of pool", e );
}
}
this.m_disposed = true;
}
}
内容来源于网络,如有侵权,请联系作者删除!