當前位置: 首頁>>代碼示例>>Java>>正文


Java TIntSet.iterator方法代碼示例

本文整理匯總了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));
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:17,代碼來源:TPrimitiveOffheapHashSetTest.java

示例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));
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:17,代碼來源:TPrimitiveHashSetTest.java

示例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;
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:17,代碼來源:DeviationDAOCachedMergingMySQL.java

示例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());
    }
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:29,代碼來源:TPrimitiveOffheapHashSetTest.java

示例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());

    }
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:33,代碼來源:TPrimitiveOffheapHashSetTest.java

示例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());
    }
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:29,代碼來源:TPrimitiveHashSetTest.java

示例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());

    }
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:33,代碼來源:TPrimitiveHashSetTest.java

示例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();
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:15,代碼來源:ActionDAOMysqlImpl.java


注:本文中的gnu.trove.set.TIntSet.iterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。