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


Java AbstractMap.SimpleEntry方法代碼示例

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


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

示例1: getAvailable

import java.util.AbstractMap; //導入方法依賴的package包/類
public float getAvailable(AbstractMap.SimpleEntry<String, Float>[] latestMarkets) {
	// TODO ���ǵ�����
	float frozen = 0.0f;
	for (AbstractMap.SimpleEntry<String, Float> item : latestMarkets) {
		String instrument = item.getKey();
		int ydLongPosition = ydLongPositions.get(instrument);
		int ydShortPosition = ydShortPositions.get(instrument);
		int tdLongPosition = tdLongPositions.get(instrument);
		int tdShortPosition = tdShortPositions.get(instrument);
		float latestPrice = item.getValue();
		float marginRatio = getMarginRatio(instrument);
		float longFrozen = (ydLongPosition + tdLongPosition) * latestPrice * marginRatio;
		float shortFrozen = (ydShortPosition + tdShortPosition) * latestPrice * marginRatio;
		frozen += (longFrozen + shortFrozen);
	}
	return getBalance(latestMarkets) - frozen;
}
 
開發者ID:zc8424,項目名稱:QuantTester,代碼行數:18,代碼來源:Portfolio.java

示例2: cacheEntrySetIterator

import java.util.AbstractMap; //導入方法依賴的package包/類
private Iterator<Map.Entry<K,V>> cacheEntrySetIterator() {
    final Iterator<Map.Entry<CacheKey, CacheValue>> iter = cache.entrySet().iterator();
    
    return new Iterator<Map.Entry<K,V>>() {

        @Override
        public boolean hasNext() {
            return iter.hasNext();
        }

        @Override
        public java.util.Map.Entry<K, V> next() {
            Map.Entry<CacheKey, CacheValue> entry = iter.next();
            return new AbstractMap.SimpleEntry(entry.getValue().getKey(), entry.getValue().getValue());
        }
        
        @Override
        public void remove() {
            iter.remove();
        }
        
    };
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:24,代碼來源:RedissonLocalCachedMap.java

示例3: getOrdinals

import java.util.AbstractMap; //導入方法依賴的package包/類
public final static <T extends Comparable<? super T>> int[] getOrdinals(final T[] values, final boolean polaris) {
	final int size = values.length;
	int[] ordinals = new int[size];
	
	List<AbstractMap.SimpleEntry<Integer, T>> it_list = new ArrayList<>();
	
	for (int i = 0; i < size; i++) {
		AbstractMap.SimpleEntry<Integer, T> entry = new AbstractMap.SimpleEntry<>(i, values[i]);
		it_list.add(entry);
	}
	
	if (polaris) {
		Collections.sort(it_list, (arg0, arg1) -> arg0.getValue().compareTo(arg1.getValue()));
	} else {
		Collections.sort(it_list, (arg0, arg1) -> arg1.getValue().compareTo(arg0.getValue()));
	}
	
	for (int i = 0; i < size; i++) {
		ordinals[i] = it_list.get(i).getKey();
	}
	return ordinals;
}
 
開發者ID:zc8424,項目名稱:QuantTester,代碼行數:23,代碼來源:SortHelper.java

示例4: readEntry

import java.util.AbstractMap; //導入方法依賴的package包/類
private void readEntry(Config config, ResSpec spec) {
    D("[%08x]read ResTable_entry", in.position());
    int size = in.getShort();
    D("ResTable_entry %d", size);

    int flags = in.getShort(); // ENTRY_FLAG_PUBLIC
    int keyStr = in.getInt();
    spec.updateName(keyNamesX[keyStr]);

    ResEntry resEntry = new ResEntry(flags, spec);

    if (0 != (flags & ENTRY_FLAG_COMPLEX)) {

        int parent = in.getInt();
        int count = in.getInt();
        BagValue bag = new BagValue(parent);
        for (int i = 0; i < count; i++) {
            Map.Entry<Integer, Value> entry = new AbstractMap.SimpleEntry(in.getInt(), readValue());
            bag.map.add(entry);
        }
        resEntry.value = bag;
    } else {
        resEntry.value = readValue();
    }
    config.resources.put(spec.id, resEntry);
}
 
開發者ID:hyb1996,項目名稱:Auto.js-ApkBuilder,代碼行數:27,代碼來源:ArscParser.java

示例5: getTransactionsBuffer

import java.util.AbstractMap; //導入方法依賴的package包/類
private Map<Long, TransactionData> getTransactionsBuffer(String cacheName,
                                                         int countTx,
                                                         List<?> expectedKeys,
                                                         List<?> expectedValues
) {
    Map<Long, TransactionData> transactionsBuffer = new HashMap<>(countTx);
    for (int i = 0; i < countTx; i++) {
        Map.Entry<String, List> cacheScope =
                new AbstractMap.SimpleEntry<String, List>(
                        cacheName,
                        Collections.singletonList(expectedKeys.get(i))
                );
        TransactionScope txScope = new TransactionScope((long) i, Collections.singletonList(cacheScope));
        ByteBuffer serializedCacheValue = serializer.serialize(
                Collections.singletonList(Collections.singletonList(expectedValues.get(i)))
        );
        TransactionData transactionScopeAndSerializedValues =
                new TransactionData(
                        txScope,
                        serializedCacheValue,new TopicPartition(TOPIC,0),0L
                );
        transactionsBuffer.put((long) i, transactionScopeAndSerializedValues);
    }
    return transactionsBuffer;
}
 
開發者ID:epam,項目名稱:Lagerta,代碼行數:26,代碼來源:SequentialCommitStrategyUnitTest.java

示例6: searchAndSave

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Scrape RSS feed
 * @param job contains url to RSS feed
 */
protected void searchAndSave(BSJob job){
    try {
        RSSScraper rssScraper = new RSSScraper(job.getURL(),job.getLanguage(),job.getDB(), this.ld);
        AbstractMap.SimpleEntry <Integer,Integer> vals = rssScraper.fetchAndSave();
        TaskLogger taskLogger = this.viewManager.getLogger(job.getLanguage());
        taskLogger.addTodupsdCount(vals.getKey());
        taskLogger.addToNotInLang(vals.getValue());

    } catch (MalformedURLException e) {
        log.error(e);

    } catch (Exception ex){
        log.error(ex);
    }

}
 
開發者ID:gidim,項目名稱:Babler,代碼行數:21,代碼來源:BSFetcherAndSaver.java

示例7: saveAll

import java.util.AbstractMap; //導入方法依賴的package包/類
@Override
public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
    Function<? super S, Map.Entry<ID, S>> fn = s -> {
        ID id = getIdentifier(s);
        return new AbstractMap.SimpleEntry<>(id, s);
    };
    Map<ID, S> tMap = StreamSupport
        .stream(entities.spliterator(), false)
        .map(fn)
        .collect(Collectors.toMap(
            Map.Entry::getKey,
            Map.Entry::getValue
            )
        );
    map.putAll(tMap);
    return entities;
}
 
