Java Code Examples for java.util.HashMap#values()
The following examples show how to use
java.util.HashMap#values() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PLIBuilder.java From metanome-algorithms with Apache License 2.0 | 6 votes |
protected static List<PositionListIndex> fetchPositionListIndexesStatic(List<HashMap<String, IntArrayList>> clusterMaps, boolean isNullEqualNull) { List<PositionListIndex> clustersPerAttribute = new ArrayList<>(); for (int columnId = 0; columnId < clusterMaps.size(); columnId++) { List<IntArrayList> clusters = new ArrayList<>(); HashMap<String, IntArrayList> clusterMap = clusterMaps.get(columnId); if (!isNullEqualNull) clusterMap.remove(null); for (IntArrayList cluster : clusterMap.values()) if (cluster.size() > 1) clusters.add(cluster); clustersPerAttribute.add(new PositionListIndex(columnId, clusters)); } return clustersPerAttribute; }
Example 2
Source File: Partition.java From metanome-algorithms with Apache License 2.0 | 6 votes |
public Collection<Partition> refineBy(int target) { HashMap<Cluster, Partition> map = new HashMap<Cluster, Partition>(); for(TIntIterator iter = array.iterator(); iter.hasNext();) { int next = iter.next(); Cluster c = StrippedPartition.clusters.get(next)[target]; if(c == null) { continue; } if(map.containsKey(c)) { map.get(c).add(next); } else { Partition p = new Partition(); p.add(next); map.put(c, p); } } return map.values(); }
Example 3
Source File: LanguageMenuProcessor.java From talkback with Apache License 2.0 | 6 votes |
private static List<ContextMenuItem> getMenuItems( TalkBackService service, ContextMenuItemBuilder menuItemBuilder) { if (service == null) { return null; } HashMap<Locale, String> languagesAvailable = getInstalledLanguages(service); if (languagesAvailable == null) { return null; } LanguageMenuItemClickListener clickListener = new LanguageMenuItemClickListener(service, languagesAvailable); List<ContextMenuItem> menuItems = new ArrayList<>(); for (String value : languagesAvailable.values()) { ContextMenuItem val = menuItemBuilder.createMenuItem(service, R.id.group_language, Menu.NONE, Menu.NONE, value); val.setOnMenuItemClickListener(clickListener); menuItems.add(val); } return menuItems; }
Example 4
Source File: PositionConfSpace.java From OSPREY3 with GNU General Public License v2.0 | 6 votes |
public int maxNumRCsPerResType(){ //maximum (over all residue types) of the number of RCs of that residue type HashMap<String,Integer> resTypeRCCounts = new HashMap<>(); for(RC rc : RCs){ String type = rc.AAType; if(resTypeRCCounts.containsKey(type)) resTypeRCCounts.put(type, resTypeRCCounts.get(type)+1); else resTypeRCCounts.put(type, 1); } int maxNumRCs = 0; for(int count : resTypeRCCounts.values()) maxNumRCs = Math.max(maxNumRCs,count); return maxNumRCs; }
Example 5
Source File: IterateValuesOfHashMapExample.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public static void main(String[] args) { //create HashMap object HashMap hMap = new HashMap(); //add key value pairs to HashMap hMap.put("1", "One"); hMap.put("2", "Two"); hMap.put("3", "Three"); /* get Collection of values contained in HashMap using Collection values() method of HashMap class */ Collection c = hMap.values(); //obtain an Iterator for Collection Iterator itr = c.iterator(); //iterate through HashMap values iterator while (itr.hasNext()) System.out.println(itr.next()); }
Example 6
Source File: HMaster.java From hbase with Apache License 2.0 | 6 votes |
public HashMap<String, List<Pair<ServerName, ReplicationLoadSource>>> getReplicationLoad(ServerName[] serverNames) { List<ReplicationPeerDescription> peerList = this.getReplicationPeerManager().listPeers(null); if (peerList == null) { return null; } HashMap<String, List<Pair<ServerName, ReplicationLoadSource>>> replicationLoadSourceMap = new HashMap<>(peerList.size()); peerList.stream() .forEach(peer -> replicationLoadSourceMap.put(peer.getPeerId(), new ArrayList<>())); for (ServerName serverName : serverNames) { List<ReplicationLoadSource> replicationLoadSources = getServerManager().getLoad(serverName).getReplicationLoadSourceList(); for (ReplicationLoadSource replicationLoadSource : replicationLoadSources) { replicationLoadSourceMap.get(replicationLoadSource.getPeerID()) .add(new Pair<>(serverName, replicationLoadSource)); } } for (List<Pair<ServerName, ReplicationLoadSource>> loads : replicationLoadSourceMap.values()) { if (loads.size() > 0) { loads.sort(Comparator.comparingLong(load -> (-1) * load.getSecond().getReplicationLag())); } } return replicationLoadSourceMap; }
Example 7
Source File: Solution.java From JavaExercises with GNU General Public License v2.0 | 5 votes |
public static int getCountTheSameFirstName(HashMap<String, String> map, String name) { int count = 0; /*for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { Map.Entry value = (Map.Entry) iterator.next(); if (value.getValue().equals(name)) count++; }*/ for (String value : map.values()) if (value.equals(name)) count++; return count; }
Example 8
Source File: ExtraDataBeaconTracker.java From android-beacon-library with Apache License 2.0 | 5 votes |
private void updateTrackedBeacons(@NonNull Beacon beacon) { HashMap<Integer,Beacon> matchingTrackedBeacons = mBeaconsByKey.get(getBeaconKey(beacon)); if (null != matchingTrackedBeacons) { for (Beacon matchingTrackedBeacon : matchingTrackedBeacons.values()) { matchingTrackedBeacon.setRssi(beacon.getRssi()); matchingTrackedBeacon.setExtraDataFields(beacon.getDataFields()); } } }
Example 9
Source File: StatManager.java From dsworkbench with Apache License 2.0 | 5 votes |
public void takeSnapshot() { long now = System.currentTimeMillis(); logger.debug("Taking stat snapshot from '" + now + "'"); for(Integer allyKey: data.keySet()) { HashMap<Integer, TribeStatsElement> tribes = data.get(allyKey); for(TribeStatsElement elem: tribes.values()) { elem.takeSnapshot(now); } } }
Example 10
Source File: PackageManagerActivity.java From hellomap3d-android with MIT License | 5 votes |
private ArrayList<Package> getPackages() { HashMap<String, Package> pkgs = new HashMap<String, Package>(); PackageInfoVector packageInfoVector = packageManager.getServerPackages(); for (int i = 0; i < packageInfoVector.size(); i++) { PackageInfo packageInfo = packageInfoVector.get(i); // Get the list of names for this package. Each package may have multiple names, // packages are grouped using '/' as a separator, so the the full name for Sweden // is "Europe/Northern Europe/Sweden". We display packages as a tree, so we need // to extract only relevant packages belonging to the current folder. StringVector packageNames = packageInfo.getNames(language); for (int j = 0; j < packageNames.size(); j++) { String packageName = packageNames.get(j); if (!packageName.startsWith(currentFolder)) { continue; // belongs to a different folder, so ignore } packageName = packageName.substring(currentFolder.length()); int index = packageName.indexOf('/'); Package pkg; if (index == -1) { // This is actual package PackageStatus packageStatus = packageManager.getLocalPackageStatus(packageInfo.getPackageId(), -1); pkg = new Package(packageName, packageInfo, packageStatus); } else { // This is package group packageName = packageName.substring(0, index); if (pkgs.containsKey(packageName)) { continue; } pkg = new Package(packageName, null, null); } pkgs.put(packageName, pkg); } } return new ArrayList<Package>(pkgs.values()); }
Example 11
Source File: HBaseInputFormatRegional.java From SpyGlass with Apache License 2.0 | 5 votes |
private HBaseTableSplitRegional[] convertToRegionalSplitArray( HBaseTableSplitGranular[] splits) throws IOException { if (splits == null) throw new IOException("The list of splits is null => " + splits); HashMap<String, HBaseTableSplitRegional> regionSplits = new HashMap<String, HBaseTableSplitRegional>(); for (HBaseTableSplitGranular hbt : splits) { HBaseTableSplitRegional mis = null; if (regionSplits.containsKey(hbt.getRegionName())) { mis = regionSplits.get(hbt.getRegionName()); } else { regionSplits.put(hbt.getRegionName(), new HBaseTableSplitRegional( hbt.getRegionLocation(), hbt.getRegionName())); mis = regionSplits.get(hbt.getRegionName()); } mis.addSplit(hbt); regionSplits.put(hbt.getRegionName(), mis); } // for(String region : regionSplits.keySet() ) { // regionSplits.get(region) // } Collection<HBaseTableSplitRegional> outVals = regionSplits.values(); LOG.debug("".format("Returning array of splits : %s", outVals)); if (outVals == null) throw new IOException("The list of multi input splits were null"); return outVals.toArray(new HBaseTableSplitRegional[outVals.size()]); }
Example 12
Source File: CompressionProviderFactoryTest.java From hop with Apache License 2.0 | 5 votes |
/** * Test that all core compression plugins (None, Zip, GZip) are available via the factory */ @Test public void getCoreProviders() { @SuppressWarnings( "serial" ) final HashMap<String, Boolean> foundProvider = new HashMap<String, Boolean>() { { put( "None", false ); put( "Zip", false ); put( "GZip", false ); put( "Snappy", false ); put( "Hadoop-snappy", false ); } }; Collection<ICompressionProvider> providers = factory.getCompressionProviders(); assertNotNull( providers ); for ( ICompressionProvider provider : providers ) { assertNotNull( foundProvider.get( provider.getName() ) ); foundProvider.put( provider.getName(), true ); } boolean foundAllProviders = true; for ( Boolean b : foundProvider.values() ) { foundAllProviders = foundAllProviders && b; } assertTrue( foundAllProviders ); }
Example 13
Source File: Patch.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
@Override protected void setAlpha(final float alpha, final boolean update) { if (isStack()) { final HashMap<Double,Patch> ht = new HashMap<Double,Patch>(); getStackPatchesNR(ht); for (final Patch pa : ht.values()) { pa.alpha = alpha; pa.updateInDatabase("alpha"); Display.repaint(pa.layer, pa, 5); } Display3D.setTransparency(this, alpha); } else super.setAlpha(alpha, update); }
Example 14
Source File: TextProcessor.java From sax-vsm_classic with GNU General Public License v2.0 | 5 votes |
/** * Normalize the vector to the norm of 1. * * @param vector the vector. * @return normalized vector. */ public HashMap<String, Double> normalizeToUnitVector(HashMap<String, Double> vector) { double sum = 0d; for (double value : vector.values()) { sum = sum + value * value; } sum = Math.sqrt(sum); HashMap<String, Double> res = new HashMap<String, Double>(); for (Entry<String, Double> e : vector.entrySet()) { res.put(e.getKey(), e.getValue() / sum); } return res; }
Example 15
Source File: QueryUtil.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
private static void appendJoins(StringBuilder statement, HashMap<String, AssociationPath> explicitJoinsMap) { ArrayList<AssociationPath> joins = new ArrayList<AssociationPath>(explicitJoinsMap.values()); Collections.sort(joins, new JoinComparator()); Iterator<AssociationPath> it = joins.iterator(); while (it.hasNext()) { AssociationPath join = it.next(); StringBuilder joinSb = new StringBuilder(" left join "); joinSb.append(join.getAliasedPathString()); joinSb.append(" as "); joinSb.append(join.getJoinAlias()); statement.append(joinSb); } }
Example 16
Source File: TreedMapper.java From compiler with Apache License 2.0 | 4 votes |
private <E> int length(HashMap<E, Integer> vector) { int len = 0; for (int val : vector.values()) len += val; return len; }
Example 17
Source File: TaskListUserDAOHibernate.java From lams with GNU General Public License v2.0 | 4 votes |
@Override @SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) public Collection<TaskListUserDTO> getPagedUsersBySession(Long sessionId, int page, int size, String sortBy, String sortOrder, String searchString, IUserManagementService userManagementService) { String[] portraitStrings = userManagementService.getPortraitSQL("user.user_id"); StringBuilder bldr = new StringBuilder(LOAD_USERS_SELECT) .append(portraitStrings[0]) .append(LOAD_USERS_FROM) .append(portraitStrings[1]) .append(LOAD_USERS_JOINS) .append(sortOrder); NativeQuery query = getSession().createNativeQuery(bldr.toString()); query.setParameter("sessionId", sessionId); // support for custom search from a toolbar searchString = searchString == null ? "" : searchString; query.setParameter("searchString", searchString); query.setFirstResult(page * size); query.setMaxResults(size); List<Object[]> list = query.list(); //group by userId as long as it returns all completed visitLogs for each user HashMap<Long, TaskListUserDTO> userIdToUserDto = new LinkedHashMap<Long, TaskListUserDTO>(); if (list != null && list.size() > 0) { for (Object[] element : list) { Long userId = ((Number) element[0]).longValue(); String fullName = (String) element[1]; boolean isVerifiedByMonitor = element[2] == null ? false : (Boolean) element[2]; Long completedTaskUid = element[3] == null ? 0 : ((Number) element[3]).longValue(); Long portraitId = element[4] == null ? null : ((Number) element[4]).longValue(); TaskListUserDTO userDto = (userIdToUserDto.get(userId) == null) ? new TaskListUserDTO() : userIdToUserDto.get(userId); userDto.setUserId(userId); userDto.setFullName(fullName); userDto.setVerifiedByMonitor(isVerifiedByMonitor); userDto.getCompletedTaskUids().add(completedTaskUid); userDto.setPortraitId(portraitId); userIdToUserDto.put(userId, userDto); } } return userIdToUserDto.values(); }
Example 18
Source File: Solution.java From JavaRushTasks with MIT License | 4 votes |
public static void main(String[] args) throws Exception { Scanner reader = new Scanner(System.in); String filename = reader.nextLine(); FileInputStream f = new FileInputStream(filename); HashMap<Integer, Integer> mapOfByte = new HashMap<Integer, Integer>(); int value = 0; Integer count = 0; while (f.available() > 0) { value = f.read(); count = mapOfByte.get(value); if (count != null) count++; else count = 0; mapOfByte.put(value, count); } f.close(); //int min = Collections.min(mapOfByte.values()); //Находим минимальное число повторений boolean first = true; int min = 0; for (int amountByte : mapOfByte.values()) { if (first) { min = amountByte; first = false; } if (min > amountByte) min = amountByte; } //Выводим for (Map.Entry pair : mapOfByte.entrySet()) { if (min == (int) pair.getValue()) System.out.print(" " + pair.getKey()); } }
Example 19
Source File: VisNetHandler.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 4 votes |
public static WeakReference<TileVisNode> addNode(World world, TileVisNode vn) { WeakReference ref = new WeakReference(vn); HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources .get(world.provider.dimensionId); if (sourcelist == null) { sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>(); return null; } ArrayList<Object[]> nearby = new ArrayList<Object[]>(); for (WeakReference<TileVisNode> root : sourcelist.values()) { if (!isNodeValid(root)) continue; TileVisNode source = root.get(); float r = inRange(world, vn.getLocation(), source.getLocation(), vn.getRange()); if (r > 0) { nearby.add(new Object[] { source, r - vn.getRange() * 2 }); } nearby = findClosestNodes(vn, source, nearby); cache.clear(); } float dist = Float.MAX_VALUE; TileVisNode closest = null; if (nearby.size() > 0) { for (Object[] o : nearby) { if ((Float) o[1] < dist && (vn.getAttunement() == -1 || ((TileVisNode) o[0]).getAttunement() == -1 || vn.getAttunement() == ((TileVisNode) o[0]).getAttunement())//) { && canNodeBeSeen(vn,(TileVisNode)o[0])) { dist = (Float) o[1]; closest = (TileVisNode) o[0]; } } } if (closest != null) { closest.getChildren().add(ref); nearbyNodes.clear(); return new WeakReference(closest); } return null; }
Example 20
Source File: VisNetHandler.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 4 votes |
private static void calculateNearbyNodes(World world, int x, int y, int z) { HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources .get(world.provider.dimensionId); if (sourcelist == null) { sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>(); return; } ArrayList<WeakReference<TileVisNode>> cn = new ArrayList<WeakReference<TileVisNode>>(); WorldCoordinates drainer = new WorldCoordinates(x, y, z, world.provider.dimensionId); ArrayList<Object[]> nearby = new ArrayList<Object[]>(); for (WeakReference<TileVisNode> root : sourcelist.values()) { if (!isNodeValid(root)) continue; TileVisNode source = root.get(); TileVisNode closest = null; float range = Float.MAX_VALUE; float r = inRange(world, drainer, source.getLocation(), source.getRange()); if (r > 0) { range = r; closest = source; } ArrayList<WeakReference<TileVisNode>> children = new ArrayList<WeakReference<TileVisNode>>(); children = getAllChildren(source,children); for (WeakReference<TileVisNode> child : children) { TileVisNode n = child.get(); if (n != null && !n.equals(root)) { float r2 = inRange(n.getWorldObj(), n.getLocation(), drainer, n.getRange()); if (r2 > 0 && r2 < range) { range = r2; closest = n; } } } if (closest != null) { cn.add(new WeakReference(closest)); } } nearbyNodes.put(drainer, cn); }