Class IndexedList<K,​V>

  • All Implemented Interfaces:
    Iterable<V>

    public class IndexedList<K,​V>
    extends Object
    implements Iterable<V>
    List which is indexed by a key in addition to its natural integer index

    Does not allow removal

    • Constructor Detail

      • IndexedList

        public IndexedList()
      • IndexedList

        public IndexedList​(int size)
    • Method Detail

      • add

        public void add​(K key,
                        V value)
      • getIndex

        public int getIndex​(K key)
        returns the index of the element with key or -1 if there is no such element
        Parameters:
        key -
        Returns:
        returns the index of the element with key or -1 if there is no such element
      • hasKey

        public boolean hasKey​(K key)
        Parameters:
        key -
        Returns:
        true if the list contains the key
      • get

        public V get​(K key)
        Returns the value mapped to the key or null if there is no such element
        Parameters:
        key -
        Returns:
      • get

        public V get​(int idx)
        Parameters:
        idx -
        Returns:
        See Also:
        List.get(int)
      • size

        public int size()
        Returns:
        returns the size of the list.
      • changeKey

        public void changeKey​(K oldKey,
                              K newKey)
      • getList

        public List<V> getList()
      • set

        public void set​(int idx,
                        V value)