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


Java ISet类代码示例

本文整理汇总了Java中com.hazelcast.core.ISet的典型用法代码示例。如果您正苦于以下问题:Java ISet类的具体用法?Java ISet怎么用?Java ISet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ISet类属于com.hazelcast.core包,在下文中一共展示了ISet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: destroy

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
    public void destroy() {
        HazelcastClient hClient = getHazelcastClient();
        ISet<Integer> set = hClient.getSet("destroy");
        for (int i = 0; i < 100; i++) {
            assertTrue(set.add(i));
        }
        ISet<Integer> set2 = hClient.getSet("destroy");
        assertTrue(set == set2);
        assertTrue(set.getId().equals(set2.getId()));
        set.destroy();
        set2 = hClient.getSet("destroy");
        assertFalse(set == set2);
//        for(int i=0;i<100;i++){
//        	assertNull(list2.get(i));
//        }
    }
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:18,代码来源:HazelcastClientSetTest.java

示例2: size

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void size() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("size");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    for (int i = 0; i < count / 2; i++) {
        assertFalse(set.add(i));
    }
    assertFalse(set.isEmpty());
    assertEquals(count, set.size());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:17,代码来源:HazelcastClientSetTest.java

示例3: remove

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void remove() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("remove");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    for (int i = 0; i < count; i++) {
        assertTrue(set.remove((Object) i));
    }
    assertTrue(set.isEmpty());
    for (int i = count; i < 2 * count; i++) {
        assertFalse(set.remove((Object) i));
    }
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:19,代码来源:HazelcastClientSetTest.java

示例4: iterate

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void iterate() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("iterate");
    set.add(1);
    set.add(2);
    set.add(2);
    set.add(3);
    assertEquals(3, set.size());
    Map<Integer, Integer> counter = new HashMap<Integer, Integer>();
    counter.put(1, 1);
    counter.put(2, 1);
    counter.put(3, 1);
    for (Iterator<Integer> iterator = set.iterator(); iterator.hasNext(); ) {
        Integer integer = iterator.next();
        counter.put(integer, counter.get(integer) - 1);
        iterator.remove();
    }
    assertEquals(Integer.valueOf(0), counter.get(1));
    assertEquals(Integer.valueOf(0), counter.get(2));
    assertEquals(Integer.valueOf(0), counter.get(3));
    assertTrue(set.isEmpty());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:24,代码来源:HazelcastClientSetTest.java

示例5: execute

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Override
protected void execute(String... args) {
    withHazelcast(hazelcast -> {
        String name = "default";
        ISet<Integer> set = hazelcast.getSet(name);

        if (args.length > 0) {
            if ("master".equals(args[0])) {
                IntStream.rangeClosed(1, 10).forEach(set::add);
            }
        }

        readConsoleWhile(hazelcast,
                name,
                () -> {
                    set.forEach(e -> show("element = %d.", e));
                    return null;
                },
                set::size);
    });
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:22,代码来源:HazelcastSetInterpreter.java

示例6: getISet

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <E> ISet<E> getISet(String name)
{
    name = Objects.requireNonNull(name);

    final ISet<E> valu = getBeanSafely(name, ISet.class);

    if (null != valu)
    {
        return valu;
    }
    return hz().getSet(name);
}
 
开发者ID:ahome-it,项目名称:ahome-tooling-server-hazelcast,代码行数:15,代码来源:HazelcastContextInstance.java

示例7: equals

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Override
public boolean equals(Object o) {
    if (o instanceof ISet && o != null) {
        return getName().equals(((ISet) o).getName());
    } else {
        return false;
    }
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:9,代码来源:SetClientProxy.java

示例8: addRemoveItemListener

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void addRemoveItemListener() throws InterruptedException {
    HazelcastClient hClient = getHazelcastClient();
    final ISet<String> set = hClient.getSet("addRemoveItemListenerSet");
    final CountDownLatch addLatch = new CountDownLatch(2);
    final CountDownLatch removeLatch = new CountDownLatch(2);
    ItemListener<String> listener = new CountDownItemListener<String>(addLatch, removeLatch);
    set.addItemListener(listener, true);
    set.add("hello");
    set.add("hello");
    set.remove("hello");
    set.remove("hello");
    for (int i = 0; i < 100; i++) {
        if (removeLatch.getCount() != 1 || addLatch.getCount() != 1) {
            Thread.sleep(50);
        } else {
            break;
        }
    }
    assertEquals(1, removeLatch.getCount());
    assertEquals(1, addLatch.getCount());
    set.removeItemListener(listener);
    set.add("hello");
    set.add("hello");
    set.remove("hello");
    set.remove("hello");
    Thread.sleep(50);
    assertEquals(1, addLatch.getCount());
    assertEquals(1, removeLatch.getCount());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:31,代码来源:HazelcastClientSetTest.java

示例9: add

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void add() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("add");
    int count = 100;
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    for (int i = 0; i < count; i++) {
        assertFalse(set.add(i));
    }
    assertEquals(count, set.size());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:14,代码来源:HazelcastClientSetTest.java

示例10: contains

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void contains() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("contains");
    int count = 100;
    for (int i = 0; i < count; i++) {
        set.add(i);
    }
    for (int i = 0; i < count; i++) {
        assertTrue(set.contains(i));
    }
    for (int i = count; i < 2 * count; i++) {
        assertFalse(set.contains(i));
    }
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:16,代码来源:HazelcastClientSetTest.java

示例11: addAll

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void addAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("addAll");
    List<Integer> arr = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arr.add(i);
    }
    assertTrue(set.addAll(arr));
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:12,代码来源:HazelcastClientSetTest.java

示例12: containsAll

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void containsAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("containsAll");
    List<Integer> arrList = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arrList.add(i);
    }
    assertTrue(set.addAll(arrList));
    assertTrue(set.containsAll(arrList));
    arrList.set((int) count / 2, count + 1);
    assertFalse(set.containsAll(arrList));
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:15,代码来源:HazelcastClientSetTest.java

示例13: clear

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void clear() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("clear");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    set.clear();
    assertTrue(set.isEmpty());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:14,代码来源:HazelcastClientSetTest.java

示例14: removeAll

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Test
public void removeAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("removeAll");
    List<Integer> arrList = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arrList.add(i);
    }
    assertTrue(set.addAll(arrList));
    assertTrue(set.removeAll(arrList));
    assertFalse(set.removeAll(arrList.subList(0, count / 10)));
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:14,代码来源:HazelcastClientSetTest.java

示例15: getSet

import com.hazelcast.core.ISet; //导入依赖的package包/类
@Override
public <E> ISet<E> getSet(String s) {
    return null;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:5,代码来源:WebConfigurerIntTest.java


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