Package dev.demeng.pluginbase.bucket
Interface Bucket<E>
- Type Parameters:
E- the element type
- All Superinterfaces:
Collection<E>,Iterable<E>,Set<E>
- All Known Implementing Classes:
AbstractBucket
A bucket is an extension of
Set, which allows contained elements to be separated into
parts by a PartitioningStrategy.
The performance of Bucket should be largely similar to the performance of the
underlying Set. Elements are stored twice - once in a set containing all elements in the
bucket, and again in a set representing each partition.
-
Method Summary
Modifier and TypeMethodDescriptionasCycle()Returns a cycle instance unique to this bucket.getPartition(int i) Gets the partition with the given index valueintGets the number of partitions used to form this bucket.Gets the partitions which form this bucket.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Method Details
-
getPartitionCount
int getPartitionCount()Gets the number of partitions used to form this bucket.- Returns:
- the number of partitions in this bucket
-
getPartition
Gets the partition with the given index value- Parameters:
i- the partition index- Returns:
- the partition
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= getPartitionCount())
-
getPartitions
Gets the partitions which form this bucket.- Returns:
- the partitions within the bucket
-
asCycle
Returns a cycle instance unique to this bucket.This method is provided as a utility for operating deterministically on all elements within the bucket over a period of time.
The same cycle instance is returned for each bucket.
- Returns:
- a cycle of partitions
-