Package uk.ac.ebi.utils.collections
Class MapCollection<K,V>
java.lang.Object
uk.ac.ebi.utils.collections.MapCollection<K,V>
- All Implemented Interfaces:
Iterable<V>
,Collection<V>
Creates a view of a Map that is a collection. Does so by using a keyFunc
function
, which applies to map
values.
WARNING: Not fully tested yet!- Author:
- brandizi
- Date:
- 15 Oct 2015
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds the entry (keyFunc.apply(e)
, e)boolean
addAll
(Collection<? extends V> c) Iteratively callsadd(Object)
.void
clear()
boolean
Checks the entry (keyFunc.apply(e)
, e)boolean
containsAll
(Collection<?> c) Iteratively callscontains(Object)
.getBase()
The underlining map.The key function should return different values for different arguments and should always return the same value when an argument is presented multiple times.boolean
isEmpty()
iterator()
Refers togetBase()
.Map.values()
(the map's values).boolean
Removes the entry (keyFunc.apply(e)
, e)boolean
removeAll
(Collection<?> c) Iteratively callsremove(Object)
.boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
Refers togetBase()
.Map.values()
(the map's values).<T> T[]
toArray
(T[] a) Refers togetBase()
.Map.values()
(the map's values).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
MapCollection
- See Also:
-
#getKey()
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<K>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<K>
-
contains
Checks the entry (keyFunc.apply(e)
, e)- Specified by:
contains
in interfaceCollection<K>
-
iterator
Refers togetBase()
.Map.values()
(the map's values). -
toArray
Refers togetBase()
.Map.values()
(the map's values).- Specified by:
toArray
in interfaceCollection<K>
-
toArray
public <T> T[] toArray(T[] a) Refers togetBase()
.Map.values()
(the map's values).- Specified by:
toArray
in interfaceCollection<K>
-
add
Adds the entry (keyFunc.apply(e)
, e)- Specified by:
add
in interfaceCollection<K>
-
remove
Removes the entry (keyFunc.apply(e)
, e)- Specified by:
remove
in interfaceCollection<K>
-
containsAll
Iteratively callscontains(Object)
.- Specified by:
containsAll
in interfaceCollection<K>
-
addAll
Iteratively callsadd(Object)
.- Specified by:
addAll
in interfaceCollection<K>
-
removeAll
Iteratively callsremove(Object)
.- Specified by:
removeAll
in interfaceCollection<K>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<K>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<K>
-
getBase
The underlining map. -
getKeyFunction
The key function should return different values for different arguments and should always return the same value when an argument is presented multiple times.
-