Class AlignmentTools.IdentityMap<K>

  • Type Parameters:
    K -
    All Implemented Interfaces:
    java.util.Map<K,​K>
    Enclosing class:
    AlignmentTools

    public static class AlignmentTools.IdentityMap<K>
    extends java.util.AbstractMap<K,​K>
    A Map can be viewed as a function from K to V. This class represents the identity function. Getting a value results in the value itself.

    The class is a bit inconsistent when representing its contents. On the one hand, containsKey(key) is true for all objects. However, attempting to iterate through the values returns an empty set.

    Author:
    Spencer Bliven
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

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

      Constructors 
      Constructor Description
      IdentityMap()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(java.lang.Object key)  
      java.util.Set<java.util.Map.Entry<K,​K>> entrySet()
      Always returns the empty set
      K get​(java.lang.Object key)  
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • IdentityMap

        public IdentityMap()
    • Method Detail

      • get

        public K get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​K>
        Overrides:
        get in class java.util.AbstractMap<K,​K>
        Parameters:
        key -
        Returns:
        the key
        Throws:
        java.lang.ClassCastException - if key is not of type K
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​K>> entrySet()
        Always returns the empty set
        Specified by:
        entrySet in interface java.util.Map<K,​K>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​K>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​K>
        Overrides:
        containsKey in class java.util.AbstractMap<K,​K>