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


Java ConcurrentSkipListSet類代碼示例

本文整理匯總了Java中java.util.concurrent.ConcurrentSkipListSet的典型用法代碼示例。如果您正苦於以下問題:Java ConcurrentSkipListSet類的具體用法?Java ConcurrentSkipListSet怎麽用?Java ConcurrentSkipListSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: testEmptyAll

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
/**
 * Test of emptyAll method, of class FinancialMarket.
 */
@Test
public void testEmptyAll() {
    System.out.println("testGetFinancialMarket");
    FinancialMarket instance = new FinancialMarket();
    assertTrue(instance.getFinancialMarketData().get("ETFs").isEmpty());
    Market market = new Market("Global Uranium X", ChartType.DAY, "Australia");
    instance.addMarket("ETFs", market);
    ConcurrentHashMap<String, ConcurrentSkipListSet<Market>> result = instance.getFinancialMarketData();
    assertEquals(0, result.get("Stocks").size());
    assertEquals(1, result.get("ETFs").size());
    Market actual = instance.getMarket("ETFs", "Global Uranium X");
    assertNotNull(actual);
    assertTrue(actual.getMarketCode().compareToIgnoreCase("Global Uranium X") == 0);
    assertEquals(ChartType.DAY, actual.getChartType());
    instance.emptyAll();
    assertNull(instance.getMarket("ETFs", "Global Uranium X"));

}
 
開發者ID:ztan5,項目名稱:TechnicalAnalysisTool,代碼行數:22,代碼來源:FinancialMarketTest.java

示例2: load

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
/**
 * Load services that are provided by the DAO.
 */
@Scheduled(initialDelayString = "${cas.serviceRegistry.startDelay:PT20S}",
        fixedDelayString = "${cas.serviceRegistry.repeatInterval:PT60S}")
