本文整理匯總了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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}