Class UnmodifiableWeightedTable<T>

  • Type Parameters:
    T - Item type
    All Implemented Interfaces:
    java.lang.Iterable<TableEntry<T>>, java.util.Collection<TableEntry<T>>

    public class UnmodifiableWeightedTable<T>
    extends WeightedTable<T>
    Creates a WeightedTable that is completely immutable, but still is able to be changed via its proxy table.
    • Method Detail

      • add

        public boolean add​(TableEntry<T> entry)
        Specified by:
        add in interface java.util.Collection<T>
        Overrides:
        add in class WeightedTable<T>
      • add

        public boolean add​(T object,
                           double weight)
        Description copied from class: RandomObjectTable
        Adds the given object to the table with the given weight.
        Overrides:
        add in class WeightedTable<T>
        Parameters:
        object - The new object
        weight - The weight of the object
        Returns:
        If the object was successfully added
      • addAll

        public boolean addAll​(java.util.Collection<? extends TableEntry<T>> c)
        Specified by:
        addAll in interface java.util.Collection<T>
        Overrides:
        addAll in class WeightedTable<T>
      • 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 class RandomObjectTable<T>
        Parameters:
        rolls - The new roll count
      • remove

        public boolean remove​(java.lang.Object entry)
        Specified by:
        remove in interface java.util.Collection<T>
        Overrides:
        remove in class WeightedTable<T>
      • removeObject

        public boolean removeObject​(java.lang.Object entry)
        Description copied from class: RandomObjectTable
        Removes the first instance of an entry in this table which is a WeightedObject entry and contains the given object.
        Overrides:
        removeObject in class WeightedTable<T>
        Parameters:
        entry - The object to remove
        Returns:
        If the table was changed as a result
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<T>
        Overrides:
        removeAll in class WeightedTable<T>
      • removeIf

        public boolean removeIf​(java.util.function.Predicate<? super TableEntry<T>> filter)
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<T>
        Overrides:
        retainAll in class WeightedTable<T>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<T>
        Overrides:
        clear in class WeightedTable<T>
      • iterator

        public java.util.Iterator<TableEntry<T>> iterator()
        Specified by:
        iterator in interface java.util.Collection<T>
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Overrides:
        iterator in class WeightedTable<T>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<T>
        Overrides:
        contains in class RandomObjectTable<T>
      • rolls

        public VariableAmount 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 class RandomObjectTable<T>
        Returns:
        The number of rolls
      • get

        public java.util.List<T> get​(java.util.Random rand)
        Description copied from class: RandomObjectTable
        Performs a number of rolls according to the number of rolls defined by RandomObjectTable.rolls() and returns items from the table for each roll.
        Overrides:
        get in class WeightedTable<T>
        Parameters:
        rand - The random object to use
        Returns:
        The returned items, may be empty but not null
      • containsObject

        public boolean containsObject​(java.lang.Object obj)
        Description copied from class: RandomObjectTable
        Gets if this table contains the given object, the object may either be a TableEntry or the object contained within.
        Overrides:
        containsObject in class RandomObjectTable<T>
        Parameters:
        obj - The object to check for
        Returns:
        If the object is contained within the table
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<T>
        Overrides:
        containsAll in class RandomObjectTable<T>
      • containsAllObjects

        public boolean containsAllObjects​(java.util.Collection<?> c)
        Description copied from class: RandomObjectTable
        Gets if this table contains all of the given objects, the objects may either be TableEntrys or the objects contained within the entries.
        Overrides:
        containsAllObjects in class RandomObjectTable<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 interface java.util.Collection<T>
        Overrides:
        isEmpty in class RandomObjectTable<T>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<T>
        Overrides:
        size in class RandomObjectTable<T>
      • entries

        public java.util.List<TableEntry<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 class RandomObjectTable<T>
        Returns:
        The raw entries
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<T>
        Overrides:
        toArray in class RandomObjectTable<T>
      • toArray

        public <R> R[] toArray​(R[] a)
        Specified by:
        toArray in interface java.util.Collection<T>
        Overrides:
        toArray in class RandomObjectTable<T>
      • spliterator

        public java.util.Spliterator<TableEntry<T>> spliterator()
      • stream

        public java.util.stream.Stream<TableEntry<T>> stream()
      • parallelStream

        public java.util.stream.Stream<TableEntry<T>> parallelStream()
      • forEach

        public void forEach​(java.util.function.Consumer<? super TableEntry<T>> action)
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<T>
        Overrides:
        hashCode in class WeightedTable<T>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<T>
        Overrides:
        equals in class WeightedTable<T>