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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the entry (keyFunc.apply(e), e)booleanaddAll(Collection<? extends V> c) Iteratively callsadd(Object).voidclear()booleanChecks the entry (keyFunc.apply(e), e)booleancontainsAll(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.booleanisEmpty()iterator()Refers togetBase().Map.values()(the map's values).booleanRemoves the entry (keyFunc.apply(e), e)booleanremoveAll(Collection<?> c) Iteratively callsremove(Object).booleanretainAll(Collection<?> c) intsize()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, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
MapCollection
- See Also:
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection<K>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<K>
-
contains
Checks the entry (keyFunc.apply(e), e)- Specified by:
containsin interfaceCollection<K>
-
iterator
Refers togetBase().Map.values()(the map's values). -
toArray
Refers togetBase().Map.values()(the map's values).- Specified by:
toArrayin interfaceCollection<K>
-
toArray
public <T> T[] toArray(T[] a) Refers togetBase().Map.values()(the map's values).- Specified by:
toArrayin interfaceCollection<K>
-
add
Adds the entry (keyFunc.apply(e), e)- Specified by:
addin interfaceCollection<K>
-
remove
Removes the entry (keyFunc.apply(e), e)- Specified by:
removein interfaceCollection<K>
-
containsAll
Iteratively callscontains(Object).- Specified by:
containsAllin interfaceCollection<K>
-
addAll
Iteratively callsadd(Object).- Specified by:
addAllin interfaceCollection<K>
-
removeAll
Iteratively callsremove(Object).- Specified by:
removeAllin interfaceCollection<K>
-
retainAll
- Specified by:
retainAllin interfaceCollection<K>
-
clear
public void clear()- Specified by:
clearin 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.
-