Package com.globalmentor.collections
Class TreeSetMap<K,V>
- java.lang.Object
-
- com.globalmentor.collections.MapDecorator<K,C>
-
- com.globalmentor.collections.AbstractDecoratorCollectionMap<K,V,java.util.Set<V>>
-
- com.globalmentor.collections.TreeSetMap<K,V>
-
- Type Parameters:
K
- The type of map key.V
- The type of map value.
- All Implemented Interfaces:
CollectionMap<K,V,java.util.Set<V>>
,java.util.Map<K,java.util.Set<V>>
public class TreeSetMap<K,V> extends AbstractDecoratorCollectionMap<K,V,java.util.Set<V>>
An decorator map that stores aTreeSet
of values for each key, with special methods for retrieving single values.- Author:
- Garret Wilson
-
-
Field Summary
-
Fields inherited from class com.globalmentor.collections.MapDecorator
map
-
-
Constructor Summary
Constructors Constructor Description TreeSetMap(java.util.Map<K,java.util.Set<V>> map)
Map constructor with a natural ordering of set values.TreeSetMap(java.util.Map<K,java.util.Set<V>> map, java.util.Comparator<? super V> comparator)
Map and comparator constructor that sorts set values in the order specified by the comparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<V>
createCollection()
Creates a collection in which to store values.java.util.Comparator<? super V>
getComparator()
-
Methods inherited from class com.globalmentor.collections.AbstractDecoratorCollectionMap
addItem, getCollection, getItem, getItemCount, getItems, hasItems, removeItem
-
Methods inherited from class com.globalmentor.collections.MapDecorator
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Constructor Detail
-
TreeSetMap
public TreeSetMap(java.util.Map<K,java.util.Set<V>> map)
Map constructor with a natural ordering of set values.- Parameters:
map
- The map this map should decorate.- Throws:
java.lang.NullPointerException
- if the provided map isnull
.
-
TreeSetMap
public TreeSetMap(java.util.Map<K,java.util.Set<V>> map, java.util.Comparator<? super V> comparator)
Map and comparator constructor that sorts set values in the order specified by the comparator.- Parameters:
map
- The map this map should decorate.comparator
- The comparator that will be used to order the values in the set, ornull
if natural ordering should be used.- Throws:
java.lang.NullPointerException
- if the provided map isnull
.
-
-
Method Detail
-
getComparator
public java.util.Comparator<? super V> getComparator()
- Returns:
- The comparator that will be used to order the values in the set, or
null
if natural ordering should be used.
-
createCollection
public java.util.Set<V> createCollection()
Creates a collection in which to store values. This version returns aTreeSet
.- Returns:
- The collections with the values stored.
-
-