[hyena] RangeCollection: Remove the obsolete Indexes property
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] RangeCollection: Remove the obsolete Indexes property
- Date: Sat, 30 Apr 2011 09:18:00 +0000 (UTC)
commit 761cf0cd9e127e1dba85c2fccf00c4b50ac6d430
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Sat Apr 30 11:08:09 2011 +0200
RangeCollection: Remove the obsolete Indexes property
The Indexes property was just a memory-hungry substitute for
IEnumerable<int> in .NET 1.1.
Also remove the unit tests for that property.
Hyena/Hyena.Collections/RangeCollection.cs | 26 ------------
.../Tests/RangeCollectionTests.cs | 42 --------------------
2 files changed, 0 insertions(+), 68 deletions(-)
---
diff --git a/Hyena/Hyena.Collections/RangeCollection.cs b/Hyena/Hyena.Collections/RangeCollection.cs
index 881377f..ded0644 100644
--- a/Hyena/Hyena.Collections/RangeCollection.cs
+++ b/Hyena/Hyena.Collections/RangeCollection.cs
@@ -71,9 +71,6 @@ namespace Hyena.Collections
private Range [] ranges;
private int range_count;
private int index_count;
- private int generation;
- private int [] indexes_cache;
- private int indexes_cache_generation;
public RangeCollection ()
{
@@ -252,26 +249,6 @@ namespace Hyena.Collections
get { return range_count; }
}
- [Obsolete ("Do not use the Indexes property in 2.0 profiles if enumerating only; Indexes allocates an array to avoid boxing in the 1.1 profile")]
- public int [] Indexes {
- get {
- if (indexes_cache != null && generation == indexes_cache_generation) {
- return indexes_cache;
- }
-
- indexes_cache = new int[Count];
- indexes_cache_generation = generation;
-
- for (int i = 0, j = 0; i < range_count; i++) {
- for (int k = ranges[i].Start; k <= ranges[i].End; j++, k++) {
- indexes_cache[j] = k;
- }
- }
-
- return indexes_cache;
- }
- }
-
public int IndexOf (int value)
{
int offset = 0;
@@ -306,7 +283,6 @@ namespace Hyena.Collections
public bool Add (int value)
{
if (!Contains (value)) {
- generation++;
InsertRange (new Range (value, value));
index_count++;
return true;
@@ -322,7 +298,6 @@ namespace Hyena.Collections
public bool Remove (int value)
{
- generation++;
return RemoveIndexFromRange (value);
}
@@ -330,7 +305,6 @@ namespace Hyena.Collections
{
range_count = 0;
index_count = 0;
- generation++;
ranges = new Range[MIN_CAPACITY];
}
diff --git a/Hyena/Hyena.Collections/Tests/RangeCollectionTests.cs b/Hyena/Hyena.Collections/Tests/RangeCollectionTests.cs
index b461573..724e495 100644
--- a/Hyena/Hyena.Collections/Tests/RangeCollectionTests.cs
+++ b/Hyena/Hyena.Collections/Tests/RangeCollectionTests.cs
@@ -146,20 +146,6 @@ namespace Hyena.Collections.Tests
foreach (int index in range) {
Assert.AreEqual (indexes[i++], index);
}
-
- #pragma warning disable 0618
-
- i = 0;
- foreach (int index in range.Indexes) {
- Assert.AreEqual (indexes[i++], index);
- }
-
- for (i = 0; i < range.Indexes.Length; i++) {
- Assert.AreEqual (indexes[i], range.Indexes[i]);
- }
-
- #pragma warning restore 0618
-
}
[Test]
@@ -288,34 +274,6 @@ namespace Hyena.Collections.Tests
return range;
}
- #pragma warning disable 0618
-
- [Test]
- public void IndexesCacheGeneration ()
- {
- RangeCollection range = new RangeCollection ();
- int [] index_cache = range.Indexes;
-
- Assert.AreSame (index_cache, range.Indexes);
-
- range.Add (0);
- range.Add (5);
-
- if (index_cache == range.Indexes) {
- Assert.Fail ("Indexes Cache not regenerated after change");
- }
-
- index_cache = range.Indexes;
- range.Remove (0);
- range.Add (3);
-
- if (index_cache == range.Indexes) {
- Assert.Fail ("Indexes Cache not regenerated after change");
- }
- }
-
- #pragma warning restore 0618
-
[Test]
public void IndexOf ()
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]