本文整理匯總了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;
}
示例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();
}
};
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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]);
}
示例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);
}