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


Java ConcurrentSkipListSet.size方法代碼示例

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


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

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

示例2: getMarketStockCount

import java.util.concurrent.ConcurrentSkipListSet; //導入方法依賴的package包/類
/**
 * Get how many stocks within this market.
 * Could be OHLC's and not restricted by Stocks
 * @return total number of OHLC
 */
public Integer getMarketStockCount() {
    if (data != null && data.keySet().size() > 0) {
        Map.Entry<String, ConcurrentSkipListSet<OHLC>> entry = data.entrySet().iterator().next();
        ConcurrentSkipListSet<OHLC> value = entry.getValue();
        return value.size();
    }else {
        return 0;
    }
}
 
開發者ID:ztan5,項目名稱:TechnicalAnalysisTool,代碼行數:15,代碼來源:Market.java

示例3: updateIndexEntry

import java.util.concurrent.ConcurrentSkipListSet; //導入方法依賴的package包/類
void updateIndexEntry(Document document, NitriteId nitriteId) {
    Set<String> fields = getFields(document);

    for (String field : fields) {
        Index index = indexMetaService.findIndex(field);
        if (index != null) {
            Object fieldValue = getFieldValue(document, field);

            if (fieldValue == null) continue;
            validateDocumentIndexField(fieldValue, field);

            // if dirty index and currently indexing is not running, rebuild
            if (indexMetaService.isDirtyIndex(field) &&
                    indexBuildRegistry.get(field) != null
                    && !indexBuildRegistry.get(field).get()) {
                // rebuild will also take care of the current document
                rebuildIndex(index, true);
            } else {
                IndexType indexType = index.getIndexType();
                Object fieldLock = indexMetaService.getFieldLock(field);

                if (indexType == IndexType.Fulltext && fieldValue instanceof String) {
                    // update text index
                    textIndexingService.updateIndex(nitriteId, field, (String) fieldValue);
                } else {
                    NitriteMap<Comparable, ConcurrentSkipListSet<NitriteId>> indexMap
                            = indexMetaService.getIndexMap(field);

                    // create the nitriteId list associated with the value
                    ConcurrentSkipListSet<NitriteId> nitriteIdList
                            = indexMap.get((Comparable) fieldValue);

                    synchronized (fieldLock) {
                        if (nitriteIdList == null) {
                            nitriteIdList = new ConcurrentSkipListSet<>();
                        }

                        if (indexType == IndexType.Unique && nitriteIdList.size() == 1) {
                            // if key is already exists for unique type, throw error
                            throw new UniqueConstraintException(errorMessage(
                                    "unique key constraint violation for " + field,
                                    UCE_UPDATE_INDEX_CONSTRAINT_VIOLATED));
                        }

                        // add the nitriteId to the list
                        nitriteIdList.add(nitriteId);
                        indexMap.put((Comparable) fieldValue, nitriteIdList);
                    }
                }
            }
        }
    }
}
 
開發者ID:dizitart,項目名稱:nitrite-database,代碼行數:54,代碼來源:IndexingService.java

示例4: doCalculation

import java.util.concurrent.ConcurrentSkipListSet; //導入方法依賴的package包/類
/**
 * Most important method to calculate moving average data and store it in 
 * smaData set
 * @param orgData original data used to calculate smaData
 */
public void doCalculation(ConcurrentSkipListSet<OHLC> orgData){
    //Everytime is a new calculation
    smaPrice.clear();
    smaVolume.clear();
    
    int avgOn = avgOnProperty.getValue();
    CalculationBase calBase = calBaseProperty.getValue();
    //If source data is empty or less or equals to avgOn do nothing
    if (orgData.isEmpty() || orgData.size() < avgOn){
        return;
    }
    
    //Convert set to array
    Object[] rawData;
    rawData = (Object[])orgData.toArray();

    //Start calculation
    for (int i = 0; i<=rawData.length - avgOn; i++){
        float totalPrice = 0f;
        double totalVolume = 0l;
        OHLC ohlc = null;
        
        for(int j = i; j < i + avgOn; j++){                    
            ohlc = (OHLC)rawData[j];
            switch(calBase){
                case OPEN:
                    totalPrice += ohlc.getOpen();
                    break;
                case HIGH:
                    totalPrice += ohlc.getHigh();
                    break;
                case LOW:
                    totalPrice += ohlc.getLow();
                    break;
                case CLOSE:
                    totalPrice += ohlc.getClose();
                    break;
                case MIDDIUM:
                    totalPrice += ((float)(ohlc.getHigh() + ohlc.getLow()) /(float)2);
                    break;
                case TYPICAL:
                    totalPrice += (((float)(ohlc.getHigh() + ohlc.getLow() + ohlc.getClose()))/ (float)3);
                    break;
                case WEIGHTED:
                    totalPrice += (((float)(ohlc.getHigh() + ohlc.getLow() + ohlc.getClose() + ohlc.getClose()))/ (float)4);
                    break;
                case VOLUME:
                    totalVolume += ohlc.getVolume();
                    break;
            }
        }
        
        float avgPrice = totalPrice / avgOn;
        double avgVolume = totalVolume / avgOn;
        if (ohlc != null){
            if (calBase == CalculationBase.VOLUME){
                //Volume is using Million as the units
                //And it is keep 4 digits floating point
                avgVolume/=1000000;
                avgVolume *= 10000;
                avgVolume = (float)Math.round(avgVolume);
                avgVolume /= 10000;
                smaVolume.put(ohlc.getDate(), avgVolume);  
            } else {
                //round to 4 digits floating points
                avgPrice *= 10000;
                avgPrice = Math.round(avgPrice);
                avgPrice /= 10000;
                smaPrice.put(ohlc.getDate(), avgPrice);
            }
        }
    }
}
 
開發者ID:ztan5,項目名稱:TechnicalAnalysisTool,代碼行數:79,代碼來源:SimpleMovingAverage.java


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