All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.firefang.power.common.util.CollectionUtil Maven / Gradle / Ivy

There is a newer version: 0.0.6
Show newest version
package io.github.firefang.power.common.util;

import java.util.Collection;
import java.util.Map;

/**
 * Collection工具类
 * 
 * @author xinufo
 *
 */
public abstract class CollectionUtil {
    public static final float MAP_DEFAULT_LOAD_FACTOR = 0.75F;
    public static final int MAP_DEFAULT_SIZE = 16;

    public static boolean isEmpty(Collection collection) {
        return collection == null ? true : collection.isEmpty();
    }

    public static boolean isEmpty(Map map) {
        return map == null ? true : map.isEmpty();
    }

    public static int mapSize(int numOfElements) {
        return mapSize(numOfElements, MAP_DEFAULT_LOAD_FACTOR);
    }

    public static int mapSize(int numOfElements, float factor) {
        return (int) (numOfElements / factor + 1);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy