T
- The type of entrypublic abstract class RandomObjectTable<T> extends Object implements Collection<TableEntry<T>>
Modifier and Type | Field and Description |
---|---|
protected List<TableEntry<T>> |
entries |
Constructor and Description |
---|
RandomObjectTable(int rolls)
Creates a new
RandomObjectTable with the provided number of rolls. |
RandomObjectTable(VariableAmount rolls)
Creates a new
RandomObjectTable with the provided number of rolls. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(TableEntry<T> entry) |
boolean |
add(T object,
double weight)
Adds the given object to the table with the given weight.
|
boolean |
addAll(Collection<? extends TableEntry<T>> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
containsAllObjects(Collection<?> c)
Gets if this table contains all of the given objects, the objects may
either be
TableEntry s or the objects contained within the
entries. |
boolean |
containsObject(Object obj)
Gets if this table contains the given object, the object may either be a
TableEntry or the object contained within. |
abstract List<T> |
get(Random rand)
Performs a number of rolls according to the number of rolls defined by
getRolls() and returns items from the table for each roll. |
List<TableEntry<T>> |
getEntries()
Gets the entries in the table.
|
VariableAmount |
getRolls()
Gets the number of times this table will roll while retrieving items.
|
boolean |
isEmpty() |
Iterator<TableEntry<T>> |
iterator() |
boolean |
remove(Object entry) |
boolean |
removeAll(Collection<?> c) |
boolean |
removeObject(Object object)
Removes the first instance of an entry in this table which is a
WeightedObject entry and contains the given object. |
boolean |
retainAll(Collection<?> c) |
void |
setRolls(int rolls)
Sets the number of times this table will roll while retrieving items.
|
void |
setRolls(VariableAmount rolls)
Sets the number of times this table will roll while retrieving items.
|
int |
size() |
Object[] |
toArray() |
<R> R[] |
toArray(R[] a) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
protected final List<TableEntry<T>> entries
public RandomObjectTable(int rolls)
RandomObjectTable
with the provided number of rolls.rolls
- the rollsgetRolls()
public RandomObjectTable(VariableAmount rolls)
RandomObjectTable
with the provided number of rolls.rolls
- the rollsgetRolls()
public VariableAmount getRolls()
public void setRolls(VariableAmount rolls)
rolls
- The new roll countpublic void setRolls(int rolls)
rolls
- The new roll countpublic boolean add(TableEntry<T> entry)
add
in interface Collection<TableEntry<T>>
public boolean add(T object, double weight)
object
- The new objectweight
- The weight of the objectpublic boolean addAll(Collection<? extends TableEntry<T>> c)
addAll
in interface Collection<TableEntry<T>>
public boolean contains(Object o)
contains
in interface Collection<TableEntry<T>>
public boolean containsObject(Object obj)
TableEntry
or the object contained within.obj
- The object to check forpublic boolean containsAll(Collection<?> c)
containsAll
in interface Collection<TableEntry<T>>
public boolean containsAllObjects(Collection<?> c)
TableEntry
s or the objects contained within the
entries.c
- The objects to check forpublic boolean isEmpty()
isEmpty
in interface Collection<TableEntry<T>>
public boolean remove(Object entry)
remove
in interface Collection<TableEntry<T>>
public boolean removeObject(Object object)
WeightedObject
entry and contains the given object.object
- The object to removepublic boolean removeAll(Collection<?> c)
removeAll
in interface Collection<TableEntry<T>>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<TableEntry<T>>
public void clear()
clear
in interface Collection<TableEntry<T>>
public int size()
size
in interface Collection<TableEntry<T>>
public abstract List<T> get(Random rand)
getRolls()
and returns items from the table for each roll.rand
- The random object to usepublic List<TableEntry<T>> getEntries()
public Iterator<TableEntry<T>> iterator()
iterator
in interface Iterable<TableEntry<T>>
iterator
in interface Collection<TableEntry<T>>
public Object[] toArray()
toArray
in interface Collection<TableEntry<T>>
public <R> R[] toArray(R[] a)
toArray
in interface Collection<TableEntry<T>>