本文整理汇总了Java中java.util.concurrent.CopyOnWriteArraySet.add方法的典型用法代码示例。如果您正苦于以下问题:Java CopyOnWriteArraySet.add方法的具体用法?Java CopyOnWriteArraySet.add怎么用?Java CopyOnWriteArraySet.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.CopyOnWriteArraySet
的用法示例。
在下文中一共展示了CopyOnWriteArraySet.add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import java.util.concurrent.CopyOnWriteArraySet; //导入方法依赖的package包/类
@Before
public void setUp() {
initMocks(this);
final CopyOnWriteArraySet<String> copyOnWriteArraySet = new CopyOnWriteArraySet<>();
copyOnWriteArraySet.add("secret");
when(mockObjectStoreService.getIterable()).thenReturn(copyOnWriteArraySet);
jvmWinSvcAcctPasswordScrubberService = new JvmWinSvcAcctPasswordScrubberServiceImpl(mockObjectStoreService,
mockDecryptPassword);
}
示例2: populatedSet
import java.util.concurrent.CopyOnWriteArraySet; //导入方法依赖的package包/类
static CopyOnWriteArraySet<Integer> populatedSet(int n) {
CopyOnWriteArraySet<Integer> a = new CopyOnWriteArraySet<>();
assertTrue(a.isEmpty());
for (int i = 0; i < n; i++)
a.add(i);
assertEquals(n == 0, a.isEmpty());
assertEquals(n, a.size());
return a;
}
示例3: testToArray_ArrayStoreException
import java.util.concurrent.CopyOnWriteArraySet; //导入方法依赖的package包/类
/**
* toArray throws an ArrayStoreException when the given array can
* not store the objects inside the set
*/
public void testToArray_ArrayStoreException() {
CopyOnWriteArraySet c = new CopyOnWriteArraySet();
c.add("zfasdfsdf");
c.add("asdadasd");
try {
c.toArray(new Long[5]);
shouldThrow();
} catch (ArrayStoreException success) {}
}
示例4: populatedSet
import java.util.concurrent.CopyOnWriteArraySet; //导入方法依赖的package包/类
static CopyOnWriteArraySet<Integer> populatedSet(int n) {
CopyOnWriteArraySet<Integer> a = new CopyOnWriteArraySet<Integer>();
assertTrue(a.isEmpty());
for (int i = 0; i < n; i++)
a.add(i);
assertEquals(n == 0, a.isEmpty());
assertEquals(n, a.size());
return a;
}
示例5: init
import java.util.concurrent.CopyOnWriteArraySet; //导入方法依赖的package包/类
private void init()
{
execution = FunctionService.onMembers(region.getCache().getDistributedSystem());
int totalNumBuckets = region.getPartitionAttributes().getTotalNumBuckets();
routingKeySet = new CopyOnWriteArraySet();
for (int i = 0; i < totalNumBuckets; i++) {
routingKeySet.add(i);
}
}
示例6: convertSet
import java.util.concurrent.CopyOnWriteArraySet; //导入方法依赖的package包/类
public static <E> CopyOnWriteArraySet<E> convertSet(Set<E> set) {
CopyOnWriteArraySet<E> copySet = new CopyOnWriteArraySet<>();
for (E e : set) {
copySet.add(e);
}
return copySet;
}
示例7: onTransact
import java.util.concurrent.CopyOnWriteArraySet; //导入方法依赖的package包/类
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
switch(code) {
case TRANSACT_methodWithCOWArraySetParamAndHashSetReturn: {
data.enforceInterface(this.getInterfaceDescriptor());
final CopyOnWriteArraySet<Parcelable> objectListCollection;
final int objectListSize = data.readInt();
if (objectListSize < 0) {
objectListCollection = null;
} else {
objectListCollection = new CopyOnWriteArraySet<>();
for (int j = 0; j < objectListSize; j++) {
objectListCollection.add(data.readParcelable(getClass().getClassLoader()));
}
}
final Serializable returnValue = delegate.methodWithCOWArraySetParamAndHashSetReturn((CopyOnWriteArraySet) objectListCollection);
reply.writeNoException();
AidlUtil.writeToObjectStream(reply, returnValue);
return true;
}
}
return super.onTransact(code, data, reply, flags);
}
示例8: testEquals
import java.util.concurrent.CopyOnWriteArraySet; //导入方法依赖的package包/类
/**
* Sets with equal elements are equal
*/
public void testEquals() {
CopyOnWriteArraySet a = populatedSet(3);
CopyOnWriteArraySet b = populatedSet(3);
assertTrue(a.equals(b));
assertTrue(b.equals(a));
assertTrue(a.containsAll(b));
assertTrue(b.containsAll(a));
assertEquals(a.hashCode(), b.hashCode());
assertEquals(a.size(), b.size());
a.add(m1);
assertFalse(a.equals(b));
assertFalse(b.equals(a));
assertTrue(a.containsAll(b));
assertFalse(b.containsAll(a));
b.add(m1);
assertTrue(a.equals(b));
assertTrue(b.equals(a));
assertTrue(a.containsAll(b));
assertTrue(b.containsAll(a));
assertEquals(a.hashCode(), b.hashCode());
Object x = a.iterator().next();
a.remove(x);
assertFalse(a.equals(b));
assertFalse(b.equals(a));
assertFalse(a.containsAll(b));
assertTrue(b.containsAll(a));
a.add(x);
assertTrue(a.equals(b));
assertTrue(b.equals(a));
assertTrue(a.containsAll(b));
assertTrue(b.containsAll(a));
assertEquals(a.hashCode(), b.hashCode());
assertEquals(a.size(), b.size());
CopyOnWriteArraySet empty1 = new CopyOnWriteArraySet(Arrays.asList());
CopyOnWriteArraySet empty2 = new CopyOnWriteArraySet(Arrays.asList());
assertTrue(empty1.equals(empty1));
assertTrue(empty1.equals(empty2));
assertFalse(empty1.equals(a));
assertFalse(a.equals(empty1));
assertFalse(a.equals(null));
}