当前位置: 首页>>代码示例>>Java>>正文


Java CopyOnWriteArraySet.add方法代码示例

本文整理汇总了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);
}
 
开发者ID:cerner,项目名称:jwala,代码行数:10,代码来源:JvmWinSvcAcctPasswordScrubberServiceImplTest.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:CopyOnWriteArraySetTest.java

示例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) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:CopyOnWriteArraySetTest.java

示例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;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:10,代码来源:CopyOnWriteArraySetTest.java

示例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);
	}
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:10,代码来源:AggregatorPeer.java

示例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;
}
 
开发者ID:annefried,项目名称:swan,代码行数:8,代码来源:Utility.java

示例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);
}
 
开发者ID:chdir,项目名称:aidl2,代码行数:28,代码来源:ConcreteSetTypeArgsAndTypeLoss$$AidlServerImpl.java

示例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));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:CopyOnWriteArraySetTest.java


注:本文中的java.util.concurrent.CopyOnWriteArraySet.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。