本文整理匯總了Java中gnu.trove.set.TIntSet.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntSet.iterator方法的具體用法?Java TIntSet.iterator怎麽用?Java TIntSet.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.set.TIntSet
的用法示例。
在下文中一共展示了TIntSet.iterator方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testToArrayMatchesIteratorOrder
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testToArrayMatchesIteratorOrder() {
TIntSet set = new TIntOffheapHashSet();
int[] ints = {42, 1138, 13, 86, 99};
set.addAll(ints);
int[] toarray_ints = set.toArray();
int[] iter_ints = new int[5];
TIntIterator iter = set.iterator();
int index = 0;
while (iter.hasNext()) {
iter_ints[index++] = iter.next();
}
assertTrue(Arrays.equals(iter_ints, toarray_ints));
}
示例2: testToArrayMatchesIteratorOrder
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testToArrayMatchesIteratorOrder() {
TIntSet set = new TIntHashSet();
int[] ints = {42, 1138, 13, 86, 99};
set.addAll(ints);
int[] toarray_ints = set.toArray();
int[] iter_ints = new int[5];
TIntIterator iter = set.iterator();
int index = 0;
while (iter.hasNext()) {
iter_ints[index++] = iter.next();
}
assertTrue(Arrays.equals(iter_ints, toarray_ints));
}
示例3: getItemIds
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
@Nonnull
public Set<TenantItem> getItemIds(final int tenantId, final TIntSet itemTypeIds) {
TIntIterator iterator = itemTypeIds.iterator();
Set<TenantItem> result = Sets.newHashSet();
while (iterator.hasNext()) {
int itemTypeId = iterator.next();
Object[] args = new Object[]{tenantId, itemTypeId, tenantId, itemTypeId};
List<Integer> itemIds = QUERY_GET_ITEMIDS.execute(args);
for (Integer itemId : itemIds)
result.add(new TenantItem(itemId, itemTypeId));
}
return result;
}
示例4: testIterator
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testIterator() {
TIntSet set = new TIntOffheapHashSet();
set.add(1);
set.add(2);
set.add(3);
set.add(4);
TIntIterator iter = set.iterator();
assertTrue("iterator should have a next item", iter.hasNext());
int last = -1;
while (iter.hasNext()) {
int next = iter.next();
assertTrue(Integer.valueOf(next).toString(),
next >= 1 && next <= 4);
assertTrue(Integer.valueOf(next).toString(), next != last);
last = next;
}
assertFalse("iterator should not have a next item", iter.hasNext());
assertTrue("set should contain 1", set.contains(1));
assertTrue("set should contain 2", set.contains(2));
assertTrue("set should contain 3", set.contains(3));
assertTrue("set should contain 4", set.contains(4));
assertEquals(4, set.size());
}
示例5: testIteratorRemove
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testIteratorRemove() {
TIntSet set = new TIntOffheapHashSet();
set.add(1);
set.add(2);
set.add(3);
set.add(4);
TIntIterator iter = set.iterator();
assertTrue("iterator should have a next item", iter.hasNext());
int last = -1;
while (iter.hasNext()) {
int next = iter.next();
assertTrue(next >= 1 && next <= 4);
assertTrue(next != last);
last = next;
if (next == 3) {
iter.remove();
}
}
assertFalse("iterator should not have a next item", iter.hasNext());
assertFalse("set should not contain 3", set.contains(3));
assertTrue("set should contain 1", set.contains(1));
assertTrue("set should contain 2", set.contains(2));
assertTrue("set should contain 4", set.contains(4));
assertEquals(3, set.size());
}
示例6: testIterator
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testIterator() {
TIntSet set = new TIntHashSet();
set.add(1);
set.add(2);
set.add(3);
set.add(4);
TIntIterator iter = set.iterator();
assertTrue("iterator should have a next item", iter.hasNext());
int last = -1;
while (iter.hasNext()) {
int next = iter.next();
assertTrue(Integer.valueOf(next).toString(),
next >= 1 && next <= 4);
assertTrue(Integer.valueOf(next).toString(), next != last);
last = next;
}
assertFalse("iterator should not have a next item", iter.hasNext());
assertTrue("set should contain 1", set.contains(1));
assertTrue("set should contain 2", set.contains(2));
assertTrue("set should contain 3", set.contains(3));
assertTrue("set should contain 4", set.contains(4));
assertEquals(4, set.size());
}
示例7: testIteratorRemove
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testIteratorRemove() {
TIntSet set = new TIntHashSet();
set.add(1);
set.add(2);
set.add(3);
set.add(4);
TIntIterator iter = set.iterator();
assertTrue("iterator should have a next item", iter.hasNext());
int last = -1;
while (iter.hasNext()) {
int next = iter.next();
assertTrue(next >= 1 && next <= 4);
assertTrue(next != last);
last = next;
if (next == 3) {
iter.remove();
}
}
assertFalse("iterator should not have a next item", iter.hasNext());
assertFalse("set should not contain 3", set.contains(3));
assertTrue("set should contain 1", set.contains(1));
assertTrue("set should contain 2", set.contains(2));
assertTrue("set should contain 4", set.contains(4));
assertEquals(3, set.size());
}
示例8: generateItemTypeInClause
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
private String generateItemTypeInClause(TIntSet itemTypeIds) {
StringBuilder inClause = new StringBuilder();
TIntIterator iterator = itemTypeIds.iterator();
while (iterator.hasNext()) {
inClause.append(iterator.next());
if (iterator.hasNext())
inClause.append(", ");
}
return inClause.toString();
}