Interface Bucket<E>

Type Parameters:
E - the element type
All Superinterfaces:
Collection<E>, Iterable<E>, Set<E>
All Known Implementing Classes:
AbstractBucket

public interface Bucket<E> extends Set<E>
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 Details

    • getPartitionCount

      int getPartitionCount()
      Gets the number of partitions used to form this bucket.
      Returns:
      the number of partitions in this bucket
    • getPartition

      @Nonnull BucketPartition<E> getPartition(int i)
      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

      @Nonnull List<BucketPartition<E>> getPartitions()
      Gets the partitions which form this bucket.
      Returns:
      the partitions within the bucket
    • asCycle

      @Nonnull Cycle<BucketPartition<E>> 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