[libgee] Fix typos in TreeMap and TreeSet fix and other embarrasing mistakes
- From: Maciej Marcin Piechotka <mpiechotka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgee] Fix typos in TreeMap and TreeSet fix and other embarrasing mistakes
- Date: Tue, 3 Aug 2010 00:22:00 +0000 (UTC)
commit 37cacc4cfa8816a732f2cf684d78f81d2f6cb108
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date: Tue Aug 3 00:42:44 2010 +0200
Fix typos in TreeMap and TreeSet fix and other embarrasing mistakes
gee/treemap.vala | 13 ++++++++-----
gee/treeset.vala | 11 +++++++----
2 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/gee/treemap.vala b/gee/treemap.vala
index 5b9d5bf..8b3917e 100644
--- a/gee/treemap.vala
+++ b/gee/treemap.vala
@@ -245,6 +245,8 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
Node<K,V> n = (owned) node;
if (&key != null)
key = (owned) n.key;
+ else
+ n.key = null;
if (&value != null)
value = (owned) n.value;
if (n.prev != null) {
@@ -257,8 +259,7 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
} else {
last = n.next;
}
- node.key = null;
- node.value = null;
+ n.value = null;
node = null;
_size--;
}
@@ -356,11 +357,13 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
return b;
}
- private inline void clear_subtree (owned Node<G> node) {
+ private inline void clear_subtree (owned Node<K,V> node) {
node.key = null;
node.value = null;
- clear_subtree ((owned) node.left);
- clear_subtree ((owned) node.right);
+ if (node.left != null)
+ clear_subtree ((owned) node.left);
+ if (node.right != null)
+ clear_subtree ((owned) node.right);
}
/**
diff --git a/gee/treeset.vala b/gee/treeset.vala
index 2ebe1f7..0f09ff9 100644
--- a/gee/treeset.vala
+++ b/gee/treeset.vala
@@ -214,6 +214,8 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
Node<G> n = (owned)node;
if (&key != null)
key = (owned) n.key;
+ else
+ n.key = null;
if (n.prev != null) {
n.prev.next = n.next;
} else {
@@ -224,7 +226,6 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
} else {
_last = n.prev;
}
- node.key = null;
node = null;
_size--;
}
@@ -314,8 +315,10 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
private inline void clear_subtree (owned Node<G> node) {
node.key = null;
- clear_subtree ((owned) node.left);
- clear_subtree ((owned) node.right);
+ if (node.left != null)
+ clear_subtree ((owned) node.left);
+ if (node.right != null)
+ clear_subtree ((owned) node.right);
}
/**
@@ -324,7 +327,7 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
public override void clear () {
if (root != null) {
clear_subtree ((owned) root);
- first = last = null;
+ _first = _last = null;
}
_size = 0;
stamp++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]