Class UnmodifiableWeightedTable<T>
java.lang.Object
org.spongepowered.api.util.weighted.RandomObjectTable<T>
org.spongepowered.api.util.weighted.WeightedTable<T>
org.spongepowered.api.util.weighted.UnmodifiableWeightedTable<T>
- Type Parameters:
T- Item type
- All Implemented Interfaces:
Iterable<TableEntry<T>>,Collection<TableEntry<T>>
Creates a WeightedTable that is completely immutable, but still is able
to be changed via its proxy table.
-
Field Summary
Fields inherited from class org.spongepowered.api.util.weighted.RandomObjectTable
entries -
Constructor Summary
ConstructorsConstructorDescriptionUnmodifiableWeightedTable(WeightedTable<T> table) Creates a newUnmodifiableWeightedTablewith the providedWeightedTable.UnmodifiableWeightedTable(WeightedTable<T> table, int rolls) UnmodifiableWeightedTable(WeightedTable<T> table, VariableAmount rolls) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(TableEntry<T> entry) booleanAdds the given object to the table with the given weight.booleanaddAll(Collection<? extends TableEntry<T>> c) voidclear()booleanbooleancontainsAll(Collection<?> c) booleancontainsAllObjects(Collection<?> c) Gets if this table contains all of the given objects, the objects may either beTableEntrys or the objects contained within the entries.booleancontainsObject(Object obj) Gets if this table contains the given object, the object may either be aTableEntryor the object contained within.List<TableEntry<T>> entries()Gets the entries in the table.booleanvoidforEach(Consumer<? super TableEntry<T>> action) get(RandomGenerator rand) Performs a number of rolls according to the number of rolls defined byRandomObjectTable.rolls()and returns items from the table for each roll.inthashCode()booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> c) booleanremoveIf(Predicate<? super TableEntry<T>> filter) booleanremoveObject(Object entry) Removes the first instance of an entry in this table which is aWeightedObjectentry and contains the given object.booleanretainAll(Collection<?> c) rolls()Gets the number of times this table will roll while retrieving items.voidsetRolls(int rolls) Sets the number of times this table will roll while retrieving items.voidsetRolls(VariableAmount rolls) Sets the number of times this table will roll while retrieving items.intsize()stream()Object[]toArray()<R> R[]toArray(R[] a) toString()Methods inherited from class org.spongepowered.api.util.weighted.WeightedTable
recalculateWeightMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
toArray
-
Constructor Details
-
UnmodifiableWeightedTable
Creates a newUnmodifiableWeightedTablewith the providedWeightedTable.- Parameters:
table- The table to provide
-
UnmodifiableWeightedTable
- Parameters:
table- The tablerolls- The rolls
-
UnmodifiableWeightedTable
- Parameters:
table- The tablerolls- The rolls
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection<T>- Overrides:
addin classWeightedTable<T>
-
add
Description copied from class:RandomObjectTableAdds the given object to the table with the given weight.- Overrides:
addin classWeightedTable<T>- Parameters:
object- The new objectweight- The weight of the object- Returns:
- If the object was successfully added
-
addAll
- Specified by:
addAllin interfaceCollection<T>- Overrides:
addAllin classWeightedTable<T>
-
setRolls
Description copied from class:RandomObjectTableSets the number of times this table will roll while retrieving items.- Overrides:
setRollsin classRandomObjectTable<T>- Parameters:
rolls- The new roll count
-
setRolls
public void setRolls(int rolls) Description copied from class:RandomObjectTableSets the number of times this table will roll while retrieving items.- Overrides:
setRollsin classRandomObjectTable<T>- Parameters:
rolls- The new roll count
-
remove
- Specified by:
removein interfaceCollection<T>- Overrides:
removein classWeightedTable<T>
-
removeObject
Description copied from class:RandomObjectTableRemoves the first instance of an entry in this table which is aWeightedObjectentry and contains the given object.- Overrides:
removeObjectin classWeightedTable<T>- Parameters:
entry- The object to remove- Returns:
- If the table was changed as a result
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Overrides:
removeAllin classWeightedTable<T>
-
removeIf
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>- Overrides:
retainAllin classWeightedTable<T>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>- Overrides:
clearin classWeightedTable<T>
-
iterator
- Specified by:
iteratorin interfaceCollection<T>- Specified by:
iteratorin interfaceIterable<T>- Overrides:
iteratorin classWeightedTable<T>
-
contains
- Specified by:
containsin interfaceCollection<T>- Overrides:
containsin classRandomObjectTable<T>
-
rolls
Description copied from class:RandomObjectTableGets the number of times this table will roll while retrieving items. For each roll a complete pass through of the table will occur.- Overrides:
rollsin classRandomObjectTable<T>- Returns:
- The number of rolls
-
get
Description copied from class:RandomObjectTablePerforms a number of rolls according to the number of rolls defined byRandomObjectTable.rolls()and returns items from the table for each roll.- Overrides:
getin classWeightedTable<T>- Parameters:
rand- The random object to use- Returns:
- The returned items, may be empty but not null
-
containsObject
Description copied from class:RandomObjectTableGets if this table contains the given object, the object may either be aTableEntryor the object contained within.- Overrides:
containsObjectin classRandomObjectTable<T>- Parameters:
obj- The object to check for- Returns:
- If the object is contained within the table
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Overrides:
containsAllin classRandomObjectTable<T>
-
containsAllObjects
Description copied from class:RandomObjectTableGets if this table contains all of the given objects, the objects may either beTableEntrys or the objects contained within the entries.- Overrides:
containsAllObjectsin classRandomObjectTable<T>- Parameters:
c- The objects to check for- Returns:
- If all of the objects are contained within the table
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>- Overrides:
isEmptyin classRandomObjectTable<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Overrides:
sizein classRandomObjectTable<T>
-
entries
Description copied from class:RandomObjectTableGets the entries in the table. Note that the specific sub class of this abstract table will determine the context that the entry weights should be interpreted in (either weights or chances).- Overrides:
entriesin classRandomObjectTable<T>- Returns:
- The raw entries
-
toArray
- Specified by:
toArrayin interfaceCollection<T>- Overrides:
toArrayin classRandomObjectTable<T>
-
toArray
public <R> R[] toArray(R[] a) - Specified by:
toArrayin interfaceCollection<T>- Overrides:
toArrayin classRandomObjectTable<T>
-
spliterator
-
stream
-
parallelStream
-
forEach
-
toString
- Overrides:
toStringin classWeightedTable<T>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<T>- Overrides:
hashCodein classWeightedTable<T>
-
equals
- Specified by:
equalsin interfaceCollection<T>- Overrides:
equalsin classWeightedTable<T>
-