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


Java NavigableSet.toArray方法代碼示例

本文整理匯總了Java中java.util.NavigableSet.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java NavigableSet.toArray方法的具體用法?Java NavigableSet.toArray怎麽用?Java NavigableSet.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.NavigableSet的用法示例。


在下文中一共展示了NavigableSet.toArray方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getOrderedPrices

import java.util.NavigableSet; //導入方法依賴的package包/類
/**
 * Get an ordered array of prices
 *
 * @param ascending when true, values are sorted in ascending order,
 * descending otherwise
 * @return n-th highest order or null if index out of bounds
 */
public Decimal[] getOrderedPrices(boolean ascending) {
    NavigableSet<Decimal> ns = ascending ? orders.navigableKeySet()
            : orders.descendingKeySet();
    Decimal[] prices = new Decimal[ns.size()];
    ns.toArray(prices);
    return prices;
}
 
開發者ID:prog-fun,項目名稱:exchange-apis,代碼行數:15,代碼來源:Book.java

示例2: 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

示例3: testToArray

import java.util.NavigableSet; //導入方法依賴的package包/類
/**
 * toArray contains all elements in sorted order
 */
public void testToArray() {
    NavigableSet q = populatedSet(SIZE);
    Object[] o = q.toArray();
    for (int i = 0; i < o.length; i++)
        assertSame(o[i], q.pollFirst());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:TreeSubSetTest.java

示例4: testToArray2

import java.util.NavigableSet; //導入方法依賴的package包/類
/**
 * toArray(a) contains all elements in sorted order
 */
public void testToArray2() {
    NavigableSet<Integer> q = populatedSet(SIZE);
    Integer[] ints = new Integer[SIZE];
    Integer[] array = q.toArray(ints);
    assertSame(ints, array);
    for (int i = 0; i < ints.length; i++)
        assertSame(ints[i], q.pollFirst());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:TreeSubSetTest.java

示例5: testDescendingToArray

import java.util.NavigableSet; //導入方法依賴的package包/類
/**
 * toArray contains all elements
 */
public void testDescendingToArray() {
    NavigableSet q = populatedSet(SIZE);
    Object[] o = q.toArray();
    Arrays.sort(o);
    for (int i = 0; i < o.length; i++)
        assertEquals(o[i], q.pollFirst());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TreeSubSetTest.java

示例6: testToArray

import java.util.NavigableSet; //導入方法依賴的package包/類
/**
 * Tests that the array has a size of 0.
 */
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testToArray(String description, NavigableSet<?> navigableSet) {
    Object[] emptyNavigableSetArray = navigableSet.toArray();

    assertTrue(emptyNavigableSetArray.length == 0, "Returned non-empty Array.");

    emptyNavigableSetArray = new Object[20];

    Object[] result = navigableSet.toArray(emptyNavigableSetArray);

    assertSame(emptyNavigableSetArray, result);

    assertTrue(result[0] == null);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:EmptyNavigableSet.java


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