T - the generic type of the itemspublic class Bucket<T> extends Object
Buckets have a fixed capacity. Once reached, the bucket will accept no more items
| Constructor and Description |
|---|
Bucket(int index,
int capacity)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T item)
Adds the given
item if the bucket still has capacity. |
boolean |
contains(Position position) |
Optional<T> |
get(int index)
Obtains the value that was added at the given
index through the add(Object) method. |
int |
getIndex() |
public Bucket(int index,
int capacity)
index - the bucket's index.capacity - the bucket's capacity.public Optional<T> get(int index)
index through the add(Object) method.
If no such value was added, it will return an empty value.index - the item's indexOptional valuepublic boolean contains(Position position)
position - a Positionpositionpublic int getIndex()
this bucket's indexpublic boolean add(T item)
item if the bucket still has capacity.item - the item to be addedCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.