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


Java NavigableSet.iterator方法代码示例

本文整理汇总了Java中java.util.NavigableSet.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableSet.iterator方法的具体用法?Java NavigableSet.iterator怎么用?Java NavigableSet.iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.NavigableSet的用法示例。


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

示例1: demoNavigableSetIterRemove

import java.util.NavigableSet; //导入方法依赖的package包/类
private static void demoNavigableSetIterRemove(NavigableSet<Integer> set) {
    System.out.println("set: " + set);
    try {
        Iterator iter = set.iterator();
        while (iter.hasNext()) {
            Integer e = (Integer) iter.next();
            System.out.println(e);
            if (e == 2) {
                System.out.println("Calling iter.remove()...");
                iter.remove();
            }
        }
    } catch (Exception ex) {
        System.out.println(ex.getClass().getName());
    }
    System.out.println("set: " + set);
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Cookbook,代码行数:18,代码来源:Chapter07Concurrency02.java

示例2: testToSubchartsBananasAndInvalid

import java.util.NavigableSet; //导入方法依赖的package包/类
@Test
public void testToSubchartsBananasAndInvalid() throws IOException {
  final String input = "wordpress/charts/mariadb/charts/frobnicator/charts/joe/barney/charts/wilma/README.md";
  final NavigableSet<String> output = StreamOrientedChartLoader.toSubcharts(input);
  assertNotNull(output);
  assertEquals(4, output.size());
  final Iterator<String> iterator = output.iterator();
  assertNotNull(iterator);
  assertTrue(iterator.hasNext());
  assertEquals("wordpress/charts/mariadb", iterator.next());
  assertTrue(iterator.hasNext());
  assertEquals("wordpress/charts/mariadb/charts/frobnicator", iterator.next());
  assertTrue(iterator.hasNext());
  assertEquals("wordpress/charts/mariadb/charts/frobnicator/charts/joe", iterator.next());
  assertTrue(iterator.hasNext());
  assertEquals("wordpress/charts/mariadb/charts/frobnicator/charts/joe/barney/charts/wilma", iterator.next());
  assertFalse(iterator.hasNext());
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:19,代码来源:TestStreamOrientedChartLoader.java

示例3: mutateSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSet(NavigableSet<Integer> set, int min, int max) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10));
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min + rnd.nextInt(rangeSize);
        assertTrue(element >= min && element <= max);
        put(set, element);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:TreeSetTest.java

示例4: testIteratorRemove

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * iterator.remove removes current element
 */
public void testIteratorRemove() {
    final NavigableSet q = set0();
    q.add(new Integer(2));
    q.add(new Integer(1));
    q.add(new Integer(3));

    Iterator it = q.iterator();
    it.next();
    it.remove();

    it = q.iterator();
    assertEquals(2, it.next());
    assertEquals(3, it.next());
    assertFalse(it.hasNext());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TreeSubSetTest.java

示例5: testDescendingIteratorRemove

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * iterator.remove removes current element
 */
public void testDescendingIteratorRemove() {
    final NavigableSet q = dset0();
    q.add(new Integer(2));
    q.add(new Integer(1));
    q.add(new Integer(3));

    Iterator it = q.iterator();
    it.next();
    it.remove();

    it = q.iterator();
    assertEquals(2, it.next());
    assertEquals(3, it.next());
    assertFalse(it.hasNext());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TreeSubSetTest.java

示例6: testIteratorRemove

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * iterator.remove removes current element
 */
public void testIteratorRemove() {
    final NavigableSet q = set0();
    q.add(new Integer(2));
    q.add(new Integer(1));
    q.add(new Integer(3));

    Iterator it = q.iterator();
    it.next();
    it.remove();

    it = q.iterator();
    assertEquals(it.next(), new Integer(2));
    assertEquals(it.next(), new Integer(3));
    assertFalse(it.hasNext());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ConcurrentSkipListSubSetTest.java

示例7: testDescendingIteratorRemove

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * iterator.remove removes current element
 */
public void testDescendingIteratorRemove() {
    final NavigableSet q = dset0();
    q.add(new Integer(2));
    q.add(new Integer(1));
    q.add(new Integer(3));

    Iterator it = q.iterator();
    it.next();
    it.remove();

    it = q.iterator();
    assertEquals(it.next(), new Integer(2));
    assertEquals(it.next(), new Integer(3));
    assertFalse(it.hasNext());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ConcurrentSkipListSubSetTest.java

示例8: mutateSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSet(NavigableSet<Integer> set, int min, int max, BitSet bs) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10), bs);
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min + rnd.nextInt(rangeSize);
        assertTrue(element >= min && element <= max);
        put(set, element, bs);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ConcurrentSkipListSetTest.java

示例9: testEmptyIterator

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Tests that the iterator is empty.
 */
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testEmptyIterator(String description, NavigableSet<?> navigableSet) {
    Iterator emptyIterator = navigableSet.iterator();

    assertFalse((emptyIterator != null) && (emptyIterator.hasNext()),
        "The iterator is not empty.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:EmptyNavigableSet.java

示例10: mutateSubSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSubSet(NavigableSet<Integer> set, int min, int max) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10));
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min - 5 + rnd.nextInt(rangeSize + 10);
        if (element >= min && element <= max) {
            put(set, element);
        } else {
            try {
                set.add(element);
                shouldThrow();
            } catch (IllegalArgumentException success) {}
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TreeSetTest.java

示例11: testIterator

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * iterator iterates through all elements
 */
public void testIterator() {
    NavigableSet q = populatedSet(SIZE);
    Iterator it = q.iterator();
    int i;
    for (i = 0; it.hasNext(); i++)
        assertTrue(q.contains(it.next()));
    assertEquals(i, SIZE);
    assertIteratorExhausted(it);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:TreeSubSetTest.java

示例12: testDescendingIterator

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * iterator iterates through all elements
 */
public void testDescendingIterator() {
    NavigableSet q = populatedSet(SIZE);
    int i = 0;
    Iterator it = q.iterator();
    while (it.hasNext()) {
        assertTrue(q.contains(it.next()));
        ++i;
    }
    assertEquals(i, SIZE);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TreeSubSetTest.java

示例13: testDescendingEmptyIterator

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * iterator of empty set has no elements
 */
public void testDescendingEmptyIterator() {
    NavigableSet q = dset0();
    int i = 0;
    Iterator it = q.iterator();
    while (it.hasNext()) {
        assertTrue(q.contains(it.next()));
        ++i;
    }
    assertEquals(0, i);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TreeSubSetTest.java

示例14: mutateSubSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSubSet(NavigableSet<Integer> set, int min, int max,
                  BitSet bs) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10), bs);
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min - 5 + rnd.nextInt(rangeSize + 10);
        if (element >= min && element <= max) {
            put(set, element, bs);
        } else {
            try {
                set.add(element);
                shouldThrow();
            } catch (IllegalArgumentException success) {}
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:ConcurrentSkipListSetTest.java


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