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


Java NavigableSet.clear方法代码示例

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


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

示例1: transformedNavigableSet

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Factory method to create a transforming navigable set that will transform
 * existing contents of the specified navigable set.
 * <p>
 * If there are any elements already in the set being decorated, they
 * will be transformed by this method.
 * Contrast this with {@link #transformingNavigableSet(NavigableSet, Transformer)}.
 *
 * @param <E> the element type
 * @param set  the set to decorate, must not be null
 * @param transformer  the transformer to use for conversion, must not be null
 * @return a new transformed {@link NavigableSet}
 * @throws NullPointerException if set or transformer is null
 */
public static <E> TransformedNavigableSet<E> transformedNavigableSet(final NavigableSet<E> set,
        final Transformer<? super E, ? extends E> transformer) {

    final TransformedNavigableSet<E> decorated = new TransformedNavigableSet<E>(set, transformer);
    if (set.size() > 0) {
        @SuppressWarnings("unchecked") // set is type E
        final E[] values = (E[]) set.toArray(); // NOPMD - false positive for generics
        set.clear();
        for (final E value : values) {
            decorated.decorated().add(transformer.transform(value));
        }
    }
    return decorated;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:29,代码来源:TransformedNavigableSet.java

示例2: testClear

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * clear removes all elements
 */
public void testClear() {
    NavigableSet q = populatedSet(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    assertTrue(q.add(new Integer(1)));
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TreeSubSetTest.java

示例3: testDescendingClear

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * clear removes all elements
 */
public void testDescendingClear() {
    NavigableSet q = populatedSet(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    assertTrue(q.add(new Integer(1)));
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TreeSubSetTest.java

示例4: testClear

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * clear removes all elements
 */
public void testClear() {
    NavigableSet q = populatedSet(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    q.add(new Integer(1));
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ConcurrentSkipListSubSetTest.java

示例5: testDescendingClear

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * clear removes all elements
 */
public void testDescendingClear() {
    NavigableSet q = populatedSet(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    q.add(new Integer(1));
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ConcurrentSkipListSubSetTest.java


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