Java List Size sizeOfListMap(Map> map)

Here you can find the source of sizeOfListMap(Map> map)

Description

Get the total number of elements in a map whose values are lists of elements.

License

Apache License

Parameter

Parameter Description
T the type of the keys in the map.
U the type of the elements in the lists.
map the map of which to get the size.

Return

the size of the map as an int value.

Declaration

public static <T, U> int sizeOfListMap(Map<T, List<U>> map) 

Method Source Code

//package com.java2s;
/*/*w w w. j  av a2  s  .  c  om*/
 * JPPF.
 * Copyright (C) 2005-2010 JPPF Team.
 * http://www.jppf.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.*;

public class Main {
    /**
     * Get the total number of elements in a map whose values are lists of elements.
     * @param <T> the type of the keys in the map.
     * @param <U> the type of the elements in the lists.
     * @param map the map of which to get the size.
     * @return the size of the map as an int value.
     */
    public static <T, U> int sizeOfListMap(Map<T, List<U>> map) {
        int result = 0;
        for (Map.Entry<T, List<U>> entry : map.entrySet())
            result += entry.getValue().size();
        return result;
    }
}

Related

  1. getSize(List sourceList)
  2. size(List list)
  3. size(Object[] list)
  4. sizeNotNull(final List list)
  5. sizeOf(List l)
  6. sizeOfStringToStringListMap( Map> m)
  7. sizeSafe(List list)