[libgee/0.6] Change Gee.TreeSet.Range to class
- From: Maciej Marcin Piechotka <mpiechotka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgee/0.6] Change Gee.TreeSet.Range to class
- Date: Fri, 29 Apr 2011 00:06:41 +0000 (UTC)
commit 8644055a862f980b99e3d66052e07ccb2c2742f0
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date: Fri Apr 29 01:45:46 2011 +0200
Change Gee.TreeSet.Range to class
It fixes problem that may occured when key used as boundary is freed
gee/treeset.vala | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/gee/treeset.vala b/gee/treeset.vala
index 0f09ff9..3548cf1 100644
--- a/gee/treeset.vala
+++ b/gee/treeset.vala
@@ -712,7 +712,7 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
return compare_func (a, b) > 0 ? a : b;
}
- private struct Range<G> {
+ private class Range<G> {
public Range (TreeSet<G> set, G after, G before) {
this.set = set;
if (set.compare_func (after, before) < 0) {
@@ -746,14 +746,14 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
public Range<G> cut_head (G after) {
switch (type) {
case RangeType.HEAD:
- return Range<G> (set, after, before);
+ return new Range<G> (set, after, before);
case RangeType.TAIL:
- return Range<G>.tail (set, set.max (after, this.after));
+ return new Range<G>.tail (set, set.max (after, this.after));
case RangeType.EMPTY:
return this;
case RangeType.BOUNDED:
var _after = set.max (after, this.after);
- return Range<G> (set, _after, before);
+ return new Range<G> (set, _after, before);
default:
assert_not_reached ();
}
@@ -762,14 +762,14 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
public Range<G> cut_tail (G before) {
switch (type) {
case RangeType.HEAD:
- return Range<G>.head (set, set.min (before, this.before));
+ return new Range<G>.head (set, set.min (before, this.before));
case RangeType.TAIL:
- return Range<G> (set, after, before);
+ return new Range<G> (set, after, before);
case RangeType.EMPTY:
return this;
case RangeType.BOUNDED:
var _before = set.min (before, this.before);
- return Range<G> (set, after, _before);
+ return new Range<G> (set, after, _before);
default:
assert_not_reached ();
}
@@ -780,7 +780,7 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
return this;
var _before = type != RangeType.TAIL ? set.min (before, this.before) : before;
var _after = type != RangeType.HEAD ? set.max (after, this.after) : after;
- return Range<G> (set, _after, _before);
+ return new Range<G> (set, _after, _before);
}
public bool in_range (G item) {
@@ -856,17 +856,17 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
private class SubSet<G> : AbstractSet<G>, SortedSet<G> {
public SubSet (TreeSet<G> set, G after, G before) {
this.set = set;
- this.range = Range<G> (set, after, before);
+ this.range = new Range<G> (set, after, before);
}
public SubSet.head (TreeSet<G> set, G before) {
this.set = set;
- this.range = Range<G>.head (set, before);
+ this.range = new Range<G>.head (set, before);
}
public SubSet.tail (TreeSet<G> set, G after) {
this.set = set;
- this.range = Range<G>.tail (set, after);
+ this.range = new Range<G>.tail (set, after);
}
public SubSet.from_range (TreeSet<G> set, Range<G> range) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]