開發者ID:snowdrop,項目名稱:spring-data-snowdrop,代碼行數:18,代碼來源:MapCrudAdapter.java

示例8: addFeatureData

import java.util.AbstractMap; //導入方法依賴的package包/類
public boolean addFeatureData(FeatureIndex fi, UnitAggregateStatistics uas) {
    if (fi == null || uas == null) {
        return false;
    }
    Map.Entry<FeatureIndex, UnitAggregateStatistics> data
            = new AbstractMap.SimpleEntry<>(fi, uas);
    featureData.add(data);
    return true;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:10,代碼來源:AggregateStatisticsFeature.java

示例9: getAdditionalDepciesTarget

import java.util.AbstractMap; //導入方法依賴的package包/類
@Override
List<Entry<PgStatement, PgStatement>> getAdditionalDepciesTarget(PgDatabase target) {
    PgSchema s = target.getSchema("newschema");
    PgView v = target.getSchema("public").getView("v1");
    Entry<PgStatement, PgStatement> arr = new AbstractMap.SimpleEntry<> (v, s);
    List<Entry<PgStatement, PgStatement>> list = new ArrayList<>();
    list.add(arr);
    return list;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:10,代碼來源:DifferTest.java

示例10: getBalance

import java.util.AbstractMap; //導入方法依賴的package包/類
@Deprecated
public float getBalance(float price) {
	AbstractMap.SimpleEntry<String, Float> latestMarket = new AbstractMap.SimpleEntry<String, Float>("common", price);
	@SuppressWarnings("unchecked")
	AbstractMap.SimpleEntry<String, Float>[] latestMarkets = new AbstractMap.SimpleEntry[1];
	latestMarkets[0] = latestMarket;
	return getBalance(latestMarkets);
}
 
開發者ID:zc8424,項目名稱:QuantTester,代碼行數:9,代碼來源:Portfolio.java

示例11: getAdditionalDepciesSource

import java.util.AbstractMap; //導入方法依賴的package包/類
@Override
List<Entry<PgStatement, PgStatement>> getAdditionalDepciesSource(PgDatabase source) {
    PgColumn c = source.getSchema("public").getTable("t1").getColumn("c1");
    PgSequence s = source.getSchema("public").getSequence("t1_c1_seq");
    Entry<PgStatement, PgStatement> arr = new AbstractMap.SimpleEntry<> (s, c);
    List<Entry<PgStatement, PgStatement>> list = new ArrayList<>();
    list.add(arr);
    return list;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:10,代碼來源:DifferTest.java

示例12: editDistance

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Computes the edit distance between two strings.
 *
 * <p>
 * The complexity is O(nm) where n=a.length() and m=b.length().
 */
public static int editDistance( String a, String b ) {
    // let's check cache
    AbstractMap.SimpleEntry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(a, b); // using this class to avoid creation of my own which will handle PAIR of values
    Integer result = null;
    if (CACHE.containsKey(entry))
        result = CACHE.get(entry); // looks like we have it

    if (result == null) {
        result = new EditDistance(a, b).calc();
        CACHE.put(entry, result); // cache the result
    }
    return result;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:EditDistance.java

示例13: extractTypeAndKey

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Extracts a type and key from a RestConf path
 * @param restconfPath - RestConf URI path
 * @return a pair (Map.Entry) of the FixedType and Key from the RestConf URI path
 */
public Map.Entry<FixedType, String> extractTypeAndKey(String restconfPath) {
    for (Map.Entry<FixedType, Map.Entry<Pattern,Integer>> p : entityPatterns.entrySet()) {
        Matcher m = p.getValue().getKey().matcher(restconfPath);
        if (m.matches()) {
            return new AbstractMap.SimpleEntry<FixedType, String>(p.getKey(), m.group(p.getValue().getValue()));
        }
    }
    return null;
}
 
開發者ID:opendaylight,項目名稱:fpc,代碼行數:15,代碼來源:NameResolver.java

示例14: onGenerateEntry

import java.util.AbstractMap; //導入方法依賴的package包/類
@Override
protected Map.Entry<String, String> onGenerateEntry(String line)
{
    String[] paramArray = line.split(separator, 2);
    if (paramArray.length != 2)
    {
        logger.warning("詞典有一行讀取錯誤: " + line);
        return null;
    }
    return new AbstractMap.SimpleEntry<String, String>(paramArray[0], paramArray[1]);
}
 
開發者ID:priester,項目名稱:hanlpStudy,代碼行數:12,代碼來源:StringDictionary.java

示例15: test_for_issue_int

import java.util.AbstractMap; //導入方法依賴的package包/類
public void test_for_issue_int() throws Exception {
    Map.Entry entry = new AbstractMap.SimpleEntry("name", 123);
    String text = JSON.toJSONString(entry);
    assertEquals("{\"name\":123}", text);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:Issue983_1.java


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