本文整理匯總了Java中java.util.LinkedHashMap.values方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedHashMap.values方法的具體用法?Java LinkedHashMap.values怎麽用?Java LinkedHashMap.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.LinkedHashMap
的用法示例。
在下文中一共展示了LinkedHashMap.values方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static void main(String[] args) {
//create LinkedHashMap object
LinkedHashMap lHashMap = new LinkedHashMap();
//add key value pairs to LinkedHashMap
lHashMap.put("1", "One");
lHashMap.put("2", "Two");
lHashMap.put("3", "Three");
/*
get Collection of values contained in LinkedHashMap using
Collection values() method of LinkedHashMap class
*/
Collection c = lHashMap.values();
//obtain an Iterator for Collection
Iterator itr = c.iterator();
//iterate through LinkedHashMap values iterator
while (itr.hasNext()) System.out.println(itr.next());
}
示例2: writeGroupedEntryMap
import java.util.LinkedHashMap; //導入方法依賴的package包/類
protected static <T extends GroupedBiomeEntry> void writeGroupedEntryMap(JsonObject o, LinkedHashMap<String, T> list) {
for (T biome : list.values()) {
String catname = biome.category.toString();
if (!o.has(catname)) {
o.add(catname, new JsonObject());
}
JsonObject catobject = JsonUtil.getAsObject(o, catname);
if (!catobject.has(biome.group)) {
catobject.add(biome.group, new JsonArray());
}
JsonArray groupobject = JsonUtil.getAsArray(catobject, biome.group);
groupobject.add(biome.toJson());
}
}
示例3: merge
import java.util.LinkedHashMap; //導入方法依賴的package包/類
static List<Map<String, String>> merge(List<List<Map<String, String>>> parts) {
final LinkedHashMap<String, Map<String, String>> merged = new LinkedHashMap<>();
for (List<Map<String, String>> part : parts) {
for (Map<String, String> thisEntry : part) {
merged.putIfAbsent(thisEntry.get(P_PACKAGE), thisEntry);
}
}
return new ArrayList<>(merged.values());
}
示例4: setSchedules
import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
* Set the schedules to be displayed in the reorder list.
*
* @param schedules SchedulesUtil
*/
public void setSchedules(LinkedHashMap<String, Schedule> schedules) {
this.schedules = new ArrayList<>(schedules.size());
this.schedulesDelete = new HashMap<>(schedules.size());
long i = 0;
for (Schedule schedule : schedules.values()) {
this.schedules.add(new Pair<>(i++, schedule));
}
}
示例5: sortHashMapByValues
import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
* Sorts LinkedHashMap by its values(natural descending order). keeps the
* duplicates as it is.
*
* @param passedMap
* An Object of type LinkedHashMap to be sorted by its values.
* @return An Object containing the sorted LinkedHashMap.
*/
private LinkedHashMap<?,?> sortHashMapByValues(LinkedHashMap<String,String> passedMap) {
List<String> mapKeys = new ArrayList<String>(passedMap.keySet());
List<String> mapValues = new ArrayList<String>(passedMap.values());
Collections.sort(mapValues, new ValueComparator());
Collections.sort(mapKeys);
// Reversing the collection to sort the values in descending order
Collections.reverse(mapValues);
LinkedHashMap<String,String> sortedMap = new LinkedHashMap<String,String>();
Iterator<String> valueIt = mapValues.iterator();
while (valueIt.hasNext()) {
String val = valueIt.next();
Iterator<String> keyIt = mapKeys.iterator();
while (keyIt.hasNext()) {
String key = keyIt.next();
String comp1 = passedMap.get(key).toString();
String comp2 = val.toString();
if (comp1.equals(comp2)) {
passedMap.remove(key);
mapKeys.remove(key);
sortedMap.put(key, val);
break;
}
}
}
return sortedMap;
}
示例6: sortHashMapByValues
import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
* Sorts LinkedHashMap by its values(natural descending order). keeps the
* duplicates as it is.
*
* @param passedMap
* An Object of type LinkedHashMap to be sorted by its values.
*
* @return An Object containing the sorted LinkedHashMap.
*/
private LinkedHashMap<String,String> sortHashMapByValues(LinkedHashMap<String,String> passedMap) {
List<String> mapKeys = new ArrayList<String>(passedMap.keySet());
List<String> mapValues = new ArrayList<String>(passedMap.values());
Collections.sort(mapValues, new ValueComparator());
Collections.sort(mapKeys);
Collections.reverse(mapValues);
LinkedHashMap<String,String> sortedMap = new LinkedHashMap<String,String>();
Iterator<String> valueIt = mapValues.iterator();
while (valueIt.hasNext()) {
String val = valueIt.next();
Iterator<String> keyIt = mapKeys.iterator();
while (keyIt.hasNext()) {
String key = keyIt.next();
String comp1 = passedMap.get(key).toString();
String comp2 = val.toString();
if (comp1.equals(comp2)) {
passedMap.remove(key);
mapKeys.remove(key);
sortedMap.put(key, val);
break;
}
}
}
return sortedMap;
}
示例7: recreateFolderHierarchy
import java.util.LinkedHashMap; //導入方法依賴的package包/類
private void recreateFolderHierarchy(LinkedHashMap<Long, Bookmark> idMap) {
for (Bookmark bookmark : idMap.values()) {
if (bookmark.mId == ROOT_FOLDER_ID) continue;
// Look for invalid parent ids and self-cycles.
if (!idMap.containsKey(bookmark.mParentId) || bookmark.mParentId == bookmark.mId) {
bookmark.mParent = idMap.get(ROOT_FOLDER_ID);
bookmark.mParent.mEntries.add(bookmark);
continue;
}
bookmark.mParent = idMap.get(bookmark.mParentId);
bookmark.mParent.mEntries.add(bookmark);
}
}
示例8: writeJsonableMap
import java.util.LinkedHashMap; //導入方法依賴的package包/類
static <T extends IJsonMappable> void writeJsonableMap(JsonObject o, LinkedHashMap<String, T> list, String tagname) {
if (!list.isEmpty()) {
JsonArray g = new JsonArray();
for (T def : list.values()) {
g.add(def.toJson());
}
o.add(tagname, g);
}
}
示例9: getDiagnostics
import java.util.LinkedHashMap; //導入方法依賴的package包/類
DiagList getDiagnostics() {
if (diags == null) {
LinkedHashMap<String, Diag> diagMap = new LinkedHashMap<>();
for (Diagnostic<? extends JavaFileObject> in : diagnostics.getDiagnostics()) {
Diag d = diag(in);
String uniqueKey = d.getCode() + ":" + d.getPosition() + ":" + d.getMessage(PARSED_LOCALE);
diagMap.put(uniqueKey, d);
}
diags = new DiagList(diagMap.values());
}
return diags;
}
示例10: getMenuItems
import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static List<MenuItem> getMenuItems(ArrayList<RecentEntityMenuBase> menus) {
LinkedHashMap<String, MenuItem> menuItems = new LinkedHashMap<String, MenuItem>();
if (menus != null && menus.size() > 0) {
Iterator<RecentEntityMenuBase> it = menus.iterator();
while (it.hasNext()) {
findMenuItems(it.next().createMenuModel(WebUtil.getSessionScopeBean(), 0).getContents(), menuItems);
}
}
return new ArrayList<MenuItem>(menuItems.values());
}
示例11: getNamedParameters
import java.util.LinkedHashMap; //導入方法依賴的package包/類
public LinkedHashSet<NamedParameter> getNamedParameters(String resource, boolean excludeOverriden) throws Exception {
LinkedHashMap<String, NamedParameter> namedParameters = new LinkedHashMap<String, NamedParameter>();
Method method = getAnnotatedMethod(resource);
if (method != null) {
MethodParameterNames annotation = method.getAnnotation(MethodParameterNames.class);
String[] parameterNames = null;
if (annotation != null) {
parameterNames = annotation.value();
}
Class[] parameterTypes = method.getParameterTypes();
if (parameterNames != null && parameterTypes != null) {
for (int i = 0; i < parameterNames.length; i++) {
namedParameters.put(parameterNames[i], new NamedParameter(parameterNames[i], parameterTypes[i]));
}
}
}
Iterator<Entry<String, Object>> it = defaults.entrySet().iterator();
while (it.hasNext()) {
Entry<String, Object> defaultParameter = it.next();
if (!namedParameters.containsKey(defaultParameter.getKey())) {
namedParameters.put(defaultParameter.getKey(), new NamedParameter(defaultParameter.getKey(), defaultParameter.getValue().getClass()));
}
}
it = overrides.entrySet().iterator();
while (it.hasNext()) {
Entry<String, Object> overrideParameter = it.next();
namedParameters.put(overrideParameter.getKey(), new NamedParameter(overrideParameter.getKey(), overrideParameter.getValue().getClass()));
}
if (excludeOverriden) {
it = overrides.entrySet().iterator();
while (it.hasNext()) {
namedParameters.remove(it.next().getKey());
}
}
return new LinkedHashSet<NamedParameter>(namedParameters.values());
}
示例12: getMessages
import java.util.LinkedHashMap; //導入方法依賴的package包/類
protected MatrixCursor getMessages(String[] projection) throws InterruptedException {
BlockingQueue<List<MessageInfoHolder>> queue = new SynchronousQueue<List<MessageInfoHolder>>();
// new code for integrated inbox, only execute this once as it will be processed afterwards via the listener
SearchAccount integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(getContext());
MessagingController msgController = MessagingController.getInstance(getContext());
msgController.searchLocalMessages(integratedInboxAccount.getRelatedSearch(),
new MessageInfoHolderRetrieverListener(queue));
List<MessageInfoHolder> holders = queue.take();
// TODO add sort order parameter
Collections.sort(holders, new ReverseDateComparator());
String[] projectionToUse;
if (projection == null) {
projectionToUse = DEFAULT_MESSAGE_PROJECTION;
} else {
projectionToUse = projection;
}
LinkedHashMap<String, FieldExtractor<MessageInfoHolder, ?>> extractors =
resolveMessageExtractors(projectionToUse, holders.size());
int fieldCount = extractors.size();
String[] actualProjection = extractors.keySet().toArray(new String[fieldCount]);
MatrixCursor cursor = new MatrixCursor(actualProjection);
for (MessageInfoHolder holder : holders) {
Object[] o = new Object[fieldCount];
int i = 0;
for (FieldExtractor<MessageInfoHolder, ?> extractor : extractors.values()) {
o[i] = extractor.getField(holder);
i += 1;
}
cursor.addRow(o);
}
return cursor;
}
示例13: fix
import java.util.LinkedHashMap; //導入方法依賴的package包/類
private void fix() {
/*
* Useful references:
* http://tools.ietf.org/html/rfc4121#page-5
* http://tools.ietf.org/html/rfc2743#page-81
* https://msdn.microsoft.com/en-us/library/ms995330.aspx
*/
// Scan until we find the mech types list. If we find anything
// unexpected, abort the fix process.
if (!tag(0x60)) return;
if (!length()) return;
if (!oid("1.3.6.1.5.5.2")) return;
if (!tag(0xa0)) return;
if (!length()) return;
if (!tag(0x30)) return;
if (!length()) return;
if (!tag(0xa0)) return;
lengthAsInt();
if (!tag(0x30)) return;
// Now at the start of the mechType list.
// Read the mechTypes into an ordered set
int mechTypesLen = lengthAsInt();
int mechTypesStart = pos;
LinkedHashMap<String, int[]> mechTypeEntries = new LinkedHashMap<String, int[]>();
while (pos < mechTypesStart + mechTypesLen) {
int[] value = new int[2];
value[0] = pos;
String key = oidAsString();
value[1] = pos - value[0];
mechTypeEntries.put(key, value);
}
// Now construct the re-ordered mechType list
byte[] replacement = new byte[mechTypesLen];
int replacementPos = 0;
int[] first = mechTypeEntries.remove("1.2.840.113554.1.2.2");
if (first != null) {
System.arraycopy(token, first[0], replacement, replacementPos, first[1]);
replacementPos += first[1];
}
for (int[] markers : mechTypeEntries.values()) {
System.arraycopy(token, markers[0], replacement, replacementPos, markers[1]);
replacementPos += markers[1];
}
// Finally, replace the original mechType list with the re-ordered
// one.
System.arraycopy(replacement, 0, token, mechTypesStart, mechTypesLen);
}
示例14: fix
import java.util.LinkedHashMap; //導入方法依賴的package包/類
private void fix() {
/*
* Useful references: http://tools.ietf.org/html/rfc4121#page-5
* http://tools.ietf.org/html/rfc2743#page-81
* https://msdn.microsoft.com/en-us/library/ms995330.aspx
*/
// Scan until we find the mech types list. If we find anything
// unexpected, abort the fix process.
if (!tag(0x60))
return;
if (!length())
return;
if (!oid("1.3.6.1.5.5.2"))
return;
if (!tag(0xa0))
return;
if (!length())
return;
if (!tag(0x30))
return;
if (!length())
return;
if (!tag(0xa0))
return;
lengthAsInt();
if (!tag(0x30))
return;
// Now at the start of the mechType list.
// Read the mechTypes into an ordered set
int mechTypesLen = lengthAsInt();
int mechTypesStart = pos;
LinkedHashMap<String, int[]> mechTypeEntries = new LinkedHashMap<String, int[]>();
while (pos < mechTypesStart + mechTypesLen) {
int[] value = new int[2];
value[0] = pos;
String key = oidAsString();
value[1] = pos - value[0];
mechTypeEntries.put(key, value);
}
// Now construct the re-ordered mechType list
byte[] replacement = new byte[mechTypesLen];
int replacementPos = 0;
int[] first = mechTypeEntries.remove("1.2.840.113554.1.2.2");
if (first != null) {
System.arraycopy(token, first[0], replacement, replacementPos, first[1]);
replacementPos += first[1];
}
for (int[] markers : mechTypeEntries.values()) {
System.arraycopy(token, markers[0], replacement, replacementPos, markers[1]);
replacementPos += markers[1];
}
// Finally, replace the original mechType list with the re-ordered
// one.
System.arraycopy(replacement, 0, token, mechTypesStart, mechTypesLen);
}
示例15: MapAdapter
import java.util.LinkedHashMap; //導入方法依賴的package包/類
public MapAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull LinkedHashMap<K,V> map) {
super(context, resource, new ArrayList<V>(map.values()));
mMap = map;
mKeys.addAll(mMap.keySet());
}