类 CollectionUtils


  • public class CollectionUtils
    extends java.lang.Object
    Provides utility methods and decorators for Collection instances.
    从以下版本开始:
    Commons Collections 1.0
    版本:
    $Revision: 1713167 $ $Date: 2015-11-07 20:44:03 +0100 (Sat, 07 Nov 2015) $
    作者:
    Rodney Waldhoff, Paul Jack, Stephen Colebourne, Steve Downey, Herve Quiroz, Peter KoBek, Matthew Hawthorne, Janek Bogucki, Phil Steitz, Steven Melzer, Jon Schewe, Neil O'Toole, Stephen Smith
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      private static java.lang.Integer INTEGER_ONE
      Constant to avoid repeated object creation.
    • 构造器概要

      构造器 
      构造器 说明
      CollectionUtils()
      CollectionUtils should not normally be instantiated.
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static java.util.Map getCardinalityMap​(java.util.Collection coll)
      Returns a Map mapping each unique element in the given Collection to an Integer representing the number of occurrences of that element in the Collection.
      private static int getFreq​(java.lang.Object obj, java.util.Map freqMap)  
      static boolean isEmpty​(java.util.Collection coll)
      Null-safe check if the specified collection is empty.
      static boolean isEqualCollection​(java.util.Collection a, java.util.Collection b)
      Returns true iff the given Collections contain exactly the same elements with exactly the same cardinalities.
      static java.util.Collection subtract​(java.util.Collection a, java.util.Collection b)
      Returns a new Collection containing a - b.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • INTEGER_ONE

        private static final java.lang.Integer INTEGER_ONE
        Constant to avoid repeated object creation.
    • 构造器详细资料

      • CollectionUtils

        public CollectionUtils()
        CollectionUtils should not normally be instantiated.
    • 方法详细资料

      • subtract

        public static java.util.Collection subtract​(java.util.Collection a,
                                                    java.util.Collection b)
        Returns a new Collection containing a - b. The cardinality of each element e in the returned Collection will be the cardinality of e in a minus the cardinality of e in b, or zero, whichever is greater.
        参数:
        a - the collection to subtract from, must not be null
        b - the collection to subtract, must not be null
        返回:
        a new collection with the results
        另请参阅:
        Collection.removeAll(java.util.Collection<?>)
      • getCardinalityMap

        public static java.util.Map getCardinalityMap​(java.util.Collection coll)
        Returns a Map mapping each unique element in the given Collection to an Integer representing the number of occurrences of that element in the Collection.

        Only those elements present in the collection will appear as keys in the map.

        参数:
        coll - the collection to get the cardinality map for, must not be null
        返回:
        the populated cardinality map
      • isEqualCollection

        public static boolean isEqualCollection​(java.util.Collection a,
                                                java.util.Collection b)
        Returns true iff the given Collections contain exactly the same elements with exactly the same cardinalities.

        That is, iff the cardinality of e in a is equal to the cardinality of e in b, for each element e in a or b.

        参数:
        a - the first collection, must not be null
        b - the second collection, must not be null
        返回:
        true iff the collections contain the same elements with the same cardinalities.
      • isEmpty

        public static boolean isEmpty​(java.util.Collection coll)
        Null-safe check if the specified collection is empty.

        Null returns true.

        参数:
        coll - the collection to check, may be null
        返回:
        true if empty or null
        从以下版本开始:
        Commons Collections 3.2
      • getFreq

        private static int getFreq​(java.lang.Object obj,
                                   java.util.Map freqMap)