@Override
@PostConstruct
public void load() {
    LOGGER.debug("Loading services from [{}]", this.serviceRegistryDao);
    this.services = this.serviceRegistryDao.load().stream()
            .collect(Collectors.toConcurrentMap(r -> {
                LOGGER.debug("Adding registered service [{}]", r.getServiceId());
                return r.getId();
            }, Function.identity(), (r, s) -> s == null ? r : s));
    this.orderedServices = new ConcurrentSkipListSet<>(this.services.values());
    publishEvent(new CasRegisteredServicesLoadedEvent(this, this.orderedServices));
    LOGGER.info("Loaded [{}] service(s) from [{}].", this.services.size(), this.serviceRegistryDao);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:19,代碼來源:DefaultServicesManager.java

示例3: ApplicationNetwork

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
/**
 * Instantiates a new Application network.
 *
 * @param application_name the application name
 * @param scanner_interval the scanner interval for all defaults scanners
 * @param scanner_timeout the scanner timeout for all defaults scanners
 * @param scanner_thread_pool_size the scanner scheduler thread pool size
 * @param concurrent_scanner_thread_pool_size the size of the thread pool used by {@link ConcurrentScanner concurrent scans}
 */
public ApplicationNetwork(final String application_name, final Duration scanner_interval, final Duration scanner_timeout, final int scanner_thread_pool_size, final int concurrent_scanner_thread_pool_size) {

    this.application_name = application_name;
    application_descriptors = new ConcurrentSkipListSet<>();
    scheduled_scanners = new HashMap<>();
    scanner_scheduler = createScannerScheduledExecutorService(scanner_thread_pool_size);
    concurrent_scanner_executor = createScannerExecutorService(concurrent_scanner_thread_pool_size);
    network_executor_service = createNetworkExecutorService();

    auto_kill_scanner = new AutoKillScanner(scanner_interval, scanner_timeout);
    auto_deploy_scanner = new AutoDeployScanner(scanner_interval, scanner_timeout);
    auto_remove_scanner = new AutoRemoveScanner(scanner_interval, scanner_timeout);
    status_scanner = new StatusScanner(scanner_interval);

    addScanner(auto_kill_scanner);
    addScanner(auto_deploy_scanner);
    addScanner(auto_remove_scanner);
    addScanner(status_scanner);
}
 
開發者ID:stacs-srg,項目名稱:shabdiz,代碼行數:29,代碼來源:ApplicationNetwork.java

示例4: findEqual

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
Set<NitriteId> findEqual(String field, Object value) {
    if (!(value instanceof Comparable)) {
        throw new FilterException(CAN_NOT_SEARCH_NON_COMPARABLE_ON_INDEXED_FIELD);
    }

    NitriteMap<Comparable, ConcurrentSkipListSet<NitriteId>> indexMap
            = indexMetaService.getIndexMap(field);

    Set<NitriteId> resultSet = null;
    if (indexMap != null) {
        resultSet = indexMap.get((Comparable) value);
    }

    if (resultSet == null) resultSet = new LinkedHashSet<>();
    return resultSet;
}
 
開發者ID:dizitart,項目名稱:nitrite-database,代碼行數:17,代碼來源:IndexedSearchService.java

示例5: createOrUpdate

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
private void createOrUpdate(NitriteId id, String field, String text) {
    try {
        NitriteMap<Comparable, ConcurrentSkipListSet<NitriteId>> indexMap
                = indexMetaService.getIndexMap(field);
        Set<String> words = tokenizerService.tokenize(text);

        Object fieldLock = indexMetaService.getFieldLock(field);
        for (String word : words) {
            ConcurrentSkipListSet<NitriteId> nitriteIds = indexMap.get(word);

            synchronized (fieldLock) {
                if (nitriteIds == null) {
                    nitriteIds = new ConcurrentSkipListSet<>();
                    indexMap.put(word, nitriteIds);
                }
            }

            nitriteIds.add(id);
        }
    } catch (IOException ioe) {
        throw new IndexingException(errorMessage(
                "could not write full-text index data for " + text,
                IE_FAILED_TO_WRITE_FTS_DATA), ioe);
    }
}
 
開發者ID:dizitart,項目名稱:nitrite-database,代碼行數:26,代碼來源:NitriteTextIndexingService.java

示例6: searchByTrailingWildCard

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
private Set<NitriteId> searchByTrailingWildCard(String field, String searchString) {
    if (searchString.equalsIgnoreCase("*")) {
        throw new FilterException(INVALID_SEARCH_TERM_TRAILING_STAR);
    }

    NitriteMap<Comparable, ConcurrentSkipListSet<NitriteId>> indexMap
            = indexMetaService.getIndexMap(field);
    Set<NitriteId> idSet = new LinkedHashSet<>();
    String term = searchString.substring(0, searchString.length() - 1);

    for (Map.Entry<Comparable, ConcurrentSkipListSet<NitriteId>> entry : indexMap.entrySet()) {
        String key = (String) entry.getKey();
        if (key.startsWith(term.toLowerCase())) {
            idSet.addAll(entry.getValue());
        }
    }
    return idSet;
}
 
開發者ID:dizitart,項目名稱:nitrite-database,代碼行數:19,代碼來源:NitriteTextIndexingService.java

示例7: searchByLeadingWildCard

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
private Set<NitriteId> searchByLeadingWildCard(String field, String searchString) {
    if (searchString.equalsIgnoreCase("*")) {
        throw new FilterException(INVALID_SEARCH_TERM_LEADING_STAR);
    }

    NitriteMap<Comparable, ConcurrentSkipListSet<NitriteId>> indexMap
            = indexMetaService.getIndexMap(field);
    Set<NitriteId> idSet = new LinkedHashSet<>();
    String term = searchString.substring(1, searchString.length());

    for (Map.Entry<Comparable, ConcurrentSkipListSet<NitriteId>> entry : indexMap.entrySet()) {
        String key = (String) entry.getKey();
        if (key.endsWith(term.toLowerCase())) {
            idSet.addAll(entry.getValue());
        }
    }
    return idSet;
}
 
開發者ID:dizitart,項目名稱:nitrite-database,代碼行數:19,代碼來源:NitriteTextIndexingService.java

示例8: testRecursiveSubSets

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
/**
 * Subsets of subsets subdivide correctly
 */
public void testRecursiveSubSets() throws Exception {
    int setSize = expensiveTests ? 1000 : 100;
    Class cl = ConcurrentSkipListSet.class;

    NavigableSet<Integer> set = newSet(cl);
    BitSet bs = new BitSet(setSize);

    populate(set, setSize, bs);
    check(set,                 0, setSize - 1, true, bs);
    check(set.descendingSet(), 0, setSize - 1, false, bs);

    mutateSet(set, 0, setSize - 1, bs);
    check(set,                 0, setSize - 1, true, bs);
    check(set.descendingSet(), 0, setSize - 1, false, bs);

    bashSubSet(set.subSet(0, true, setSize, false),
               0, setSize - 1, true, bs);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:ConcurrentSkipListSetTest.java

示例9: testsForConcurrentSkipListSetWithComparator

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
public Test testsForConcurrentSkipListSetWithComparator() {
  return SetTestSuiteBuilder.using(
          new TestStringSortedSetGenerator() {
            @Override
            public SortedSet<String> create(String[] elements) {
              SortedSet<String> set =
                  new ConcurrentSkipListSet<String>(arbitraryNullFriendlyComparator());
              Collections.addAll(set, elements);
              return set;
            }
          })
      .named("ConcurrentSkipListSet, with comparator")
      .withFeatures(
          SetFeature.GENERAL_PURPOSE,
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .suppressing(suppressForConcurrentSkipListSetWithComparator())
      .createTestSuite();
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:21,代碼來源:TestsForSetsInJavaUtil.java

示例10: loadSavepoint

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
@SuppressWarnings("unchecked")
synchronized void loadSavepoint(Savepoint pt) {

	try {

		ConcurrentHashMap<Long, Transaction> transactionSet;
		try (ByteArrayInputStream bais = new ByteArrayInputStream(pt.data)) {
			try (ObjectInputStream ois = new ObjectInputStream(bais)) {
				transactionSet = (ConcurrentHashMap<Long, Transaction>) ois.readObject();
			}
		}

		ConcurrentSkipListSet<Long> listSet = new ConcurrentSkipListSet<>(new LongComparator(transactionSet));
		listSet.addAll(transactionSet.keySet());

		this.transactions = transactionSet;
		this.keys = listSet;
	} catch (Exception e) {
		throw new DataAccessException(e);
	}

}
 
開發者ID:EonTechnology,項目名稱:server,代碼行數:23,代碼來源:Backlog.java

示例11: sets

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
@Test
public void sets() {
    test(new TreeSet<>(), NonComparable::new,
         (s, e) -> {
             assertEquals(s.size(), 0);
             assertTrue(e instanceof ClassCastException);
         });
    test(new TreeSet<>(), AComparable::new,
         (s, e) -> {
             assertEquals(s.size(), 1);
             assertTrue(e == null);
         });

    test(new ConcurrentSkipListSet<>(), NonComparable::new,
         (s, e) -> {
             assertEquals(s.size(), 0);
             assertTrue(e instanceof ClassCastException);
         });
    test(new ConcurrentSkipListSet<>(), AComparable::new,
         (s, e) -> {
             assertEquals(s.size(), 1);
             assertTrue(e == null);
         });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:AddNonComparable.java

示例12: testRemoveMarket

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
/**
 * Test of removeMarket method, of class FinancialMarket.
 */
@Test
public void testRemoveMarket() {
    System.out.println("testGetFinancialMarket");
    FinancialMarket instance = new FinancialMarket();
    assertTrue(instance.getFinancialMarketData().get("ETFs").isEmpty());
    Market market = new Market("Global Uranium X", ChartType.DAY, "Australia");
    instance.addMarket("ETFs", market);
    ConcurrentHashMap<String, ConcurrentSkipListSet<Market>> result = instance.getFinancialMarketData();
    assertEquals(0, result.get("Stocks").size());
    assertEquals(1, result.get("ETFs").size());
    Market actual = instance.getMarket("ETFs", "Global Uranium X");
    assertNotNull(actual);
    assertTrue(actual.getMarketCode().compareToIgnoreCase("Global Uranium X") == 0);
    assertEquals(ChartType.DAY, actual.getChartType());
    //Test remove Market with wrong market code
    instance.removeMarket("Stocks", "Global Uranium X");
    actual = instance.getMarket("ETFs", "Global Uranium X");
    assertNotNull(actual);
    assertTrue(actual.getMarketCode().compareToIgnoreCase("Global Uranium X") == 0);
    assertEquals(ChartType.DAY, actual.getChartType());
    //Test remove Market with correct market code
    instance.removeMarket("ETFs", "Global Uranium X");
    //assertNull(instance.getMarket("ETFs", "Global Uranium X"));
}
 
開發者ID:ztan5,項目名稱:TechnicalAnalysisTool,代碼行數:28,代碼來源:FinancialMarketTest.java

示例13: initData

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
private void initData() {
    ConcurrentSkipListSet<Market> commoditySet = new ConcurrentSkipListSet<>();
    ConcurrentSkipListSet<Market> indicesSet = new ConcurrentSkipListSet<>();
    ConcurrentSkipListSet<Market> forexSet = new ConcurrentSkipListSet<>();
    ConcurrentSkipListSet<Market> stocksSet = new ConcurrentSkipListSet<>();
    ConcurrentSkipListSet<Market> etfsSet = new ConcurrentSkipListSet<>();
    ConcurrentSkipListSet<Market> fundsSet = new ConcurrentSkipListSet<>();
    ConcurrentSkipListSet<Market> bondsSet = new ConcurrentSkipListSet<>();
    financialMarketData.put("Commodities", commoditySet);
    financialMarketData.put("Indices", indicesSet);
    financialMarketData.put("Forex", forexSet);
    financialMarketData.put("Stocks", stocksSet);
    financialMarketData.put("ETFs", etfsSet);
    financialMarketData.put("Funds", fundsSet);
    financialMarketData.put("Bonds", bondsSet);  
}
 
開發者ID:ztan5,項目名稱:TechnicalAnalysisTool,代碼行數:17,代碼來源:FinancialMarket.java

示例14: testAddNonComparable

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
/**
 * Add of non-Comparable throws CCE
 */
public void testAddNonComparable() {
    ConcurrentSkipListSet q = new ConcurrentSkipListSet();
    try {
        q.add(new Object());
        q.add(new Object());
        shouldThrow();
    } catch (ClassCastException success) {
        assertTrue(q.size() < 2);
        for (int i = 0, size = q.size(); i < size; i++)
            assertSame(Object.class, q.pollFirst().getClass());
        assertNull(q.pollFirst());
        assertTrue(q.isEmpty());
        assertEquals(0, q.size());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:ConcurrentSkipListSetTest.java

示例15: testRemoveElement

import java.util.concurrent.ConcurrentSkipListSet; //導入依賴的package包/類
/**
 * remove(x) removes x and returns true if present
 */
public void testRemoveElement() {
    ConcurrentSkipListSet q = populatedSet(SIZE);
    for (int i = 1; i < SIZE; i += 2) {
        assertTrue(q.contains(i));
        assertTrue(q.remove(i));
        assertFalse(q.contains(i));
        assertTrue(q.contains(i - 1));
    }
    for (int i = 0; i < SIZE; i += 2) {
        assertTrue(q.contains(i));
        assertTrue(q.remove(i));
        assertFalse(q.contains(i));
        assertFalse(q.remove(i + 1));
        assertFalse(q.contains(i + 1));
    }
    assertTrue(q.isEmpty());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:ConcurrentSkipListSetTest.java


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