[libgee] Make func and wrappee properties non-updatable
- From: Didier 'Ptitjes' Villevalois <dvillevalois src gnome org>
- To: svn-commits-list gnome org
- Subject: [libgee] Make func and wrappee properties non-updatable
- Date: Wed, 22 Jul 2009 15:54:03 +0000 (UTC)
commit a21d9e955a34579b69dd546984b2194f58806e0a
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date: Sun May 24 16:37:07 2009 +0200
Make func and wrappee properties non-updatable
Fixes bug 583723.
Signed-off-by: Didier 'Ptitjes <ptitjes free fr>
gee/arraylist.vala | 13 ++++-------
gee/hashmap.vala | 48 +++++++++++++-----------------------------
gee/hashset.vala | 19 +++++-----------
gee/readonlycollection.vala | 2 +-
gee/readonlylist.vala | 2 +-
gee/readonlymap.vala | 2 +-
gee/readonlyset.vala | 2 +-
7 files changed, 30 insertions(+), 58 deletions(-)
---
diff --git a/gee/arraylist.vala b/gee/arraylist.vala
index 83d8342..7793376 100644
--- a/gee/arraylist.vala
+++ b/gee/arraylist.vala
@@ -32,13 +32,10 @@ public class Gee.ArrayList<G> : Object, Iterable<G>, Collection<G>, List<G> {
get { return _size; }
}
- public EqualFunc equal_func {
- set { _equal_func = value; }
- }
+ public EqualFunc equal_func { construct; get; }
private G[] _items = new G[4];
private int _size;
- private EqualFunc _equal_func;
// concurrent modification protection
private int _stamp = 0;
@@ -61,7 +58,7 @@ public class Gee.ArrayList<G> : Object, Iterable<G>, Collection<G>, List<G> {
public int index_of (G item) {
for (int index = 0; index < _size; index++) {
- if (_equal_func (_items[index], item)) {
+ if (equal_func (_items[index], item)) {
return index;
}
}
@@ -105,7 +102,7 @@ public class Gee.ArrayList<G> : Object, Iterable<G>, Collection<G>, List<G> {
public bool remove (G item) {
for (int index = 0; index < _size; index++) {
- if (_equal_func (_items[index], item)) {
+ if (equal_func (_items[index], item)) {
remove_at (index);
return true;
}
@@ -137,7 +134,7 @@ public class Gee.ArrayList<G> : Object, Iterable<G>, Collection<G>, List<G> {
return_val_if_fail (start >= 0, null);
return_val_if_fail (stop <= _size, null);
- var slice = new ArrayList<G> (this._equal_func);
+ var slice = new ArrayList<G> (this.equal_func);
for (int i = start; i < stop; i++) {
slice.add (this[i]);
}
@@ -173,7 +170,7 @@ public class Gee.ArrayList<G> : Object, Iterable<G>, Collection<G>, List<G> {
private class Iterator<G> : Object, Gee.Iterator<G> {
public ArrayList<G> list {
- set {
+ construct {
_list = value;
_stamp = _list._stamp;
}
diff --git a/gee/hashmap.vala b/gee/hashmap.vala
index c8d0841..ce24fd1 100644
--- a/gee/hashmap.vala
+++ b/gee/hashmap.vala
@@ -32,17 +32,11 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
get { return _nnodes; }
}
- public HashFunc key_hash_func {
- set { _key_hash_func = value; }
- }
+ public HashFunc key_hash_func { construct; get; }
- public EqualFunc key_equal_func {
- set { _key_equal_func = value; }
- }
+ public EqualFunc key_equal_func { construct; get; }
- public EqualFunc value_equal_func {
- set { _value_equal_func = value; }
- }
+ public EqualFunc value_equal_func { construct; get; }
private int _array_size;
private int _nnodes;
@@ -51,10 +45,6 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
// concurrent modification protection
private int _stamp = 0;
- private HashFunc _key_hash_func;
- private EqualFunc _key_equal_func;
- private EqualFunc _value_equal_func;
-
private const int MIN_SIZE = 11;
private const int MAX_SIZE = 13845163;
@@ -78,9 +68,9 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
}
private Node<K,V>** lookup_node (K key) {
- uint hash_value = _key_hash_func (key);
+ uint hash_value = key_hash_func (key);
Node<K,V>** node = &_nodes[hash_value % _array_size];
- while ((*node) != null && (hash_value != (*node)->key_hash || !_key_equal_func ((*node)->key, key))) {
+ while ((*node) != null && (hash_value != (*node)->key_hash || !key_equal_func ((*node)->key, key))) {
node = &((*node)->next);
}
return node;
@@ -105,7 +95,7 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
if (*node != null) {
(*node)->value = value;
} else {
- uint hash_value = _key_hash_func (key);
+ uint hash_value = key_hash_func (key);
*node = new Node<K,V> (key, value, hash_value);
_nnodes++;
resize ();
@@ -188,11 +178,7 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
}
private class KeySet<K,V> : Object, Iterable<K>, Collection<K>, Set<K> {
- public HashMap<K,V> map {
- set { _map = value; }
- }
-
- private HashMap<K,V> _map;
+ public HashMap<K,V> map { construct; get; }
public KeySet (HashMap map) {
this.map = map;
@@ -203,11 +189,11 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
}
public Iterator<K> iterator () {
- return new KeyIterator<K,V> (_map);
+ return new KeyIterator<K,V> (map);
}
public int size {
- get { return _map.size; }
+ get { return map.size; }
}
public bool add (K key) {
@@ -229,7 +215,7 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
private class KeyIterator<K,V> : Object, Iterator<K> {
public HashMap<K,V> map {
- set {
+ construct {
_map = value;
_stamp = _map._stamp;
}
@@ -265,11 +251,7 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
}
private class ValueCollection<K,V> : Object, Iterable<V>, Collection<V> {
- public HashMap<K,V> map {
- set { _map = value; }
- }
-
- private HashMap<K,V> _map;
+ public HashMap<K,V> map { construct; get; }
public ValueCollection (HashMap map) {
this.map = map;
@@ -280,11 +262,11 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
}
public Iterator<V> iterator () {
- return new ValueIterator<K,V> (_map);
+ return new ValueIterator<K,V> (map);
}
public int size {
- get { return _map.size; }
+ get { return map.size; }
}
public bool add (V value) {
@@ -302,7 +284,7 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
public bool contains (V value) {
Iterator<V> it = iterator ();
while (it.next ()) {
- if (_map._value_equal_func (it.get (), value)) {
+ if (map.value_equal_func (it.get (), value)) {
return true;
}
}
@@ -312,7 +294,7 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
private class ValueIterator<K,V> : Object, Iterator<V> {
public HashMap<K,V> map {
- set {
+ construct {
_map = value;
_stamp = _map._stamp;
}
diff --git a/gee/hashset.vala b/gee/hashset.vala
index 1e45232..c15a6da 100644
--- a/gee/hashset.vala
+++ b/gee/hashset.vala
@@ -32,13 +32,9 @@ public class Gee.HashSet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
get { return _nnodes; }
}
- public HashFunc hash_func {
- set { _hash_func = value; }
- }
+ public HashFunc hash_func { construct; get; }
- public EqualFunc equal_func {
- set { _equal_func = value; }
- }
+ public EqualFunc equal_func { construct; get; }
private int _array_size;
private int _nnodes;
@@ -47,9 +43,6 @@ public class Gee.HashSet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
// concurrent modification protection
private int _stamp = 0;
- private HashFunc _hash_func;
- private EqualFunc _equal_func;
-
private const int MIN_SIZE = 11;
private const int MAX_SIZE = 13845163;
@@ -64,9 +57,9 @@ public class Gee.HashSet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
}
private Node<G>** lookup_node (G key) {
- uint hash_value = _hash_func (key);
+ uint hash_value = hash_func (key);
Node<G>** node = &_nodes[hash_value % _array_size];
- while ((*node) != null && (hash_value != (*node)->key_hash || !_equal_func ((*node)->key, key))) {
+ while ((*node) != null && (hash_value != (*node)->key_hash || !equal_func ((*node)->key, key))) {
node = &((*node)->next);
}
return node;
@@ -90,7 +83,7 @@ public class Gee.HashSet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
if (*node != null) {
return false;
} else {
- uint hash_value = _hash_func (key);
+ uint hash_value = hash_func (key);
*node = new Node<G> (key, hash_value);
_nnodes++;
resize ();
@@ -171,7 +164,7 @@ public class Gee.HashSet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
private class Iterator<G> : Object, Gee.Iterator<G> {
public new HashSet<G> set {
- set {
+ construct {
_set = value;
_stamp = _set._stamp;
}
diff --git a/gee/readonlycollection.vala b/gee/readonlycollection.vala
index e057297..8bc247d 100644
--- a/gee/readonlycollection.vala
+++ b/gee/readonlycollection.vala
@@ -31,7 +31,7 @@ public class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Collection<G> {
}
public Collection<G> collection {
- set { _collection = value; }
+ construct { _collection = value; }
}
private Collection<G> _collection;
diff --git a/gee/readonlylist.vala b/gee/readonlylist.vala
index ee19b73..19b3089 100644
--- a/gee/readonlylist.vala
+++ b/gee/readonlylist.vala
@@ -31,7 +31,7 @@ public class Gee.ReadOnlyList<G> : Object, Iterable<G>, Collection<G>, List<G> {
}
public List<G> list {
- set { _list = value; }
+ construct { _list = value; }
}
private List<G> _list;
diff --git a/gee/readonlymap.vala b/gee/readonlymap.vala
index 92997c8..de5632b 100644
--- a/gee/readonlymap.vala
+++ b/gee/readonlymap.vala
@@ -31,7 +31,7 @@ public class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
}
public Map<K,V> map {
- set { _map = value; }
+ construct { _map = value; }
}
private Map<K,V> _map;
diff --git a/gee/readonlyset.vala b/gee/readonlyset.vala
index 6da0803..e3ebe98 100644
--- a/gee/readonlyset.vala
+++ b/gee/readonlyset.vala
@@ -31,7 +31,7 @@ public class Gee.ReadOnlySet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
}
public new Set<G> set {
- set { _set = value; }
+ construct { _set = value; }
}
private Set<G> _set;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]