本文整理了Java中org.apache.commons.collections.Buffer.addAll()
方法的一些代码示例,展示了Buffer.addAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.addAll()
方法的具体详情如下:
包路径:org.apache.commons.collections.Buffer
类名称:Buffer
方法名:addAll
暂无
代码示例来源:origin: commons-collections/commons-collections
public boolean addAll(final Collection c) {
synchronized (lock) {
timeoutWait(c.size());
return getBuffer().addAll(c);
}
}
代码示例来源:origin: wildfly/wildfly
public boolean addAll(final Collection c) {
synchronized (lock) {
timeoutWait(c.size());
return getBuffer().addAll(c);
}
}
代码示例来源:origin: commons-collections/commons-collections
public void run() {
try {
// wait for other thread to block on get() or remove()
Thread.sleep( delay );
}
catch( InterruptedException e ) {
}
buffer.addAll( Collections.singleton( obj ) );
}
}
代码示例来源:origin: commons-collections/commons-collections
public Collection makeFullCollection() {
Buffer buffer = new UnboundedFifoBuffer();
buffer.addAll(Arrays.asList(getFullElements()));
return SynchronizedBuffer.decorate(buffer);
}
代码示例来源:origin: commons-collections/commons-collections
public void testAddAllToEmptyBufferExceedMaxSizeNoTimeout() {
final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 1);
try {
bounded.addAll(Collections.nCopies(2, "test"));
fail();
} catch (BufferOverflowException e) {
}
}
代码示例来源:origin: commons-collections/commons-collections
public Collection makeFullCollection() {
Buffer buffer = new UnboundedFifoBuffer();
buffer.addAll(Arrays.asList(getFullElements()));
return UnmodifiableBuffer.decorate(buffer);
}
代码示例来源:origin: commons-collections/commons-collections
public void testAddAllToFullBufferNoTimeout() {
final Buffer bounded = BoundedBuffer.decorate(new UnboundedFifoBuffer(), 1);
bounded.add( "Hello" );
try {
bounded.addAll(Collections.singleton("World"));
fail();
} catch (BufferOverflowException e) {
}
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Tests {@link BlockingBuffer#remove()} in combination with {@link BlockingBuffer#addAll(java.util.Collection)}
* using multiple read threads.
* <p/>
* Two read threads should block on an empty buffer until a singleton collection is added then one thread should
* complete. The remaining thread should complete after the addition of a second singleton.
*/
public void testBlockedRemoveWithAddAll1() {
Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
Object obj = new Object();
// run methods will remove and compare -- must wait for addAll
Thread thread1 = new ReadThread( blockingBuffer, obj, null, "remove" );
Thread thread2 = new ReadThread( blockingBuffer, obj, null, "remove" );
thread1.start();
thread2.start();
// give hungry read threads ample time to hang
delay();
blockingBuffer.addAll( Collections.singleton( obj ) );
// allow notified threads to complete
delay();
// There should be one thread waiting.
assertTrue( "There is one thread waiting", thread1.isAlive() ^ thread2.isAlive() );
blockingBuffer.addAll( Collections.singleton( obj ) );
// allow notified thread to complete
delay();
// There should not be any threads waiting.
if( thread1.isAlive() || thread2.isAlive() ) {
fail( "Live thread(s) when both should be dead." );
}
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Tests {@link BlockingBuffer#remove()} in combination with {@link BlockingBuffer#addAll(java.util.Collection)}
* using multiple read threads.
* <p/>
* Two read threads should block on an empty buffer until a collection with two distinct objects is added then both
* threads should complete. Each thread should have read a different object.
*/
public void testBlockedRemoveWithAddAll2() {
Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
Object obj1 = new Object();
Object obj2 = new Object();
Set objs = Collections.synchronizedSet( new HashSet() );
objs.add( obj1 );
objs.add( obj2 );
// run methods will remove and compare -- must wait for addAll
Thread thread1 = new ReadThread( blockingBuffer, objs, "remove" );
Thread thread2 = new ReadThread( blockingBuffer, objs, "remove" );
thread1.start();
thread2.start();
// give hungry read threads ample time to hang
delay();
blockingBuffer.addAll( objs );
// allow notified threads to complete
delay();
assertEquals( "Both objects were removed", 0, objs.size() );
// There should not be any threads waiting.
if( thread1.isAlive() || thread2.isAlive() ) {
fail( "Live thread(s) when both should be dead." );
}
}
代码示例来源:origin: commons-collections/commons-collections
/**
* Tests {@link BlockingBuffer#get()} in combination with {@link BlockingBuffer#addAll(java.util.Collection)} using
* multiple read threads.
* <p/>
* Two read threads should block on an empty buffer until a singleton is added then both threads should complete.
*/
public void testBlockedGetWithAddAll() {
Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
Object obj = new Object();
// run methods will get and compare -- must wait for addAll
Thread thread1 = new ReadThread( blockingBuffer, obj );
Thread thread2 = new ReadThread( blockingBuffer, obj );
thread1.start();
thread2.start();
// give hungry read threads ample time to hang
delay();
// notifyAll should allow both read threads to complete
blockingBuffer.addAll( Collections.singleton( obj ) );
// allow notified threads to complete
delay();
// There should not be any threads waiting.
if( thread1.isAlive() || thread2.isAlive() ) {
fail( "Live thread(s) when both should be dead." );
}
}
代码示例来源: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 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: org.objectstyle.ashwood/ashwood
public void reset(Collection newFirstVertices, Attribute level) {
if (!queue.isEmpty()) queue.clear();
if (!seen.isEmpty()) seen.clear();
this.firstVertices = newFirstVertices;
this.level = level;
queue.addAll(firstVertices);
seen.addAll(firstVertices);
for (Iterator i = firstVertices.iterator(); i.hasNext(); ) {
level.set(i.next(), new Integer(0));
}
validTree = true;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-collections
public boolean addAll(final Collection c) {
synchronized (lock) {
timeoutWait(c.size());
return getBuffer().addAll(c);
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
public boolean addAll(final Collection c) {
synchronized (lock) {
timeoutWait(c.size());
return getBuffer().addAll(c);
}
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-all
public boolean addAll(final Collection c) {
synchronized (lock) {
timeoutWait(c.size());
return getBuffer().addAll(c);
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public boolean addAll(final Collection c) {
synchronized (lock) {
timeoutWait(c.size());
return getBuffer().addAll(c);
}
}
代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand
public boolean addAll(final Collection c) {
synchronized (lock) {
timeoutWait(c.size());
return getBuffer().addAll(c);
}
}
代码示例来源:origin: bioinformatics-ua/dicoogle
@SuppressWarnings("unchecked")
public InnerIterator(List<KeyValue> tempResults) {
int size = tempResults.size();
if(size <= 0)
size = 1;
resultBuffer = BufferUtils.blockingBuffer( new UnboundedFifoBuffer(size) );
resultBuffer.addAll(tempResults);
}
代码示例来源:origin: org.objectstyle.ashwood/ashwood
public void breadthFirstSort() {
Buffer queue = new UnboundedFifoBuffer();
Set seen = new HashSet();
queue.addAll(layers[0]);
seen.addAll(layers[0]);
int[] indices = new int[layers.length];
while (!queue.isEmpty()) {
LayerVertex origin = (LayerVertex)queue.remove();
origin.setIndexInLayer(indices[origin.getRank()]++);
for (int i = 0; i < origin.outDegree(); i++) {
Object dst = origin.getSuccessors().get(i);
if (seen.add(dst)) queue.add(dst);
}
}
for (int i = 0; i < layers.length; i++) {
layers[i].sort();
}
}
内容来源于网络,如有侵权,请联系作者删除!