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
ConstructorDescriptionUnmodifiableWeightedTable
(WeightedTable<T> table) Creates a newUnmodifiableWeightedTable
with the providedWeightedTable
.UnmodifiableWeightedTable
(WeightedTable<T> table, int rolls) UnmodifiableWeightedTable
(WeightedTable<T> table, VariableAmount rolls) -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(TableEntry<T> entry) boolean
Adds the given object to the table with the given weight.boolean
addAll
(Collection<? extends TableEntry<T>> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
containsAllObjects
(Collection<?> c) Gets if this table contains all of the given objects, the objects may either beTableEntry
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 aTableEntry
or the object contained within.List<TableEntry<T>>
entries()
Gets the entries in the table.boolean
void
forEach
(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.int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection<?> c) boolean
removeIf
(Predicate<? super TableEntry<T>> filter) boolean
removeObject
(Object entry) Removes the first instance of an entry in this table which is aWeightedObject
entry and contains the given object.boolean
retainAll
(Collection<?> c) rolls()
Gets the number of times this table will roll while retrieving items.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()
stream()
Object[]
toArray()
<R> R[]
toArray
(R[] a) toString()
Methods inherited from class org.spongepowered.api.util.weighted.WeightedTable
recalculateWeight
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
toArray
-
Constructor Details
-
UnmodifiableWeightedTable
Creates a newUnmodifiableWeightedTable
with 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:
add
in interfaceCollection<T>
- Overrides:
add
in classWeightedTable<T>
-
add
Description copied from class:RandomObjectTable
Adds the given object to the table with the given weight.- Overrides:
add
in classWeightedTable<T>
- Parameters:
object
- The new objectweight
- The weight of the object- Returns:
- If the object was successfully added
-
addAll
- Specified by:
addAll
in interfaceCollection<T>
- Overrides:
addAll
in classWeightedTable<T>
-
setRolls
Description copied from class:RandomObjectTable
Sets the number of times this table will roll while retrieving items.- Overrides:
setRolls
in classRandomObjectTable<T>
- Parameters:
rolls
- The new roll count
-
setRolls
public void setRolls(int rolls) Description copied from class:RandomObjectTable
Sets the number of times this table will roll while retrieving items.- Overrides:
setRolls
in classRandomObjectTable<T>
- Parameters:
rolls
- The new roll count
-
remove
- Specified by:
remove
in interfaceCollection<T>
- Overrides:
remove
in classWeightedTable<T>
-
removeObject
Description copied from class:RandomObjectTable
Removes the first instance of an entry in this table which is aWeightedObject
entry and contains the given object.- Overrides:
removeObject
in classWeightedTable<T>
- Parameters:
entry
- The object to remove- Returns:
- If the table was changed as a result
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T>
- Overrides:
removeAll
in classWeightedTable<T>
-
removeIf
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T>
- Overrides:
retainAll
in classWeightedTable<T>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<T>
- Overrides:
clear
in classWeightedTable<T>
-
iterator
- Specified by:
iterator
in interfaceCollection<T>
- Specified by:
iterator
in interfaceIterable<T>
- Overrides:
iterator
in classWeightedTable<T>
-
contains
- Specified by:
contains
in interfaceCollection<T>
- Overrides:
contains
in classRandomObjectTable<T>
-
rolls
Description copied from class:RandomObjectTable
Gets the number of times this table will roll while retrieving items. For each roll a complete pass through of the table will occur.- Overrides:
rolls
in classRandomObjectTable<T>
- Returns:
- The number of rolls
-
get
Description copied from class:RandomObjectTable
Performs a number of rolls according to the number of rolls defined byRandomObjectTable.rolls()
and returns items from the table for each roll.- Overrides:
get
in classWeightedTable<T>
- Parameters:
rand
- The random object to use- Returns:
- The returned items, may be empty but not null
-
containsObject
Description copied from class:RandomObjectTable
Gets if this table contains the given object, the object may either be aTableEntry
or the object contained within.- Overrides:
containsObject
in classRandomObjectTable<T>
- Parameters:
obj
- The object to check for- Returns:
- If the object is contained within the table
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Overrides:
containsAll
in classRandomObjectTable<T>
-
containsAllObjects
Description copied from class:RandomObjectTable
Gets if this table contains all of the given objects, the objects may either beTableEntry
s or the objects contained within the entries.- Overrides:
containsAllObjects
in 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:
isEmpty
in interfaceCollection<T>
- Overrides:
isEmpty
in classRandomObjectTable<T>
-
size
public int size()- Specified by:
size
in interfaceCollection<T>
- Overrides:
size
in classRandomObjectTable<T>
-
entries
Description copied from class:RandomObjectTable
Gets 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:
entries
in classRandomObjectTable<T>
- Returns:
- The raw entries
-
toArray
- Specified by:
toArray
in interfaceCollection<T>
- Overrides:
toArray
in classRandomObjectTable<T>
-
toArray
public <R> R[] toArray(R[] a) - Specified by:
toArray
in interfaceCollection<T>
- Overrides:
toArray
in classRandomObjectTable<T>
-
spliterator
-
stream
-
parallelStream
-
forEach
-
toString
- Overrides:
toString
in classWeightedTable<T>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<T>
- Overrides:
hashCode
in classWeightedTable<T>
-
equals
- Specified by:
equals
in interfaceCollection<T>
- Overrides:
equals
in classWeightedTable<T>
-