Package com.xxl.tool.core
Class CollectionTool
java.lang.Object
com.xxl.tool.core.CollectionTool
Collection Tool
- Author:
- xuxueli 2024-01-21 05:03:10 (some references to other libraries)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontains(Collection<?> collection, Object value) Returnstrueif the value in collections.static Collectiondisjunction(Collection a, Collection b) 交集的补集 Returns aCollectioncontaining the exclusive disjunction (symmetric difference) of the givenCollections.static MapgetCardinalityMap(Collection coll) 元素出现次数 Returns aMapmapping each unique element in the givenCollectionto anIntegerrepresenting the number of occurrences of that element in theCollection.static Collectionintersection(Collection a, Collection b) 交集 Returns aCollectioncontaining the intersection of the givenCollections.static booleanisEmpty(Collection coll) Null-safe check if the specified collection is empty.static booleanisNotEmpty(Collection coll) Null-safe check if the specified collection is not empty.static <E> ArrayList<E>bulid new ArrayListstatic <E> ArrayList<E>newArrayList(E... elements) bulid new ArrayList (with data)split to batch-liststatic Collectionsubtract(Collection a, Collection b) A与B的差 (A-B) Returns a newCollectioncontaining a - b.static Collectionunion(Collection a, Collection b) 并集 Returns aCollectioncontaining the union of the givenCollections.
-
Constructor Details
-
CollectionTool
public CollectionTool()
-
-
Method Details
-
isEmpty
Null-safe check if the specified collection is empty.Null returns true.
- Parameters:
coll- the collection to check, may be null- Returns:
- true if empty or null
- Since:
- Commons Collections 3.2
-
isNotEmpty
Null-safe check if the specified collection is not empty.Null returns false.
- Parameters:
coll- the collection to check, may be null- Returns:
- true if non-null and non-empty
- Since:
- Commons Collections 3.2
-
contains
Returnstrueif the value in collections.- Parameters:
collection-value-- Returns:
-
union
并集 Returns aCollectioncontaining the union of the givenCollections.- Parameters:
a- the first collection, must not be nullb- the second collection, must not be null- Returns:
- the union of the two collections
- See Also:
-
getCardinalityMap
元素出现次数 Returns aMapmapping each unique element in the givenCollectionto anIntegerrepresenting the number of occurrences of that element in theCollection.Only those elements present in the collection will appear as keys in the map.
- Parameters:
coll- the collection to get the cardinality map for, must not be null- Returns:
- the populated cardinality map
-
intersection
交集 Returns aCollectioncontaining the intersection of the givenCollections.- Parameters:
a- the first collection, must not be nullb- the second collection, must not be null- Returns:
- the intersection of the two collections
-
disjunction
交集的补集 Returns aCollectioncontaining the exclusive disjunction (symmetric difference) of the givenCollections.- Parameters:
a- the first collection, must not be nullb- the second collection, must not be null- Returns:
- the symmetric difference of the two collections
-
subtract
A与B的差 (A-B) Returns a newCollectioncontaining a - b.- Parameters:
a- the collection to subtract from, must not be nullb- the collection to subtract, must not be null- Returns:
- a new collection with the results
- See Also:
-
newArrayList
bulid new ArrayList- Type Parameters:
E-- Returns:
-
newArrayList
bulid new ArrayList (with data)- Type Parameters:
E-- Parameters:
elements-- Returns:
-
split
split to batch-list- Type Parameters:
E-- Parameters:
list-batchSize-- Returns:
-