本文整理汇总了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));
// }
}
示例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());
}
示例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));
}
}
示例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());
}
示例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);
});
}
示例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);
}
示例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;
}
}
示例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());
}
示例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());
}
示例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));
}
}
示例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));
}
示例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));
}
示例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());
}
示例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)));
}
示例15: getSet
import com.hazelcast.core.ISet; //导入依赖的package包/类
@Override
public <E> ISet<E> getSet(String s) {
return null;
}