3 * Copyright (C) 2009 Didier Villevalois
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
24 * Left-leaning red-black tree implementation of the {@link MultiMap}
27 public class Gee.TreeMultiMap<K,V> : AbstractMultiMap<K,V> {
28 public CompareDataFunc<K> key_compare_func {
29 get { return ((TreeMap<K, Set<V>>) _storage_map).key_compare_func; }
32 [CCode (notify = false)]
33 public CompareDataFunc<V> value_compare_func { private set; get; }
36 * Constructs a new, empty tree multimap.
38 * If not provided, the functions parameters are requested to the
39 * {@link Functions} function factory methods.
41 * @param key_compare_func an optional key comparator function
42 * @param value_compare_func an optional value comparator function
44 public TreeMultiMap (owned CompareDataFunc<K>? key_compare_func = null, owned CompareDataFunc<V>? value_compare_func = null) {
45 base (new TreeMap<K, Set<V>> (key_compare_func, Functions.get_equal_func_for (typeof (Set))));
46 if (value_compare_func == null) {
47 value_compare_func = Functions.get_compare_func_for (typeof (V));
49 this.value_compare_func = value_compare_func;
52 protected override Collection<V> create_value_storage () {
53 return new TreeSet<V> (_value_compare_func);
56 protected override MultiSet<K> create_multi_key_set () {
57 return new TreeMultiSet<K> (key_compare_func);
60 protected override EqualDataFunc<V> get_value_equal_func () {
61 return Functions.get_equal_func_for (typeof (V));