本文整理匯總了Java中java.util.LinkedHashMap.Entry方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedHashMap.Entry方法的具體用法?Java LinkedHashMap.Entry怎麽用?Java LinkedHashMap.Entry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.LinkedHashMap
的用法示例。
在下文中一共展示了LinkedHashMap.Entry方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAllExtraWordsNameList
import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static String[] getAllExtraWordsNameList(LinkedHashMap<String, String> data, boolean defaultOpinion, String defaultString) {
int length;
if (defaultOpinion) {
length = data.size() + 1;
} else {
length = data.size();
}
String[] result = new String[length];
int start = 0;
if (defaultOpinion && defaultString != null) {
result[0] = defaultString;
start++;
}
for (Object o : data.entrySet()) {
LinkedHashMap.Entry entry = (LinkedHashMap.Entry) o;
result[start] = entry.getKey().toString();
start++;
}
return result;
}
示例2: testGetMatchingEntries
import java.util.LinkedHashMap; //導入方法依賴的package包/類
@Test
public void testGetMatchingEntries() {
mCountingLruMap.put("key1", 110);
mCountingLruMap.put("key2", 120);
mCountingLruMap.put("key3", 130);
mCountingLruMap.put("key4", 140);
List<LinkedHashMap.Entry<String, Integer>> entries = mCountingLruMap.getMatchingEntries(
new Predicate<String>() {
@Override
public boolean apply(String key) {
return key.equals("key2") || key.equals("key3");
}
});
assertNotNull(entries);
assertEquals(2, entries.size());
assertEquals("key2", entries.get(0).getKey());
assertEquals(120, (int) entries.get(0).getValue());
assertEquals("key3", entries.get(1).getKey());
assertEquals(130, (int) entries.get(1).getValue());
// getting entries should not affect the order nor the size
assertEquals(4, mCountingLruMap.getCount());
assertEquals(500, mCountingLruMap.getSizeInBytes());
assertKeyOrder("key1", "key2", "key3", "key4");
assertValueOrder(110, 120, 130, 140);
}
示例3: getMatchingEntries
import java.util.LinkedHashMap; //導入方法依賴的package包/類
/** Gets the all matching elements. */
public synchronized ArrayList<LinkedHashMap.Entry<K, V>> getMatchingEntries(
@Nullable Predicate<K> predicate) {
ArrayList<LinkedHashMap.Entry<K, V>> matchingEntries = new ArrayList<>(mMap.entrySet().size());
for (LinkedHashMap.Entry<K, V> entry : mMap.entrySet()) {
if (predicate == null || predicate.apply(entry.getKey())) {
matchingEntries.add(entry);
}
}
return matchingEntries;
}
示例4: removeAll
import java.util.LinkedHashMap; //導入方法依賴的package包/類
/** Removes all the matching elements from the map. */
public synchronized ArrayList<V> removeAll(@Nullable Predicate<K> predicate) {
ArrayList<V> oldValues = new ArrayList<>();
Iterator<LinkedHashMap.Entry<K, V>> iterator = mMap.entrySet().iterator();
while (iterator.hasNext()) {
LinkedHashMap.Entry<K, V> entry = iterator.next();
if (predicate == null || predicate.apply(entry.getKey())) {
oldValues.add(entry.getValue());
mSizeInBytes -= getValueSizeInBytes(entry.getValue());
iterator.remove();
}
}
return oldValues;
}
示例5: removeEldestEntry
import java.util.LinkedHashMap; //導入方法依賴的package包/類
@Override
protected boolean removeEldestEntry(LinkedHashMap.Entry<Integer, Bitmap> eldest) {
if (size() > HARD_CACHE_CAPACITY) {
// Entries push-out of hard reference cache are transferred to
// soft reference cache
sSoftBitmapCache.put(eldest.getKey(), new SoftReference<Bitmap>(eldest.getValue()));
return true;
} else
return false;
}