显然,ArrayList.getValue().size()不是正确的答案。

我环顾四周,向Google提出一个简单的问题。

我已经在伪代码注释中非常全面地解释了我要做什么,也许有人知道如何遍历该数组列表?

public static void perceptron_data_struc_generateur(Set<String> GLOBO_DICT,
                                                    Map<File, ArrayList<String> > fileDict,
                                                    Map<File, int[] > perceptron_input)
{

    //create a new entry in the array list 'perceptron_input'
    //with the key as the file name from fileDict
        //create a new array which is the length of GLOBO_DICT
        //iterate through the indicies of GLOBO_DICT
            //for all words in globo dict, if that word appears in fileDict,
            //increment the perceptron_input index that corresponds to that
            //word in GLOBO_DICT by the number of times that word appears in fileDict

    for (Map.Entry entry : fileDict.entrySet())
    {
        //System.out.println(entry.getKey());
        int[] cross_czech = new int[GLOBO_DICT.size()];

        for (String s : GLOBO_DICT)
        {
            for(int i = 0; i < entry.getValue() ).size(); i++)
            {

            }
        }

    }
}


最终,目的是在您感兴趣的情况下实现对this question的第一个答案。

最佳答案

遍历地图的ArrayList值:

for (Map.Entry<File, ArrayList<String>> entry : fileDict.entrySet())
{
    int[] cross_czech = new int[GLOBO_DICT.size()];

    for (String s : GLOBO_DICT)
    {
        for(String st : entry.getValue()) // iterates over all the Strings
                                          // of the ArrayList of the
                                          // current entry
        {

        }
    }

}

关于java - 确定哈希图内部数组列表的大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28556698/

10-11 16:43