[libgee] Move to non-static delegates
- From: Maciej Marcin Piechotka <mpiechotka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgee] Move to non-static delegates
- Date: Tue, 17 Aug 2010 09:31:09 +0000 (UTC)
commit 06e5dccc77bd8aa8d7826564d26620ec0de0910c
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date: Mon Sep 21 14:36:25 2009 +0200
Move to non-static delegates
benchmark/benchmarksorts.vala | 2 +-
benchmark/mergesort.vala | 8 +++---
gee/abstractlist.vala | 2 +-
gee/abstractmultimap.vala | 2 +-
gee/arraylist.vala | 16 +----------
gee/functions.vala | 51 ++++++++++++++-----------------------
gee/hashmap.vala | 8 +++---
gee/hashmultimap.vala | 16 ++++++------
gee/hashmultiset.vala | 6 ++--
gee/hashset.vala | 9 ++++--
gee/linkedlist.vala | 4 +-
gee/list.vala | 2 +-
gee/priorityqueue.vala | 4 +-
gee/readonlylist.vala | 2 +-
gee/timsort.vala | 31 +++--------------------
gee/treemap.vala | 6 ++--
gee/treemultimap.vala | 10 +++---
gee/treemultiset.vala | 4 +-
gee/treeset.vala | 6 ++--
tests/testarraylist.vala | 17 ------------
tests/testcomparable.vala | 2 +-
tests/testhashmap.vala | 37 ---------------------------
tests/testhashmultimap.vala | 6 ----
tests/testhashmultiset.vala | 4 ---
tests/testhashset.vala | 31 -----------------------
tests/testlinkedlist.vala | 25 ------------------
tests/testlinkedlistasdeque.vala | 3 --
tests/testmap.vala | 12 ++------
tests/testpriorityqueue.vala | 25 ------------------
tests/testtreemap.vala | 31 -----------------------
tests/testtreemultimap.vala | 12 ---------
tests/testtreemultiset.vala | 11 --------
tests/testtreeset.vala | 25 ------------------
33 files changed, 76 insertions(+), 354 deletions(-)
---
diff --git a/benchmark/benchmarksorts.vala b/benchmark/benchmarksorts.vala
index 6e384cf..28272ca 100644
--- a/benchmark/benchmarksorts.vala
+++ b/benchmark/benchmarksorts.vala
@@ -39,7 +39,7 @@ namespace Gee.Benchmark {
public string name { get { return "MergeSort"; } }
public void process_collection (Collection<G> collection) {
- CompareFunc compare = Functions.get_compare_func_for (typeof (G));
+ CompareDataFunc compare = Functions.get_compare_func_for (typeof (G));
Gee.MergeSort.sort<G> ((Gee.List<G>) collection, compare);
}
}
diff --git a/benchmark/mergesort.vala b/benchmark/mergesort.vala
index f20cc92..017ab85 100644
--- a/benchmark/mergesort.vala
+++ b/benchmark/mergesort.vala
@@ -22,7 +22,7 @@
internal class Gee.MergeSort<G> {
- public static void sort<G> (List<G> list, CompareFunc compare) {
+ public static void sort<G> (List<G> list, CompareDataFunc compare) {
if (list is ArrayList) {
MergeSort.sort_arraylist<G> ((ArrayList<G>) list, compare);
} else {
@@ -30,7 +30,7 @@ internal class Gee.MergeSort<G> {
}
}
- public static void sort_list<G> (List<G> list, CompareFunc compare) {
+ public static void sort_list<G> (List<G> list, CompareDataFunc compare) {
MergeSort<G> helper = new MergeSort<G> ();
helper.list_collection = list;
@@ -49,7 +49,7 @@ internal class Gee.MergeSort<G> {
}
}
- public static void sort_arraylist<G> (ArrayList<G> list, CompareFunc compare) {
+ public static void sort_arraylist<G> (ArrayList<G> list, CompareDataFunc compare) {
MergeSort<G> helper = new MergeSort<G> ();
helper.list_collection = list;
@@ -66,7 +66,7 @@ internal class Gee.MergeSort<G> {
private unowned G[] list;
private int index;
private int size;
- private CompareFunc compare;
+ private CompareDataFunc compare;
private void do_sort () {
if (this.size <= 1) {
diff --git a/gee/abstractlist.vala b/gee/abstractlist.vala
index 65c82b7..61915b6 100644
--- a/gee/abstractlist.vala
+++ b/gee/abstractlist.vala
@@ -93,7 +93,7 @@ public abstract class Gee.AbstractList<G> : Gee.AbstractCollection<G>, List<G> {
/**
* { inheritDoc}
*/
- public void sort (CompareFunc? compare = null) {
+ public void sort (owned CompareDataFunc? compare = null) {
if (compare == null) {
compare = Functions.get_compare_func_for (typeof (G));
}
diff --git a/gee/abstractmultimap.vala b/gee/abstractmultimap.vala
index 5d0d230..a7de1cc 100644
--- a/gee/abstractmultimap.vala
+++ b/gee/abstractmultimap.vala
@@ -45,7 +45,7 @@ public abstract class Gee.AbstractMultiMap<K,V> : Object, MultiMap<K,V> {
protected abstract MultiSet<K> create_multi_key_set ();
- protected abstract EqualFunc get_value_equal_func ();
+ protected abstract EqualDataFunc get_value_equal_func ();
public Set<K> get_keys () {
return _storage_map.keys;
diff --git a/gee/arraylist.vala b/gee/arraylist.vala
index 5c369b5..1aa32a6 100644
--- a/gee/arraylist.vala
+++ b/gee/arraylist.vala
@@ -48,7 +48,7 @@ public class Gee.ArrayList<G> : AbstractList<G> {
/**
* The elements' equality testing function.
*/
- public EqualFunc equal_func { private set; get; }
+ public EqualDataFunc equal_func { private set; get; }
internal G[] _items = new G[4];
internal int _size;
@@ -64,7 +64,7 @@ public class Gee.ArrayList<G> : AbstractList<G> {
*
* @param equal_func an optional element equality testing function
*/
- public ArrayList (EqualFunc? equal_func = null) {
+ public ArrayList (owned EqualDataFunc? equal_func = null) {
if (equal_func == null) {
equal_func = Functions.get_equal_func_for (typeof (G));
}
@@ -223,18 +223,6 @@ public class Gee.ArrayList<G> : AbstractList<G> {
return true;
}
- /**
- * Sorts items by comparing with the specified compare function.
- *
- * @deprecated This method has only been added as hack and will be
- * deprecated after the next odd minor version bump (>= 0.7.x).
- *
- * @param compare_func compare function to use to compare items
- */
- public void sort_with_data (CompareDataFunc compare) {
- TimSort.sort_with_data<G> (this, compare);
- }
-
private void shift (int start, int delta) {
assert (start >= 0);
assert (start <= _size);
diff --git a/gee/functions.vala b/gee/functions.vala
index b7ee46b..dc173ea 100644
--- a/gee/functions.vala
+++ b/gee/functions.vala
@@ -46,11 +46,11 @@ namespace Gee {
*
* @return the equality testing function corresponding to the given type.
*/
- public static EqualFunc get_equal_func_for (Type t) {
+ public static EqualDataFunc get_equal_func_for (Type t) {
if (t == typeof (string)) {
- return str_equal;
+ return (a, b) => {return str_equal ((string) a, (string) b);};
} else {
- return direct_equal;
+ return (a, b) => {return direct_equal (a, b);};
}
}
@@ -61,11 +61,11 @@ namespace Gee {
*
* @return the hash function corresponding to the given type.
*/
- public static HashFunc get_hash_func_for (Type t) {
+ public static HashDataFunc get_hash_func_for (Type t) {
if (t == typeof (string)) {
- return str_hash;
+ return (a) => {return str_hash ((string) a);};
} else {
- return direct_hash;
+ return (a) => {return direct_hash (a);};
}
}
@@ -76,36 +76,23 @@ namespace Gee {
*
* @return the comparator function corresponding to the given type.
*/
- public static CompareFunc get_compare_func_for (Type t) {
+ public static CompareDataFunc get_compare_func_for (Type t) {
if (t == typeof (string)) {
- return (CompareFunc) strcmp;
+ return (a, b) => {return strcmp((string) a, (string) b);};
} else if (t.is_a (typeof (Comparable))) {
- return (CompareFunc) Comparable.compare_to;
+ return (a, b) => {return ((Comparable<Comparable>) a).compare_to ((Comparable) b);};
} else {
- return (CompareFunc) direct_compare;
+ return (_val1, _val2) => {
+ long val1 = (long)_val1, val2 = (long)_val2;
+ if (val1 > val2) {
+ return 1;
+ } else if (val1 == val2) {
+ return 0;
+ } else {
+ return -1;
+ }
+ };
}
}
}
-
- /**
- * Compares two arbitrary elements together.
- *
- * The comparison is done on pointers and not on values behind.
- *
- * @param _val1 the first value to compare.
- * @param _val2 the second value to compare.
- *
- * @return a negative value if _val1 is lesser than _val2, a positive value
- * if _val1 is greater then _val2 and zero if both are equal.
- */
- public static int direct_compare (void* _val1, void* _val2) {
- long val1 = (long)_val1, val2 = (long)_val2;
- if (val1 > val2) {
- return 1;
- } else if (val1 == val2) {
- return 0;
- } else {
- return -1;
- }
- }
}
diff --git a/gee/hashmap.vala b/gee/hashmap.vala
index de4e990..496d7b1 100644
--- a/gee/hashmap.vala
+++ b/gee/hashmap.vala
@@ -89,17 +89,17 @@ public class Gee.HashMap<K,V> : Gee.AbstractMap<K,V> {
/**
* The keys' hash function.
*/
- public HashFunc key_hash_func { private set; get; }
+ public HashDataFunc<K> key_hash_func { private set; get; }
/**
* The keys' equality testing function.
*/
- public EqualFunc key_equal_func { private set; get; }
+ public EqualDataFunc<K> key_equal_func { private set; get; }
/**
* The values' equality testing function.
*/
- public EqualFunc value_equal_func { private set; get; }
+ public EqualDataFunc<V> value_equal_func { private set; get; }
private int _array_size;
private int _nnodes;
@@ -125,7 +125,7 @@ public class Gee.HashMap<K,V> : Gee.AbstractMap<K,V> {
* @param key_equal_func an optional key equality testing function
* @param value_equal_func an optional value equality testing function
*/
- public HashMap (HashFunc? key_hash_func = null, EqualFunc? key_equal_func = null, EqualFunc? value_equal_func = null) {
+ public HashMap (owned HashDataFunc? key_hash_func = null, owned EqualDataFunc? key_equal_func = null, owned EqualDataFunc? value_equal_func = null) {
if (key_hash_func == null) {
key_hash_func = Functions.get_hash_func_for (typeof (K));
}
diff --git a/gee/hashmultimap.vala b/gee/hashmultimap.vala
index 3a10220..2aded45 100644
--- a/gee/hashmultimap.vala
+++ b/gee/hashmultimap.vala
@@ -24,17 +24,17 @@
* Hash table implementation of the { link MultiMap} interface.
*/
public class Gee.HashMultiMap<K,V> : AbstractMultiMap<K,V> {
- public HashFunc key_hash_func {
+ public HashDataFunc<K> key_hash_func {
get { return ((HashMap<K, Set<V>>) _storage_map).key_hash_func; }
}
- public EqualFunc key_equal_func {
+ public EqualDataFunc<K> key_equal_func {
get { return ((HashMap<K, Set<V>>) _storage_map).key_equal_func; }
}
- public HashFunc value_hash_func { private set; get; }
+ public HashDataFunc<V> value_hash_func { private set; get; }
- public EqualFunc value_equal_func { private set; get; }
+ public EqualDataFunc<V> value_equal_func { private set; get; }
/**
* Constructs a new, empty hash multimap.
@@ -47,9 +47,9 @@ public class Gee.HashMultiMap<K,V> : AbstractMultiMap<K,V> {
* @param value_hash_func an optional value hash function
* @param value_equal_func an optional value equality testing function
*/
- public HashMultiMap (HashFunc? key_hash_func = null, EqualFunc? key_equal_func = null,
- HashFunc? value_hash_func = null, EqualFunc? value_equal_func = null) {
- base (new HashMap<K, Set<V>> (key_hash_func, key_equal_func, direct_equal));
+ public HashMultiMap (owned HashDataFunc? key_hash_func = null, owned EqualDataFunc? key_equal_func = null,
+ owned HashDataFunc? value_hash_func = null, owned EqualDataFunc? value_equal_func = null) {
+ base (new HashMap<K, Set<V>> (key_hash_func, key_equal_func, Functions.get_equal_func_for (typeof (Set<V>))));
if (value_hash_func == null) {
value_hash_func = Functions.get_hash_func_for (typeof (V));
}
@@ -68,7 +68,7 @@ public class Gee.HashMultiMap<K,V> : AbstractMultiMap<K,V> {
return new HashMultiSet<K> (key_hash_func, key_equal_func);
}
- protected override EqualFunc get_value_equal_func () {
+ protected override EqualDataFunc<V> get_value_equal_func () {
return _value_equal_func;
}
}
diff --git a/gee/hashmultiset.vala b/gee/hashmultiset.vala
index 596da77..76d7954 100644
--- a/gee/hashmultiset.vala
+++ b/gee/hashmultiset.vala
@@ -24,11 +24,11 @@
* Hash table implementation of the { link MultiSet} interface.
*/
public class Gee.HashMultiSet<G> : AbstractMultiSet<G> {
- public HashFunc hash_func {
+ public HashDataFunc hash_func {
get { return ((HashMap<G, int>) _storage_map).key_hash_func; }
}
- public EqualFunc equal_func {
+ public EqualDataFunc equal_func {
get { return ((HashMap<G, int>) _storage_map).key_equal_func; }
}
@@ -41,7 +41,7 @@ public class Gee.HashMultiSet<G> : AbstractMultiSet<G> {
* @param hash_func an optional element hash function
* @param equal_func an optional element equality testing function
*/
- public HashMultiSet (HashFunc? hash_func = null, EqualFunc? equal_func = null) {
+ public HashMultiSet (HashDataFunc? hash_func = null, EqualDataFunc? equal_func = null) {
base (new HashMap<G, int> (hash_func, equal_func));
}
}
diff --git a/gee/hashset.vala b/gee/hashset.vala
index 717e5e2..c2c0e04 100644
--- a/gee/hashset.vala
+++ b/gee/hashset.vala
@@ -24,6 +24,9 @@
using GLib;
+public delegate uint HashDataFunc (void* v);
+public delegate bool EqualDataFunc (void* a, void* b);
+
/**
* Hash table implementation of the { link Set} interface.
*
@@ -44,12 +47,12 @@ public class Gee.HashSet<G> : AbstractSet<G> {
/**
* The elements' hash function.
*/
- public HashFunc hash_func { private set; get; }
+ public HashDataFunc<G> hash_func { private set; get; }
/**
* The elements' equality testing function.
*/
- public EqualFunc equal_func { private set; get; }
+ public EqualDataFunc<G> equal_func { private set; get; }
private int _array_size;
private int _nnodes;
@@ -70,7 +73,7 @@ public class Gee.HashSet<G> : AbstractSet<G> {
* @param hash_func an optional hash function
* @param equal_func an optional equality testing function
*/
- public HashSet (HashFunc? hash_func = null, EqualFunc? equal_func = null) {
+ public HashSet (owned HashDataFunc? hash_func = null, owned EqualDataFunc? equal_func = null) {
if (hash_func == null) {
hash_func = Functions.get_hash_func_for (typeof (G));
}
diff --git a/gee/linkedlist.vala b/gee/linkedlist.vala
index 8fbf4c8..66e7082 100644
--- a/gee/linkedlist.vala
+++ b/gee/linkedlist.vala
@@ -41,7 +41,7 @@ public class Gee.LinkedList<G> : AbstractList<G>, Queue<G>, Deque<G> {
/**
* The elements' equality testing function.
*/
- public EqualFunc equal_func { private set; get; }
+ public EqualDataFunc equal_func { private set; get; }
/**
* Constructs a new, empty linked list.
@@ -51,7 +51,7 @@ public class Gee.LinkedList<G> : AbstractList<G>, Queue<G>, Deque<G> {
*
* @param equal_func an optional element equality testing function
*/
- public LinkedList (EqualFunc? equal_func = null) {
+ public LinkedList (owned EqualDataFunc? equal_func = null) {
if (equal_func == null) {
equal_func = Functions.get_equal_func_for (typeof (G));
}
diff --git a/gee/list.vala b/gee/list.vala
index d5193e3..0aa6502 100644
--- a/gee/list.vala
+++ b/gee/list.vala
@@ -111,7 +111,7 @@ public interface Gee.List<G> : Collection<G> {
*
* @param compare_func compare function to use to compare items
*/
- public abstract void sort (CompareFunc? compare_func = null);
+ public abstract void sort (owned CompareDataFunc? compare_func = null);
/**
* The read-only view of this list.
diff --git a/gee/priorityqueue.vala b/gee/priorityqueue.vala
index 74337a0..3b10f91 100644
--- a/gee/priorityqueue.vala
+++ b/gee/priorityqueue.vala
@@ -44,7 +44,7 @@ public class Gee.PriorityQueue<G> : Gee.AbstractQueue<G> {
/**
* The elements' comparator function.
*/
- public CompareFunc compare_func { private set; get; }
+ public CompareDataFunc<G> compare_func { private set; get; }
private int _size = 0;
private int _stamp = 0;
@@ -68,7 +68,7 @@ public class Gee.PriorityQueue<G> : Gee.AbstractQueue<G> {
*
* @param compare_func an optional element comparator function
*/
- public PriorityQueue (CompareFunc? compare_func = null) {
+ public PriorityQueue (owned CompareDataFunc? compare_func = null) {
if (compare_func == null) {
compare_func = Functions.get_compare_func_for (typeof (G));
}
diff --git a/gee/readonlylist.vala b/gee/readonlylist.vala
index 58d5e9a..ec140c4 100644
--- a/gee/readonlylist.vala
+++ b/gee/readonlylist.vala
@@ -116,7 +116,7 @@ internal class Gee.ReadOnlyList<G> : Gee.ReadOnlyCollection<G>, List<G> {
/**
* { inheritDoc}
*/
- public void sort (CompareFunc? compare = null) {
+ public void sort (owned CompareDataFunc? compare = null) {
assert_not_reached ();
}
diff --git a/gee/timsort.vala b/gee/timsort.vala
index cb79ced..1c1b00b 100644
--- a/gee/timsort.vala
+++ b/gee/timsort.vala
@@ -46,7 +46,7 @@
*/
internal class Gee.TimSort<G> : Object {
- public static void sort<G> (List<G> list, CompareFunc compare) {
+ public static void sort<G> (List<G> list, CompareDataFunc compare) {
if (list is ArrayList) {
TimSort.sort_arraylist<G> ((ArrayList<G>) list, compare);
} else {
@@ -54,17 +54,7 @@ internal class Gee.TimSort<G> : Object {
}
}
- public static void sort_with_data<G> (List<G> list, CompareDataFunc compare_data) {
- if (list is ArrayList) {
- TimSort.sort_arraylist<G> ((ArrayList<G>) list, null, compare_data);
- } else {
- TimSort.sort_list<G> (list, null, compare_data);
- }
- }
-
- private static void sort_list<G> (List<G> list, CompareFunc? compare, CompareDataFunc? compare_data = null) {
- assert (compare != null || compare_data != null);
-
+ private static void sort_list<G> (List<G> list, CompareDataFunc<G> compare) {
TimSort<G> helper = new TimSort<G> ();
helper.list_collection = list;
@@ -73,7 +63,6 @@ internal class Gee.TimSort<G> : Object {
helper.index = 0;
helper.size = list.size;
helper.compare = compare;
- helper.compare_data = compare_data;
helper.do_sort ();
@@ -84,9 +73,7 @@ internal class Gee.TimSort<G> : Object {
}
}
- private static void sort_arraylist<G> (ArrayList<G> list, CompareFunc? compare, CompareDataFunc? compare_data = null) {
- assert (compare != null || compare_data != null);
-
+ private static void sort_arraylist<G> (ArrayList<G> list, CompareDataFunc<G> compare) {
TimSort<G> helper = new TimSort<G> ();
helper.list_collection = list;
@@ -94,7 +81,6 @@ internal class Gee.TimSort<G> : Object {
helper.index = 0;
helper.size = list._size;
helper.compare = compare;
- helper.compare_data = compare_data;
helper.do_sort ();
}
@@ -108,8 +94,7 @@ internal class Gee.TimSort<G> : Object {
private int size;
private Slice<G>*[] pending;
private int minimum_gallop;
- private CompareFunc compare;
- private CompareDataFunc compare_data;
+ private CompareDataFunc<G> compare;
private void do_sort () {
if (size < 2) {
@@ -168,19 +153,11 @@ internal class Gee.TimSort<G> : Object {
private delegate bool LowerFunc (G left, G right);
private inline bool lower_than (G left, G right) {
- if (compare != null) {
return compare (left, right) < 0;
- } else {
- return compare_data (left, right) < 0;
- }
}
private inline bool lower_than_or_equal_to (G left, G right) {
- if (compare != null) {
return compare (left, right) <= 0;
- } else {
- return compare_data (left, right) <= 0;
- }
}
private int compute_minimum_run_length (int length) {
diff --git a/gee/treemap.vala b/gee/treemap.vala
index 8b3917e..d1bbd43 100644
--- a/gee/treemap.vala
+++ b/gee/treemap.vala
@@ -87,12 +87,12 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
/**
* The keys' comparator function.
*/
- public CompareFunc key_compare_func { private set; get; }
+ public CompareDataFunc key_compare_func { private set; get; }
/**
* The values' equality testing function.
*/
- public EqualFunc value_equal_func { private set; get; }
+ public EqualDataFunc value_equal_func { private set; get; }
private int _size = 0;
@@ -110,7 +110,7 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
* @param key_compare_func an optional key comparator function
* @param value_equal_func an optional values equality testing function
*/
- public TreeMap (CompareFunc? key_compare_func = null, EqualFunc? value_equal_func = null) {
+ public TreeMap (owned CompareDataFunc? key_compare_func = null, owned EqualDataFunc? value_equal_func = null) {
if (key_compare_func == null) {
key_compare_func = Functions.get_compare_func_for (typeof (K));
}
diff --git a/gee/treemultimap.vala b/gee/treemultimap.vala
index c26729e..9f83d4f 100644
--- a/gee/treemultimap.vala
+++ b/gee/treemultimap.vala
@@ -25,11 +25,11 @@
* interface.
*/
public class Gee.TreeMultiMap<K,V> : AbstractMultiMap<K,V> {
- public CompareFunc key_compare_func {
+ public CompareDataFunc key_compare_func {
get { return ((TreeMap<K, Set<V>>) _storage_map).key_compare_func; }
}
- public CompareFunc value_compare_func { private set; get; }
+ public CompareDataFunc value_compare_func { private set; get; }
/**
* Constructs a new, empty tree multimap.
@@ -40,8 +40,8 @@ public class Gee.TreeMultiMap<K,V> : AbstractMultiMap<K,V> {
* @param key_compare_func an optional key comparator function
* @param value_compare_func an optional value comparator function
*/
- public TreeMultiMap (CompareFunc? key_compare_func = null, CompareFunc? value_compare_func = null) {
- base (new TreeMap<K, Set<V>> (key_compare_func, direct_equal));
+ public TreeMultiMap (owned CompareDataFunc? key_compare_func = null, owned CompareDataFunc? value_compare_func = null) {
+ base (new TreeMap<K, Set<V>> (key_compare_func, Functions.get_equal_func_for (typeof (Set<V>))));
if (value_compare_func == null) {
value_compare_func = Functions.get_compare_func_for (typeof (V));
}
@@ -56,7 +56,7 @@ public class Gee.TreeMultiMap<K,V> : AbstractMultiMap<K,V> {
return new TreeMultiSet<K> (key_compare_func);
}
- protected override EqualFunc get_value_equal_func () {
+ protected override EqualDataFunc<V> get_value_equal_func () {
return Functions.get_equal_func_for (typeof (V));
}
}
diff --git a/gee/treemultiset.vala b/gee/treemultiset.vala
index 0471608..cf447da 100644
--- a/gee/treemultiset.vala
+++ b/gee/treemultiset.vala
@@ -25,7 +25,7 @@
* interface.
*/
public class Gee.TreeMultiSet<G> : AbstractMultiSet<G> {
- public CompareFunc compare_func {
+ public CompareDataFunc compare_func {
get { return ((TreeMap<G, int>) _storage_map).key_compare_func; }
}
@@ -37,7 +37,7 @@ public class Gee.TreeMultiSet<G> : AbstractMultiSet<G> {
*
* @param compare_func an optional element comparator function
*/
- public TreeMultiSet (CompareFunc? compare_func = null) {
+ public TreeMultiSet (owned CompareDataFunc? compare_func = null) {
base (new TreeMap<G, int> (compare_func));
}
}
diff --git a/gee/treeset.vala b/gee/treeset.vala
index 0f09ff9..38a2fd9 100644
--- a/gee/treeset.vala
+++ b/gee/treeset.vala
@@ -1,6 +1,6 @@
/* treeset.vala
*
- * Copyright (C) 2009 Maciej Piechotka
+ * Copyright (C) 2009-2010 Maciej Piechotka
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -43,7 +43,7 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
/**
* The elements' comparator function.
*/
- public CompareFunc compare_func { private set; get; }
+ public CompareDataFunc compare_func { private set; get; }
private int _size = 0;
@@ -56,7 +56,7 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
*
* @param compare_func an optional element comparator function
*/
- public TreeSet (CompareFunc? compare_func = null) {
+ public TreeSet (owned CompareDataFunc? compare_func = null) {
if (compare_func == null) {
compare_func = Functions.get_compare_func_for (typeof (G));
}
diff --git a/tests/testarraylist.vala b/tests/testarraylist.vala
index e5340c5..8964514 100644
--- a/tests/testarraylist.vala
+++ b/tests/testarraylist.vala
@@ -30,7 +30,6 @@ public class ArrayListTests : ListTests {
public ArrayListTests () {
base ("ArrayList");
add_test ("[ArrayList] selected functions", test_selected_functions);
- add_test ("[ArrayList] GObject properties", test_gobject_properties);
add_test ("[ArrayList] small sort (insertion)", test_small_sort);
add_test ("[ArrayList] big sort (timsort)", test_big_sort);
add_test ("[ArrayList] typed to_array calls", test_typed_to_array);
@@ -51,22 +50,6 @@ public class ArrayListTests : ListTests {
// Check the collection exists
assert (test_list != null);
-
- // Check the selected equal function
- assert (test_list.equal_func == str_equal);
- }
-
- public new void test_gobject_properties () {
- var test_list = test_collection as ArrayList<string>;
-
- // Check the list exists
- assert (test_list != null);
- Value value;
-
- value = Value (typeof (EqualFunc));
- test_list.get_property ("equal-func", ref value);
- assert (value.get_pointer () == (void*) test_list.equal_func);
- value.unset ();
}
private void test_small_sort () {
diff --git a/tests/testcomparable.vala b/tests/testcomparable.vala
index de5c2ef..dd5454f 100644
--- a/tests/testcomparable.vala
+++ b/tests/testcomparable.vala
@@ -45,7 +45,7 @@ public class ComparableTests : Gee.TestCase {
TestComparable o1 = new TestComparable (10);
TestComparable o2 = new TestComparable (20);
- CompareFunc compare = Functions.get_compare_func_for (typeof (TestComparable));
+ CompareDataFunc<TestComparable> compare = Functions.get_compare_func_for (typeof (TestComparable));
assert (compare (o1, o2) < 0);
o1._a = 42;
diff --git a/tests/testhashmap.vala b/tests/testhashmap.vala
index 6ea5582..ac4d989 100644
--- a/tests/testhashmap.vala
+++ b/tests/testhashmap.vala
@@ -27,8 +27,6 @@ public class HashMapTests : MapTests {
public HashMapTests () {
base ("HashMap");
- add_test ("[HashMap] selected functions", test_selected_functions);
- add_test ("[HashMap] GObject properties", test_gobject_properties);
}
public override void set_up () {
@@ -38,39 +36,4 @@ public class HashMapTests : MapTests {
public override void tear_down () {
test_map = null;
}
-
- public void test_selected_functions () {
- var test_hash_map = test_map as HashMap<string,string>;
-
- // Check the map exists
- assert (test_hash_map != null);
-
- // Check the selected hash and equal functions
- assert (test_hash_map.key_hash_func == str_hash);
- assert (test_hash_map.key_equal_func == str_equal);
- assert (test_hash_map.value_equal_func == str_equal);
- }
-
- public new void test_gobject_properties () {
- var test_hash_map = test_map as HashMap<string,string>;
-
- // Check the list exists
- assert (test_hash_map != null);
- Value value;
-
- value = Value (typeof (HashFunc));
- test_hash_map.get_property ("key-hash-func", ref value);
- assert (value.get_pointer () == (void*) test_hash_map.key_hash_func);
- value.unset ();
-
- value = Value (typeof (EqualFunc));
- test_hash_map.get_property ("key-equal-func", ref value);
- assert (value.get_pointer () == (void*) test_hash_map.key_equal_func);
- value.unset ();
-
- value = Value (typeof (EqualFunc));
- test_hash_map.get_property ("value-equal-func", ref value);
- assert (value.get_pointer () == (void*) test_hash_map.value_equal_func);
- value.unset ();
- }
}
diff --git a/tests/testhashmultimap.vala b/tests/testhashmultimap.vala
index 160985b..b334d28 100644
--- a/tests/testhashmultimap.vala
+++ b/tests/testhashmultimap.vala
@@ -45,11 +45,5 @@ public class HashMultiMapTests : MultiMapTests {
// Check the map exists
assert (test_hash_multi_map != null);
-
- // Check the selected hash and equal functions
- assert (test_hash_multi_map.key_hash_func == str_hash);
- assert (test_hash_multi_map.key_equal_func == str_equal);
- assert (test_hash_multi_map.value_hash_func == str_hash);
- assert (test_hash_multi_map.value_equal_func == str_equal);
}
}
diff --git a/tests/testhashmultiset.vala b/tests/testhashmultiset.vala
index 13b951c..da9f3f4 100644
--- a/tests/testhashmultiset.vala
+++ b/tests/testhashmultiset.vala
@@ -45,9 +45,5 @@ public class HashMultiSetTests : MultiSetTests {
// Check the collection exists
assert (test_multi_set != null);
-
- // Check the selected hash and equal functions
- assert (test_multi_set.hash_func == str_hash);
- assert (test_multi_set.equal_func == str_equal);
}
}
diff --git a/tests/testhashset.vala b/tests/testhashset.vala
index b252c19..1a6f8f1 100644
--- a/tests/testhashset.vala
+++ b/tests/testhashset.vala
@@ -27,8 +27,6 @@ public class HashSetTests : SetTests {
public HashSetTests () {
base ("HashSet");
- add_test ("[HashSet] selected functions", test_selected_functions);
- add_test ("[HashSet] GObject properties", test_gobject_properties);
}
public override void set_up () {
@@ -38,33 +36,4 @@ public class HashSetTests : SetTests {
public override void tear_down () {
test_collection = null;
}
-
- public void test_selected_functions () {
- var test_set = test_collection as HashSet<string>;
-
- // Check the map exists
- assert (test_set != null);
-
- // Check the selected hash and equal functions
- assert (test_set.hash_func == str_hash);
- assert (test_set.equal_func == str_equal);
- }
-
- public new void test_gobject_properties () {
- var test_set = test_collection as HashSet<string>;
-
- // Check the list exists
- assert (test_set != null);
- Value value;
-
- value = Value (typeof (HashFunc));
- test_set.get_property ("hash-func", ref value);
- assert (value.get_pointer () == (void*) test_set.hash_func);
- value.unset ();
-
- value = Value (typeof (EqualFunc));
- test_set.get_property ("equal-func", ref value);
- assert (value.get_pointer () == (void*) test_set.equal_func);
- value.unset ();
- }
}
diff --git a/tests/testlinkedlist.vala b/tests/testlinkedlist.vala
index 737b6e3..b86b734 100644
--- a/tests/testlinkedlist.vala
+++ b/tests/testlinkedlist.vala
@@ -28,8 +28,6 @@ public class LinkedListTests : ListTests {
public LinkedListTests () {
base ("LinkedList");
- add_test ("[LinkedList] selected functions", test_selected_functions);
- add_test ("[LinkedList] GObject properties", test_gobject_properties);
add_test ("[LinkedList] sort", test_sort);
}
@@ -41,29 +39,6 @@ public class LinkedListTests : ListTests {
test_collection = null;
}
- private void test_selected_functions () {
- var test_list = test_collection as LinkedList<string>;
-
- // Check the collection exists
- assert (test_list != null);
-
- // Check the selected equal function
- assert (test_list.equal_func == str_equal);
- }
-
- public new void test_gobject_properties () {
- var test_list = test_collection as LinkedList<string>;
-
- // Check the list exists
- assert (test_list != null);
- Value value;
-
- value = Value (typeof (EqualFunc));
- test_list.get_property ("equal-func", ref value);
- assert (value.get_pointer () == (void*) test_list.equal_func);
- value.unset ();
- }
-
private void test_sort () {
var test_list = test_collection as LinkedList<string>;
diff --git a/tests/testlinkedlistasdeque.vala b/tests/testlinkedlistasdeque.vala
index 81b791f..2b9a791 100644
--- a/tests/testlinkedlistasdeque.vala
+++ b/tests/testlinkedlistasdeque.vala
@@ -42,8 +42,5 @@ public class LinkedListAsDequeTests : DequeTests {
// Check the collection exists
assert (test_list != null);
-
- // Check the selected equal function
- assert (test_list.equal_func == str_equal);
}
}
diff --git a/tests/testmap.vala b/tests/testmap.vala
index 19fc091..df7aa54 100644
--- a/tests/testmap.vala
+++ b/tests/testmap.vala
@@ -314,9 +314,7 @@ public abstract class MapTests : Gee.TestCase {
}
public void test_set_all () {
- var another_map = new HashMap<string,string> (str_hash,
- str_equal,
- str_equal);
+ var another_map = new HashMap<string,string> ();
test_map.set ("one", "value_of_one");
test_map.set ("two", "value_of_two");
@@ -344,9 +342,7 @@ public abstract class MapTests : Gee.TestCase {
}
public void test_unset_all () {
- var another_map = new HashMap<string,string> (str_hash,
- str_equal,
- str_equal);
+ var another_map = new HashMap<string,string> ();
// Check unset all on empty maps.
assert (test_map.is_empty);
@@ -431,9 +427,7 @@ public abstract class MapTests : Gee.TestCase {
}
public void test_has_all () {
- var another_map = new HashMap<string,string> (str_hash,
- str_equal,
- str_equal);
+ var another_map = new HashMap<string,string> ();
// Check empty.
assert (test_map.has_all (another_map));
diff --git a/tests/testpriorityqueue.vala b/tests/testpriorityqueue.vala
index 9c82ab2..9274dd8 100644
--- a/tests/testpriorityqueue.vala
+++ b/tests/testpriorityqueue.vala
@@ -26,8 +26,6 @@ public class PriorityQueueTests : QueueTests {
public PriorityQueueTests () {
base ("PriorityQueue");
- add_test ("[PriorityQueue] selected functions", test_selected_functions);
- add_test ("[PriorityQueue] GObject properties", test_gobject_properties);
add_test ("[PriorityQueue] poll gives minimum", test_poll_gives_minimum);
}
@@ -39,29 +37,6 @@ public class PriorityQueueTests : QueueTests {
test_collection = null;
}
- private void test_selected_functions () {
- var test_queue = test_collection as PriorityQueue<string>;
-
- // Check the queue exists
- assert (test_queue != null);
-
- // Check the selected compare function
- assert (test_queue.compare_func == (CompareFunc) strcmp);
- }
-
- public new void test_gobject_properties () {
- var test_queue = test_collection as PriorityQueue<string>;
-
- // Check the list exists
- assert (test_queue != null);
- Value value;
-
- value = Value (typeof (CompareFunc));
- test_queue.get_property ("compare-func", ref value);
- assert (value.get_pointer () == (void*) test_queue.compare_func);
- value.unset ();
- }
-
private void test_poll_gives_minimum () {
var test_queue = test_collection as Gee.Queue<string>;
diff --git a/tests/testtreemap.vala b/tests/testtreemap.vala
index 993c67e..99a54d8 100644
--- a/tests/testtreemap.vala
+++ b/tests/testtreemap.vala
@@ -27,8 +27,6 @@ public class TreeMapTests : MapTests {
public TreeMapTests () {
base ("TreeMap");
- add_test ("[TreeMap] selected functions", test_selected_functions);
- add_test ("[TreeMap] GObject properties", test_gobject_properties);
add_test ("[TreeMap] key ordering", test_key_ordering);
}
@@ -40,35 +38,6 @@ public class TreeMapTests : MapTests {
test_map = null;
}
- public void test_selected_functions () {
- var test_tree_map = test_map as TreeMap<string,string>;
-
- // Check the map exists
- assert (test_tree_map != null);
-
- // Check the selected compare and equal functions
- assert (test_tree_map.key_compare_func == (CompareFunc) strcmp);
- assert (test_tree_map.value_equal_func == str_equal);
- }
-
- public new void test_gobject_properties () {
- var test_tree_map = test_map as TreeMap<string,string>;
-
- // Check the list exists
- assert (test_tree_map != null);
- Value value;
-
- value = Value (typeof (CompareFunc));
- test_tree_map.get_property ("key-compare-func", ref value);
- assert (value.get_pointer () == (void*) test_tree_map.key_compare_func);
- value.unset ();
-
- value = Value (typeof (EqualFunc));
- test_tree_map.get_property ("value-equal-func", ref value);
- assert (value.get_pointer () == (void*) test_tree_map.value_equal_func);
- value.unset ();
- }
-
public void test_key_ordering () {
var test_tree_map = test_map as TreeMap<string,string>;
diff --git a/tests/testtreemultimap.vala b/tests/testtreemultimap.vala
index 34374a9..773eef9 100644
--- a/tests/testtreemultimap.vala
+++ b/tests/testtreemultimap.vala
@@ -29,7 +29,6 @@ public class TreeMultiMapTests : MultiMapTests {
public TreeMultiMapTests () {
base ("TreeMultiMap");
- add_test ("[TreeMultiMap] selected functions", test_selected_functions);
}
public override void set_up () {
@@ -39,15 +38,4 @@ public class TreeMultiMapTests : MultiMapTests {
public override void tear_down () {
test_multi_map = null;
}
-
- private void test_selected_functions () {
- var test_tree_multi_map = test_multi_map as TreeMultiMap<string,string>;
-
- // Check the map exists
- assert (test_tree_multi_map != null);
-
- // Check the selected compare functions
- assert (test_tree_multi_map.key_compare_func == (CompareFunc) strcmp);
- assert (test_tree_multi_map.value_compare_func == (CompareFunc) strcmp);
- }
}
diff --git a/tests/testtreemultiset.vala b/tests/testtreemultiset.vala
index da86ca2..711c110 100644
--- a/tests/testtreemultiset.vala
+++ b/tests/testtreemultiset.vala
@@ -26,7 +26,6 @@ public class TreeMultiSetTests : MultiSetTests {
public TreeMultiSetTests () {
base ("TreeMultiSet");
- add_test ("[TreeMultiSet] selected functions", test_selected_functions);
}
public override void set_up () {
@@ -36,14 +35,4 @@ public class TreeMultiSetTests : MultiSetTests {
public override void tear_down () {
test_collection = null;
}
-
- private void test_selected_functions () {
- var test_multi_set = test_collection as TreeMultiSet<string>;
-
- // Check the collection exists
- assert (test_multi_set != null);
-
- // Check the selected compare functions
- assert (test_multi_set.compare_func == (CompareFunc) strcmp);
- }
}
diff --git a/tests/testtreeset.vala b/tests/testtreeset.vala
index 6d754bc..0a28d7e 100644
--- a/tests/testtreeset.vala
+++ b/tests/testtreeset.vala
@@ -27,8 +27,6 @@ public class TreeSetTests : SortedSetTests {
public TreeSetTests () {
base ("TreeSet");
- add_test ("[TreeSet] selected functions", test_selected_functions);
- add_test ("[TreeSet] GObject properties", test_gobject_properties);
add_test ("[TreeSet] add and remove", test_add_remove);
}
@@ -40,29 +38,6 @@ public class TreeSetTests : SortedSetTests {
test_collection = null;
}
- public void test_selected_functions () {
- var test_set = test_collection as TreeSet<string>;
-
- // Check the set exists
- assert (test_set != null);
-
- // Check the selected compare function
- assert (test_set.compare_func == (CompareFunc) strcmp);
- }
-
- public new void test_gobject_properties () {
- var test_set = test_collection as TreeSet<string>;
-
- // Check the set exists
- assert (test_set != null);
- Value value;
-
- value = Value (typeof (CompareFunc));
- test_set.get_property ("compare-func", ref value);
- assert (value.get_pointer () == (void*) test_set.compare_func);
- value.unset ();
- }
-
public new void test_add_remove () {
var test_set = test_collection as TreeSet<string>;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]