Interface DisposableMap<K,​V>

  • All Superinterfaces:
    java.util.Map<K,​V>

    public interface DisposableMap<K,​V>
    extends java.util.Map<K,​V>
    A special kind of Map backed by an EventList that is expected to live longer than this Map. It defines a dispose() method which should be called when the Map is no longer useful, but the underlying EventList is still referenced and useful. It allows this Map to be garbage collected before its source EventList.
    Author:
    James Lemieux
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void dispose()
      Releases the resources consumed by this DisposableMap so that it may eventually be garbage collected.
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
    • Method Detail

      • dispose

        void dispose()
        Releases the resources consumed by this DisposableMap so that it may eventually be garbage collected.

        A DisposableMap will be garbage collected without a call to dispose(), but not before its source EventList is garbage collected. By calling dispose(), you allow the DisposableMap to be garbage collected before its source EventList. This is necessary for situations where a DisposableMap is short-lived but its source EventList is long-lived.

        Warning: It is an error to call any method on a DisposableMap after it has been disposed.