All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.lucko.helper.bucket.Bucket Maven / Gradle / Ivy

There is a newer version: 5.6.14
Show newest version
/*
 * This file is part of helper, licensed under the MIT License.
 *
 *  Copyright (c) lucko (Luck) 
 *  Copyright (c) contributors
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in all
 *  copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 *  SOFTWARE.
 */

package me.lucko.helper.bucket;

import me.lucko.helper.bucket.partitioning.PartitioningStrategy;

import java.util.List;
import java.util.Set;

import javax.annotation.Nonnull;

/**
 * A bucket is an extension of {@link Set}, which allows contained elements
 * to be separated into parts by a {@link PartitioningStrategy}.
 *
 * 

The performance of {@link Bucket} should be largely similar to the performance * of the underlying {@link Set}. Elements are stored twice - once in a set * containing all elements in the bucket, and again in a set representing each partition.

* * @param the element type */ public interface Bucket extends Set { /** * Gets the number of partitions used to form this bucket. * * @return the number of partitions in this bucket */ int getPartitionCount(); /** * Gets the partition with the given index value * * @param i the partition index * @return the partition * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= getPartitionCount()) */ @Nonnull BucketPartition getPartition(int i); /** * Gets the partitions which form this bucket. * * @return the partitions within the bucket */ @Nonnull List> getPartitions(); /** * 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.

* * @return a cycle of partitions */ @Nonnull Cycle> asCycle(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy