Class SharedKeysMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
org.jhotdraw8.fxcollection.sharedkeys.SharedKeysMap<K,V>
Type Parameters:
K - key type
V - value type
All Implemented Interfaces:
Map<K,V>, javafx.beans.Observable, javafx.collections.ObservableMap<K,V>

public class SharedKeysMap<K,V> extends AbstractMap<K,V> implements javafx.collections.ObservableMap<K,V>
An observable map which stores its values in an array, and which shares its immutable keys with other SharedKeysMap instances.
Author:
Werner Randelshofer
  • Constructor Details

    • SharedKeysMap

      public SharedKeysMap(Map<K,Integer> keyMap)
      Creates a new instance.
      Parameters:
      keyMap - a map which maps from keys to indices. The indices must be in the range [0,keyMap.size()-1].

      This map must be immutable.

  • Method Details

    • addListener

      public void addListener(javafx.beans.InvalidationListener listener)
      Specified by:
      addListener in interface javafx.beans.Observable
    • addListener

      public void addListener(javafx.collections.MapChangeListener<? super K,? super V> observer)
      Specified by:
      addListener in interface javafx.collections.ObservableMap<K,V>
    • callObservers

      protected void callObservers(javafx.collections.MapChangeListener.Change<K,V> change)
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
      Overrides:
      clear in class AbstractMap<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
      Overrides:
      containsKey in class AbstractMap<K,V>
    • containsValue

      public boolean containsValue(@Nullable Object value)
      Specified by:
      containsValue in interface Map<K,V>
      Overrides:
      containsValue in class AbstractMap<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
      Specified by:
      entrySet in class AbstractMap<K,V>
    • get

      public @Nullable V get(Object key)
      Specified by:
      get in interface Map<K,V>
      Overrides:
      get in class AbstractMap<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
      Overrides:
      isEmpty in class AbstractMap<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
      Overrides:
      keySet in class AbstractMap<K,V>
    • put

      public @Nullable V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
      Overrides:
      put in class AbstractMap<K,V>
    • remove

      public @Nullable V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
      Overrides:
      remove in class AbstractMap<K,V>
    • removeListener

      public void removeListener(javafx.beans.InvalidationListener listener)
      Specified by:
      removeListener in interface javafx.beans.Observable
    • removeListener

      public void removeListener(javafx.collections.MapChangeListener<? super K,? super V> observer)
      Specified by:
      removeListener in interface javafx.collections.ObservableMap<K,V>
    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
      Overrides:
      size in class AbstractMap<K,V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
      Overrides:
      values in class AbstractMap<K,V>