Class DefaultKeyValueList<K,V>

java.lang.Object
net.thevpc.common.collections.DefaultKeyValueList<K,V>
All Implemented Interfaces:
Iterable<V>, Collection<V>, List<V>, SequencedCollection<V>, Collection2, KeyValueList<K,V>

public class DefaultKeyValueList<K,V> extends Object implements KeyValueList<K,V>
Created by vpc on 6/1/16.
  • Constructor Details

    • DefaultKeyValueList

      public DefaultKeyValueList(Function<V,K> converter)
    • DefaultKeyValueList

      public DefaultKeyValueList(List<V> list, Function<V,K> keyResolver)
  • Method Details

    • add

      public boolean add(V v)
      Specified by:
      add in interface Collection<K>
      Specified by:
      add in interface List<K>
    • size

      public int size()
      Specified by:
      size in interface Collection<K>
      Specified by:
      size in interface List<K>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<K>
      Specified by:
      isEmpty in interface List<K>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<K>
      Specified by:
      contains in interface List<K>
    • iterator

      public Iterator<V> iterator()
      Specified by:
      iterator in interface Collection<K>
      Specified by:
      iterator in interface Iterable<K>
      Specified by:
      iterator in interface List<K>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<K>
      Specified by:
      toArray in interface List<K>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<K>
      Specified by:
      toArray in interface List<K>
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<K>
      Specified by:
      remove in interface List<K>
    • removeByKey

      public V removeByKey(K k)
      Specified by:
      removeByKey in interface KeyValueList<K,V>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<K>
      Specified by:
      containsAll in interface List<K>
    • addAll

      public boolean addAll(Collection<? extends V> c)
      Specified by:
      addAll in interface Collection<K>
      Specified by:
      addAll in interface List<K>
    • addAll

      public boolean addAll(int index, Collection<? extends V> c)
      Specified by:
      addAll in interface List<K>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<K>
      Specified by:
      removeAll in interface List<K>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<K>
      Specified by:
      retainAll in interface List<K>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<K>
      Specified by:
      clear in interface List<K>
    • get

      public V get(int index)
      Specified by:
      get in interface List<K>
    • getByKey

      public V getByKey(K k)
      Specified by:
      getByKey in interface KeyValueList<K,V>
    • get

      public V get(K k)
    • set

      public V set(int index, V element)
      Specified by:
      set in interface List<K>
    • add

      public void add(int index, V element)
      Specified by:
      add in interface List<K>
    • remove

      public V remove(int index)
      Specified by:
      remove in interface List<K>
    • indexOf

      public int indexOf(Object o)
      Specified by:
      indexOf in interface List<K>
    • lastIndexOf

      public int lastIndexOf(Object o)
      Specified by:
      lastIndexOf in interface List<K>
    • listIterator

      public ListIterator<V> listIterator()
      Specified by:
      listIterator in interface List<K>
    • listIterator

      public ListIterator<V> listIterator(int index)
      Specified by:
      listIterator in interface List<K>
    • subList

      public List<V> subList(int fromIndex, int toIndex)
      Specified by:
      subList in interface List<K>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface KeyValueList<K,V>
    • containsMappedValue

      public boolean containsMappedValue(V object)
      Description copied from interface: KeyValueList
      Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==null ? v==null : value.equals(v)). This operation will probably require time linear in the map size for most implementations of the Map interface.
      Specified by:
      containsMappedValue in interface KeyValueList<K,V>
      Parameters:
      object - value whose presence in this map is to be tested
      Returns:
      true if this map maps one or more keys to the specified value
    • getByValue

      public V getByValue(V object)
      Description copied from interface: KeyValueList
      returns, it it exists, the value in this list with the same key for value param
      Specified by:
      getByValue in interface KeyValueList<K,V>
      Parameters:
      object - value whose key presence in this map is to be tested
      Returns:
      value of the list equivalent to the given value
    • containsValue

      public boolean containsValue(Object value)
      Description copied from interface: KeyValueList
      Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).
      Specified by:
      containsValue in interface KeyValueList<K,V>
      Parameters:
      value - element whose presence in this list is to be tested
      Returns:
      true if this list contains the specified element
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface KeyValueList<K,V>