本文整理汇总了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"));
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
});
}
示例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"));
}
示例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);
}
示例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());
}
}
示例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());
}