Class Buckets
java.lang.Object
com.yetnt.utils.collection.buckets.Buckets
Utility class for dividing an
ArrayList into multiple sub-lists,
referred to as "buckets," based on various criteria.
From Jaiva!
- Author:
- Lehlogonolo Poole
- See Also:
-
Constructor Details
-
Buckets
public Buckets()
-
-
Method Details
-
of
Divides anArrayListinto multiple buckets based on the provided classes. Each bucket will contain elements from the original list that are instances of the corresponding class. The order of elements within each bucket is preserved from the original list.- Parameters:
original- The originalArrayListto be divided.classes- A variable number ofClassobjects, each representing a type for which a separate bucket will be created.- Returns:
- An
ArrayListofArrayLists, where each innerArrayListis a bucket containing elements of a specific type from the original list. The order of buckets in the returned list corresponds to the order ofclassesprovided.
-
of
Divides anArrayListinto multiple buckets based on customBucketimplementations. Each bucket will contain elements from the original list that satisfy the condition defined by the correspondingBucket'sshouldHoldmethod. The order of elements within each bucket is preserved from the original list.- Parameters:
original- The originalArrayListto be divided.buckets- A variable number ofBucketobjects, each defining a custom condition for elements to be placed into its respective bucket.- Returns:
- An
ArrayListofArrayLists, where each innerArrayListis a bucket containing elements that satisfy the condition of the correspondingBucket. The order of buckets in the returned list corresponds to the order ofbucketsprovided.
-
scoop
-