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


Java HashMap.size方法代碼示例

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


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

示例1: setData

import java.util.HashMap; //導入方法依賴的package包/類
public void setData(Platform[] platforms, HashMap<String, String> hiddenPlatforms) {
    if (platforms != null) {
        if (hiddenPlatforms == null || hiddenPlatforms.size() <= 0) {
            this.logos.addAll(Arrays.asList(platforms));
        } else {
            ArrayList<Platform> ps = new ArrayList();
            for (Platform p : platforms) {
                if (!hiddenPlatforms.containsKey(p.getName())) {
                    ps.add(p);
                }
            }
            this.logos.addAll(ps);
        }
        this.checkedPositionList.clear();
        notifyDataSetChanged();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:PlatformGridViewAdapter.java

示例2: mergeMethods

import java.util.HashMap; //導入方法依賴的package包/類
private MethodDescriptor[] mergeMethods(MethodDescriptor[] superDescs) {
    HashMap<String, MethodDescriptor> subMap = internalAsMap(methods);

    for (MethodDescriptor superMethod : superDescs) {
        String methodName = getQualifiedName(superMethod.getMethod());
        MethodDescriptor method = subMap.get(methodName);
        if (method == null) {
            subMap.put(methodName, superMethod);
        } else {
            method.merge(superMethod);
        }
    }
    MethodDescriptor[] theMethods = new MethodDescriptor[subMap.size()];
    subMap.values().toArray(theMethods);
    return theMethods;
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:17,代碼來源:StandardBeanInfo.java

示例3: searchForDevice

import java.util.HashMap; //導入方法依賴的package包/類
private void searchForDevice(Context context) {
    HashMap<String, UsbDevice> devices = mUsbManager.getDeviceList();
    UsbDevice selected = null;
    int num_of_devices = devices.size();

    if (num_of_devices == 1) {
        //If there's only one device, go ahead and connect. YOLO to keyboards!
        for (UsbDevice device : devices.values()) {
            selected = device;
        }

        if (mUsbManager.hasPermission(selected)) {
            setUSBDevice(selected);
        } else {
            mUsbManager.requestPermission(selected, mPermissionIntent);
        }
    } else {
        if (num_of_devices > 1) {
            Log.wtf(TAG, "Extra devices are plugged in. Found: " + num_of_devices);
        }
        showListOfDevices(context);
    }

}
 
開發者ID:etsy,項目名稱:divertsy-client,代碼行數:25,代碼來源:UsbScaleManager.java

示例4: PostData

import java.util.HashMap; //導入方法依賴的package包/類
public static String PostData(String url, HashMap<String, String> params) {

        try {
            FormBody.Builder build = new FormBody.Builder();
            int len = params.size();
            if (len <= 0) {
                return "";
            }
            Set<String> keys = params.keySet();
            for (String s : keys) {
                build.add(s, params.get(s));
            }
            FormBody body = build.build();
            Request request = new Request.Builder().url(url).post(body).headers(headers).build();
            Response execute = client.newCall(request).execute();
            if (execute.isSuccessful()) {
                return execute.body().string();
            }
        } catch (Exception e) {

        }
        return "";
    }
 
開發者ID:Qrilee,項目名稱:MusicuuApi,代碼行數:24,代碼來源:NetUtil.java

示例5: createImmutable

import java.util.HashMap; //導入方法依賴的package包/類
/**
 * Creates an immutable <code>AttributeSet</code> as a copy of <code>AttributeSet</code>s
 * passed into this method. If the <code>AttributeSet</code>s
 * contain attributes with the same name the resulting <code>AttributeSet</code>
 * will return value of the first attribute it will find going through
 * the sets in the order as they were passed in.
 *
 * @param sets    The <code>AttributeSet</code>s which attributes will become
 *                a contents of the newly created <code>AttributeSet</code>.
 *
 * @return The new immutable <code>AttributeSet</code>.
 */
public static AttributeSet createImmutable(AttributeSet... sets) {
    if (true) {
        return org.netbeans.modules.editor.settings.AttrSet.merge(sets);
    }
    HashMap<Object, Object> map = new HashMap<Object, Object>();
    
    for(int i = sets.length - 1; i >= 0; i--) {
        AttributeSet set = sets[i];
        for(Enumeration<?> keys = set.getAttributeNames(); keys.hasMoreElements(); ) {
            Object attrKey = keys.nextElement();
            Object attrValue = set.getAttribute(attrKey);

            map.put(attrKey, attrValue);
        }
    }

    return map.size() > 0 ? new Immutable(map) : SimpleAttributeSet.EMPTY;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:AttributesUtilities.java

示例6: setData

import java.util.HashMap; //導入方法依賴的package包/類
public void setData(Platform[] platforms, HashMap<String, String> hiddenPlatforms) {
	if(platforms == null)
		return;
	if (hiddenPlatforms != null && hiddenPlatforms.size() > 0) {
		ArrayList<Platform> ps = new ArrayList<Platform>();
		for (Platform p : platforms) {
			if (hiddenPlatforms.containsKey(p.getName())) {
				continue;
			}
			ps.add(p);
		}

		logos.addAll(ps);
	} else {
		logos.addAll(Arrays.asList(platforms));
	}
	checkedPositionList.clear();
	notifyDataSetChanged();
}
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:20,代碼來源:PlatformGridViewAdapter.java

示例7: publishClips

import java.util.HashMap; //導入方法依賴的package包/類
private void publishClips(HashMap<Long, Clip> wantClipsPublished, long channelId,
        int clipsPublishedAlready) {
    int weight = clipsPublishedAlready + wantClipsPublished.size();
    for (Clip clip : wantClipsPublished.values()) {
        SampleTvProvider.publishProgram(mContext, clip, channelId, weight--);
    }
}
 
開發者ID:googlesamples,項目名稱:leanback-homescreen-channels,代碼行數:8,代碼來源:SynchronizeDatabaseJobService.java

示例8: saveData

import java.util.HashMap; //導入方法依賴的package包/類
private void saveData(@NonNull ReparativeDelegates.Container writeOnlyContainer) {
    InstanceRestoration restorationAnnotation = this.getClass().getAnnotation(InstanceRestoration.class);
    Field[] fields = null;

    if (restorationAnnotation.policy() == InstanceRestoration.Policy.IGNORE_ALL_FIELDS) {
        fields = Reflector.getAnnotatedFields(this, Restore.class);
    } else {
        fields = Reflector.getNonAnnotatedFields(this, Ignore.class);
    }

    if (fields != null && fields.length > 0) {
        for (Field field : fields) {
            try {

                Object object = Reflector.readValue(this, field);
                writeOnlyContainer.set(field.getName(), object);

            } catch (Reflector.ReflectorException ignored) {}
        }

        HashMap<String, Object> saveFailedMap = writeOnlyContainer.getUnboxable();
        if (saveFailedMap.size() > 0) {
            onSaveFailedMapReady(saveFailedMap);
        }

        writeOnlyContainer.flush();
    }
}
 
開發者ID:iFanie,項目名稱:ChocoPie,代碼行數:29,代碼來源:ReparativeActivity.java

示例9: setPhotoMap

import java.util.HashMap; //導入方法依賴的package包/類
public void setPhotoMap(HashMap<Integer, ToadData> photoMap) {
	
	if (this.photoMap == null) {
		updateView();
	}

	this.photoMap = photoMap;

	tableMap = new ArrayList<Integer>();
	tableMap.addAll(photoMap.keySet());

	Object[][] data = new Object[photoMap.size()][3];

	int i = 0;
	for (ToadData toadData : photoMap.values()) {
		data[i][2] = new File(toadData.getFileName()).getName();
		data[i][0] = toadData.getName();
		i++;
	}

	// tableMap.add(pair.getKey());

	// Iterator it = photoMap.entrySet().iterator();
	// while (it.hasNext()) {
	// Map.Entry<Integer, ToadData> pair = (Map.Entry<Integer,
	// ToadData>)it.next();
	//// pair.getKey()
	// System.out.println(pair.getKey() + " = " + pair.getValue());
	// }
	photoList.setData(data);
	this.revalidate();

}
 
開發者ID:fossasia,項目名稱:zooracle,代碼行數:34,代碼來源:ImportView.java

示例10: getTfIdfScores

import java.util.HashMap; //導入方法依賴的package包/類
/**
 * Calculates the instance array containing TF-IDF scores for each token
 * @param tokenCounts the token count for each token ID
 * @return an array of {@link Feature} elements
 */
private Feature[] getTfIdfScores(HashMap<Integer, Integer> tokenCounts) {
    int count;
    double idf;
    double weight;
    double normalizedWeight;
    double norm = 0;

    HashMap<Integer, Double> termWeights = new HashMap<>();
    // calculate TF-IDF scores for each token, also add to normalizer
    for (int tokenID : tokenCounts.keySet()) {
        count = tokenCounts.get(tokenID);
        idf = termIdf.get(tokenID);
        weight = count * idf;

        if (weight > 0.0) {
            norm += Math.pow(weight, 2);
            termWeights.put(tokenID, weight);
        }
    }
    // calculate normalization
    norm = Math.sqrt(norm);

    Feature[] instance = new Feature[termWeights.size()];
    ArrayList<Integer> list = new ArrayList<>(termWeights.keySet());
    Collections.sort(list);
    Double w;
    int i =0;
    // add normalized TF-IDF scores to the training instance
    for (int tokenId: list) {
        w = termWeights.get(tokenId);
        if (w == null) {
            w = 0.0;
        }
        normalizedWeight = w / norm;
        instance[i++] = new FeatureNode(tokenId+offset, normalizedWeight);
    }
    return instance;
}
 
開發者ID:uhh-lt,項目名稱:LT-ABSA,代碼行數:44,代碼來源:TfIdfFeature.java

示例11: validate

import java.util.HashMap; //導入方法依賴的package包/類
@Override
public String validate(String driverClassName, String url, String username, String password,
    HttpRequest request, HashMap<String, String> params) {
    //sd=20.01.2009&ed=28.01.2009
    // проверка на корректность введенных параметров
    QLog.l().logger().trace("Принятые параметры \"" + params.toString() + "\".");
    if (params.size() == 2) {
        Date sd;
        Date fd;
        Date fd1;
        try {
            sd = Uses.FORMAT_DD_MM_YYYY.parse(params.get("sd"));
            fd = Uses.FORMAT_DD_MM_YYYY.parse(params.get("ed"));
            fd1 = DateUtils.addDays(Uses.FORMAT_DD_MM_YYYY.parse(params.get("ed")), 1);
        } catch (ParseException ex) {
            return "<br>Ошибка ввода параметров! Не все параметры введены корректно(дд.мм.гггг).";
        }
        if (!sd.after(fd)) {
            paramMap.put("sd", sd);
            paramMap.put("ed", fd);
            paramMap.put("ed1", fd1);
        } else {
            return "<br>Ошибка ввода параметров! Дата начала больше даты завершения.";
        }

    } else {
        return "<br>Ошибка ввода параметров!";
    }
    return null;// все нормально
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:31,代碼來源:RatioServices.java

示例12: getMapMembers

import java.util.HashMap; //導入方法依賴的package包/類
public Member[] getMapMembers(HashMap<Member, Long> members) {
	synchronized (members) {
		Member[] result = new Member[members.size()];
		members.keySet().toArray(result);
		return result;
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:8,代碼來源:AbstractReplicatedMap.java

示例13: removeJob

import java.util.HashMap; //導入方法依賴的package包/類
/**
 * <p>
 * Remove (delete) the <code>{@link org.quartz.Job}</code> with the given
 * name, and any <code>{@link org.quartz.Trigger}</code> s that reference
 * it.
 * </p>
 *
 * @return <code>true</code> if a <code>Job</code> with the given name &
 *         group was found and removed from the store.
 */
public boolean removeJob(JobKey jobKey) {

    boolean found = false;

    synchronized (lock) {
        List<OperableTrigger> triggersOfJob = getTriggersForJob(jobKey);
        for (OperableTrigger trig: triggersOfJob) {
            this.removeTrigger(trig.getKey());
            found = true;
        }
        
        found = (jobsByKey.remove(jobKey) != null) | found;
        if (found) {

            HashMap<JobKey, JobWrapper> grpMap = jobsByGroup.get(jobKey.getGroup());
            if (grpMap != null) {
                grpMap.remove(jobKey);
                if (grpMap.size() == 0) {
                    jobsByGroup.remove(jobKey.getGroup());
                }
            }
        }
    }

    return found;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:37,代碼來源:RAMJobStore.java

示例14: getCachedWordLists

import java.util.HashMap; //導入方法依賴的package包/類
/**
 * Returns the list of cached files for a specific locale, one for each category.
 *
 * This will return exactly one file for each word list category that matches
 * the passed locale. If several files match the locale for any given category,
 * this returns the file with the closest match to the locale. For example, if
 * the passed word list is en_US, and for a category we have an en and an en_US
 * word list available, we'll return only the en_US one.
 * Thus, the list will contain as many files as there are categories.
 *
 * @param locale the locale to find the dictionary files for, as a string.
 * @param context the context on which to open the files upon.
 * @return an array of binary dictionary files, which may be empty but may not be null.
 */
public static File[] getCachedWordLists(final String locale, final Context context) {
    final File[] directoryList = DictionaryInfoUtils.getCachedDirectoryList(context);
    if (null == directoryList) return EMPTY_FILE_ARRAY;
    final HashMap<String, FileAndMatchLevel> cacheFiles = new HashMap<>();
    for (File directory : directoryList) {
        if (!directory.isDirectory()) continue;
        final String dirLocale =
                DictionaryInfoUtils.getWordListIdFromFileName(directory.getName());
        final int matchLevel = LocaleUtils.getMatchLevel(dirLocale, locale);
        if (LocaleUtils.isMatch(matchLevel)) {
            final File[] wordLists = directory.listFiles();
            if (null != wordLists) {
                for (File wordList : wordLists) {
                    final String category =
                            DictionaryInfoUtils.getCategoryFromFileName(wordList.getName());
                    final FileAndMatchLevel currentBestMatch = cacheFiles.get(category);
                    if (null == currentBestMatch || currentBestMatch.mMatchLevel < matchLevel) {
                        cacheFiles.put(category, new FileAndMatchLevel(wordList, matchLevel));
                    }
                }
            }
        }
    }
    if (cacheFiles.isEmpty()) return EMPTY_FILE_ARRAY;
    final File[] result = new File[cacheFiles.size()];
    int index = 0;
    for (final FileAndMatchLevel entry : cacheFiles.values()) {
        result[index++] = entry.mFile;
    }
    return result;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:46,代碼來源:BinaryDictionaryGetter.java

示例15: getParetoFrontIndices

import java.util.HashMap; //導入方法依賴的package包/類
/**
	 * 
	 * @param solutions
	 * @return
	 */
	public static int[] getParetoFrontIndices(double[][] solutions) {
		double[] dim1 = new double[solutions.length];
		for (int i=0; i<=dim1.length-1; i++) {
			dim1[i] = solutions[i][0];
		}
		
		int[] sortedIdxDim1 = sortedIndices(dim1);
		
		double[][] sortedSolutions = new double[solutions.length][2];
		for (int i=0; i<=sortedIdxDim1.length-1; i++) {
			sortedSolutions[i][0] = solutions[sortedIdxDim1[i]][0];
			sortedSolutions[i][1] = solutions[sortedIdxDim1[i]][1];
		}

		HashMap<Integer,Integer> pFront = new HashMap<Integer,Integer>();
		
		Integer pPointCount = 0;
		Integer pPointIndex = sortedIdxDim1[0];
		pFront.put(pPointCount, pPointIndex);
		
		for (int i=1; i<=sortedIdxDim1.length-1; i++) {
			 double dim2Val = solutions[sortedIdxDim1[i]][1];
			 if (dim2Val<solutions[(int)pPointIndex][1]) {
				 pPointCount = pPointCount+1;
				 pPointIndex = (Integer)sortedIdxDim1[i];
				 pFront.put(pPointCount, pPointIndex);
			 }
		}
		
		int[] pPointIndices = new int[pFront.size()];
		for (int i=0; i<=pPointIndices.length-1; i++) {
			pPointIndices[i] = (int)pFront.get((Integer)i);
		}
		
//		double[][] paretoFront = new double[pFront.size()][2];
//		for (int i=0; i<=paretoFront.length-1; i++) {
//			int pIndex = (int)pFront.get((Integer)i);
//			paretoFront[i][0] = solutions[pIndex][0];
//			paretoFront[i][1] = solutions[pIndex][1];
//		}
		
		return pPointIndices;
	}
 
開發者ID:smart-facility,項目名稱:calendar-based-microsim,代碼行數:49,代碼來源:ArrayHandler.java


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