Interface IdMap<Key>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int INVALID_ID  
    • Method Summary

      Modifier and Type Method Description
      int getId​(Key key)
      Returns the id associated with the specified key.
      Key getKey​(int id)
      Returns the key associated with the specified id.
      int put​(Key key)
      Puts the specified key into the map.
      int size()
      Returns the current size of the map, zero if the map is empty.
    • Method Detail

      • put

        int put​(Key key)
        Puts the specified key into the map. The id for the key is auto-generated as follows:
          If key does not exist in the map, it is inserted into the map with a new id which is equal to number of elements in the map before the key is inserted. For example, the first key inserted will have id of 0, second will have an id of 1, and so on.
          If key already exists in the map, then it keeps its original id.
        Parameters:
        key - Key to be inserted into the map.
        Returns:
        Returns the id for the key.
      • getId

        int getId​(Key key)
        Returns the id associated with the specified key.
          Returns the id of the key if it exists.
          Returns INVALID_ID if the key does not exist in the map.
        Parameters:
        key - Key to get.
        Returns:
        Id of the key.
      • getKey

        Key getKey​(int id)
        Returns the key associated with the specified id.
          Returns the id of the key if it exists.
          Returns null if the key does not exist in the map.
        Parameters:
        id - id for which to get the key.
        Returns:
        Key for the id.
      • size

        int size()
        Returns the current size of the map, zero if the map is empty.
        Returns:
        Size of the map.