Class BiMap<L,R>

java.lang.Object
io.github.kosmx.emotes.common.tools.BiMap<L,R>
Type Parameters:
L -
R -
All Implemented Interfaces:
Iterable<it.unimi.dsi.fastutil.Pair<L,R>>, Collection<it.unimi.dsi.fastutil.Pair<L,R>>

public class BiMap<L,R> extends Object implements Collection<it.unimi.dsi.fastutil.Pair<L,R>>
Bi-directional hash-map. Both L and R has to implement Object.hashCode() and Object.equals(Object) functions it can not be checked automatically, but DON'T forget it
  • Constructor Details

    • BiMap

      public BiMap()
  • Method Details

    • getR

      public R getR(L key)
    • getL

      public L getL(R key)
    • containsL

      public boolean containsL(L l)
    • containsR

      public boolean containsR(R r)
    • put

      public it.unimi.dsi.fastutil.Pair<L,R> put(L l, R r)
    • add

      public boolean add(it.unimi.dsi.fastutil.Pair<L,R> pair)
      Only put the item into it, if it's not already there. see Collection.add(Object)
      Specified by:
      add in interface Collection<L>
      Parameters:
      pair - pair of elements
      Returns:
      true if the map changed.
    • removeL

      public R removeL(L l)
      Remove pair from L key
      Parameters:
      l - key
      Returns:
      the removed R
    • removeR

      public L removeR(R r)
      Remove pair from R key
      Parameters:
      r - key
      Returns:
      the removed L
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<L>
    • containsAll

      public boolean containsAll(@NotNull @NotNull Collection<?> c)
      Specified by:
      containsAll in interface Collection<L>
    • addAll

      public boolean addAll(Collection<? extends it.unimi.dsi.fastutil.Pair<L,R>> c)
      Specified by:
      addAll in interface Collection<L>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<L>
    • retainAll

      public boolean retainAll(@NotNull @NotNull Collection<?> c)
      Retains only the elements in this collection that are contained in the specified collection. Code copied from standard lib but runs with my iterator...
      Specified by:
      retainAll in interface Collection<L>
      Parameters:
      c - collection
      Returns:
      was the map modified
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<L>
    • size

      public int size()
      Specified by:
      size in interface Collection<L>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<L>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<L>
    • iterator

      public Iterator<it.unimi.dsi.fastutil.Pair<L,R>> iterator()
      Specified by:
      iterator in interface Collection<L>
      Specified by:
      iterator in interface Iterable<L>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<L>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<L>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<L>
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<L>
      Overrides:
      equals in class Object