Permalink
Browse files

Remove Iesi.Collections (NH-3099)

Iesi.Collections source code now lives in its own repository on
GitHub: https://github.com/nhibernate/iesi.collections
  • Loading branch information...
1 parent eea5a7e commit 0c07499c9d62c9d69a90d0553086cac028d4adbb @julian-maughan julian-maughan committed May 24, 2012
Showing with 1 addition and 4,883 deletions.
  1. +1 −13 default.build
  2. +0 −50 src/Iesi.Collections.Test/Generic/HashedSetFixture.cs
  3. +0 −29 src/Iesi.Collections.Test/Generic/ImmutableSetFixture.cs
  4. +0 −42 src/Iesi.Collections.Test/Generic/OrderedSetFixture.cs
  5. +0 −463 src/Iesi.Collections.Test/Generic/SetFixture.cs
  6. +0 −69 src/Iesi.Collections.Test/Generic/SortedSetFixture.cs
  7. +0 −50 src/Iesi.Collections.Test/HashedSetFixture.cs
  8. +0 −29 src/Iesi.Collections.Test/HybridSetFixture.cs
  9. +0 −36 src/Iesi.Collections.Test/Iesi.Collections.Test.build
  10. +0 −121 src/Iesi.Collections.Test/Iesi.Collections.Test.csproj
  11. +0 −9 src/Iesi.Collections.Test/Iesi.Collections.Test.nunit
  12. +0 −29 src/Iesi.Collections.Test/ListSetFixture.cs
  13. +0 −395 src/Iesi.Collections.Test/SetFixture.cs
  14. +0 −66 src/Iesi.Collections.Test/SortedSetFixture.cs
  15. +0 −24 src/Iesi.Collections.sln
  16. +0 −219 src/Iesi.Collections/DictionarySet.cs
  17. +0 −249 src/Iesi.Collections/Generic/DictionarySet.cs
  18. +0 −33 src/Iesi.Collections/Generic/HashedSet.cs
  19. +0 −139 src/Iesi.Collections/Generic/ISet.cs
  20. +0 −308 src/Iesi.Collections/Generic/ImmutableSet.cs
  21. +0 −30 src/Iesi.Collections/Generic/OrderedSet.cs
  22. +0 −561 src/Iesi.Collections/Generic/Set.cs
  23. +0 −69 src/Iesi.Collections/Generic/SortedSet.cs
  24. +0 −262 src/Iesi.Collections/Generic/SynchronizedSet.cs
  25. +0 −32 src/Iesi.Collections/HashedSet.cs
  26. +0 −38 src/Iesi.Collections/HybridSet.cs
  27. +0 −148 src/Iesi.Collections/ISet.cs
  28. +0 −57 src/Iesi.Collections/Iesi.Collections.build
  29. +0 −111 src/Iesi.Collections/Iesi.Collections.csproj
  30. +0 −9 src/Iesi.Collections/Iesi.Collections.license.txt
  31. +0 −19 src/Iesi.Collections/Iesi.Collections.nuspec.template
  32. +0 −240 src/Iesi.Collections/ImmutableSet.cs
  33. +0 −37 src/Iesi.Collections/ListSet.cs
  34. +0 −185 src/Iesi.Collections/NamespaceSummary.xml
  35. +0 −382 src/Iesi.Collections/Set.cs
  36. +0 −55 src/Iesi.Collections/SortedSet.cs
  37. +0 −243 src/Iesi.Collections/SynchronizedSet.cs
  38. +0 −32 src/NHibernate.Everything.sln
View
14 default.build
@@ -20,8 +20,6 @@
<fileset id="buildfiles.all" basedir="src">
<!-- Files have to be in dependency order -->
- <include name="Iesi.Collections/Iesi.Collections.build" />
- <include name="Iesi.Collections.Test/Iesi.Collections.Test.build" />
<include name="NHibernate/NHibernate.build" />
<include name="NHibernate.DomainModel/NHibernate.DomainModel.build" />
<include name="NHibernate.Test/NHibernate.Test.build" />
@@ -32,7 +30,6 @@
<fileset id="buildfiles.tests" basedir="src">
<include name="NHibernate.TestDatabaseSetup/TestDatabaseSetup.build" />
- <include name="Iesi.Collections.Test/Iesi.Collections.Test.build" />
<include name="NHibernate.Test/NHibernate.Test.build" />
<include name="NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.build" />
</fileset>
@@ -74,13 +71,6 @@
<!-- Copy framework-specific libraries -->
<copy todir="${bin.dir}">
<fileset basedir="${lib.framework.dir}">
- <!--
- Excludes the Iesi.Collections assembly because it is built during the build
- of NHibernate. It is in the lib folder for VS.NET convenience. However, we
- do want to copy the license file.
- -->
- <exclude name="Iesi.Collections.dll" />
- <exclude name="Iesi.Collections.xml" />
<include name="*.dll" />
<include name="*.xml" />
<include name="*.license.txt" />
@@ -187,7 +177,6 @@
<!-- copy all of the NHibernate source -->
<include name="src/NHibernate*/**" />
- <include name="src/Iesi*/**" />
<include name="src/*.*" />
<include name="build-common/**" />
@@ -262,7 +251,7 @@
<copy todir="${bin-pack.required}">
<fileset basedir="${bin.dir}">
<include name="Iesi.Collections.???" />
- <include name="NHibernate.???" />
+ <include name="NHibernate.???" />
</fileset>
</copy>
<!--Required Bins for lazy loading NHibernate.ByteCode.Castle.dll-->
@@ -320,7 +309,6 @@
</target>
<fileset id="nugetfiles.all" basedir="src">
- <include name="Iesi.Collections/Iesi.Collections.build" />
<include name="NHibernate/NHibernate.build" />
</fileset>
View
50 src/Iesi.Collections.Test/Generic/HashedSetFixture.cs
@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Binary;
-using Iesi.Collections.Generic;
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test.Generic
-{
- /// <summary>
- /// Summary description for HashedSetFixture.
- /// </summary>
- [TestFixture]
- public class HashedSetFixture : GenericSetFixture
- {
- protected override ISet<string> CreateInstance()
- {
- return new HashedSet<string>();
- }
-
- protected override ISet<string> CreateInstance(ICollection<string> init)
- {
- return new HashedSet<string>(init);
- }
-
- protected override Type ExpectedType
- {
- get { return typeof(HashedSet<string>); }
- }
-
- [Test]
- public void Serialization()
- {
- // serialize and then deserialize the ISet.
- Stream stream = new MemoryStream();
- IFormatter formatter = new BinaryFormatter();
- formatter.Serialize(stream, _set);
- stream.Position = 0;
-
- ISet<string> desSet = (ISet<string>) formatter.Deserialize(stream);
- stream.Close();
-
- Assert.AreEqual(3, desSet.Count, "should have des 3 items");
- Assert.IsTrue(desSet.Contains(one), "should contain one");
- Assert.IsTrue(desSet.Contains(two), "should contain two");
- Assert.IsTrue(desSet.Contains(three), "should contain three");
- }
- }
-}
View
29 src/Iesi.Collections.Test/Generic/ImmutableSetFixture.cs
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Iesi.Collections.Generic;
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test.Generic
-{
- /// <summary>
- /// Summary description for HashedSetFixture.
- /// </summary>
- [TestFixture]
- public class ImmutableSetFixture : GenericSetFixture
- {
- protected override ISet<string> CreateInstance()
- {
- return new ImmutableSet<string>(new HashedSet<string>());
- }
-
- protected override ISet<string> CreateInstance(ICollection<string> init)
- {
- return new ImmutableSet<string>(new HashedSet<string>(init));
- }
-
- protected override Type ExpectedType
- {
- get { return typeof(ImmutableSet<string>); }
- }
- }
-}
View
42 src/Iesi.Collections.Test/Generic/OrderedSetFixture.cs
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Iesi.Collections.Generic;
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test.Generic
-{
- /// <summary>
- /// Summary description for OrderedSetFixture.
- /// </summary>
- [TestFixture]
- public class OrderedSetFixture : GenericSetFixture
- {
- protected override ISet<string> CreateInstance()
- {
- return new OrderedSet<string>();
- }
-
- protected override ISet<string> CreateInstance(ICollection<string> init)
- {
- return new OrderedSet<string>(init);
- }
-
- protected override Type ExpectedType
- {
- get { return typeof(OrderedSet<string>); }
- }
-
- [Test]
- public void OrderedEnumeration()
- {
- List<string> expectedOrder = new List<string>(3) {one, two, three};
-
- int index = 0;
- foreach (string str in _set)
- {
- Assert.AreEqual(str, expectedOrder[index], index + " did not have same value");
- index++;
- }
- }
- }
-}
View
463 src/Iesi.Collections.Test/Generic/SetFixture.cs
@@ -1,463 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Iesi.Collections.Generic;
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test.Generic
-{
- /// <summary>
- /// Summary description for SetFixture.
- /// </summary>
- public abstract class GenericSetFixture
- {
- private IList<string> _aInitValues;
- private IList<string> _bInitValues;
- protected ISet<string> _set;
-
- public static string one = "one";
- public static string two = "two";
- public static string three = "three";
-
- [SetUp]
- public virtual void SetUp()
- {
- _aInitValues = new List<string>();
- _aInitValues.Add("zero");
- _aInitValues.Add("one");
- _aInitValues.Add("two");
- _aInitValues.Add("three");
-
- _bInitValues = new List<string>();
- _bInitValues.Add("two");
- _bInitValues.Add("three");
- _bInitValues.Add("four");
-
- _set = CreateInstance(new string[] {one, two, three});
- }
-
- #region System.IClonable Member Tests
-
- [Test]
- public void Clone()
- {
- ISet<string> clonedSet = (ISet<string>) _set.Clone();
-
- Assert.AreEqual(ExpectedType, clonedSet.GetType(), "cloned set should be the same type");
- Assert.AreEqual(_set.Count, clonedSet.Count, "set and cloned version should be same");
-
- try
- {
- clonedSet.Add("not in original");
- Assert.IsFalse(_set.Count == clonedSet.Count, "adding to clone should not add to original.");
- if (clonedSet.IsReadOnly)
- Assert.Fail("Read-only set can be modified");
- }
- catch (NotSupportedException)
- {
- if (!clonedSet.IsReadOnly)
- throw;
- }
-
- foreach (string str in _set)
- {
- Assert.IsTrue(clonedSet.Contains(str), "cloned set should have same objects as original set.");
- }
- }
-
- #endregion
-
- #region System.Collections.ICollection Member Tests
-
- [Test]
- public void CopyTo()
- {
- string[] dest = new string[3];
- _set.CopyTo(dest, 0);
-
- int count = 0;
-
- foreach (string obj in dest)
- {
- Assert.IsTrue(_set.Contains(obj), "set should contain the object in the array");
- count++;
- }
-
- Assert.AreEqual(3, count, "should have 3 items in array");
- }
-
- [Test]
- public void Count()
- {
- Assert.AreEqual(3, _set.Count, "should be 3 items");
- Assert.AreEqual(0, CreateInstance().Count, "new set should have nothing in it.");
- }
-
- #endregion
-
- #region Iesi.Collections.ISet<string> Constructor Tests
-
- [Test]
- public void CtorWithDefaults()
- {
- List<string> init = new List<string>(3);
- init.Add("one");
- init.Add("two");
- init.Add("three");
-
- ISet<string> theSet = CreateInstance(init);
-
- Assert.AreEqual(3, init.Count, "3 items in set");
-
- int index = 0;
- foreach (string obj in init)
- {
- Assert.IsTrue(theSet.Contains(obj), "set should contain obj at index = " + index.ToString());
- index++;
- }
- }
-
- #endregion
-
- #region Iesi.Collections.ISet<string> Member Tests
-
- [Test]
- public void Add()
- {
- try
- {
- Assert.IsTrue(_set.Add("four"), "should have added 'four'");
- Assert.AreEqual(4, _set.Count, "should have added 'four'");
-
- Assert.IsFalse(_set.Add(two), "'two' was already there");
- Assert.AreEqual(4, _set.Count, "object already in set");
- if (_set.IsReadOnly)
- Assert.Fail("Read-only set can be modified");
- }
- catch (NotSupportedException)
- {
- if (!_set.IsReadOnly)
- throw;
- }
- }
-
- [Test]
- public void AddAll()
- {
- List<string> addAll = new List<string>(3);
- addAll.Add("four");
- addAll.Add("five");
- addAll.Add("four");
-
- try
- {
- Assert.IsTrue(_set.AddAll(addAll), "should have modified set");
- Assert.AreEqual(5, _set.Count, "should have added one 'four' and 'five'");
-
- Assert.IsFalse(_set.AddAll(addAll), "all elements already in set");
- if (_set.IsReadOnly)
- Assert.Fail("Read-only set can be modified");
- }
- catch (NotSupportedException)
- {
- if (!_set.IsReadOnly)
- throw;
- }
- }
-
- [Test]
- public void Clear()
- {
- try
- {
- _set.Clear();
- Assert.AreEqual(0, _set.Count, "should have no items in ISet.");
-
- if (_set.IsReadOnly)
- Assert.Fail("Read-only set can be modified");
- }
- catch (NotSupportedException)
- {
- if (!_set.IsReadOnly)
- throw;
- }
- }
-
- [Test]
- public void Contains()
- {
- Assert.IsTrue(_set.Contains(one), "does contain one");
- Assert.IsFalse(_set.Contains("four"), "does not contain 'four'");
- }
-
- [Test]
- public void ContainsAll()
- {
- List<string> all = new List<string>(2);
- all.Add("one");
- all.Add("two");
-
- Assert.IsTrue(_set.ContainsAll(all), "should contain 'one' and 'two'");
-
- all.Add("not in there");
- Assert.IsFalse(_set.ContainsAll(all), "should not contain the just added 'not in there'");
- }
-
- [Test]
- public void ExclusiveOr()
- {
- ISet<string> a = CreateInstance(_aInitValues);
- ISet<string> b = CreateInstance(_bInitValues);
-
- ISet<string> ab = Set<string>.ExclusiveOr(a, b);
-
- Assert.AreEqual(3, ab.Count, "contains 3 elements - 'zero', 'one', and 'four'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
- Assert.IsTrue(ab.Contains("four"), "should contain 'four'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
-
- ISet<string> aNull = Set<string>.ExclusiveOr(a, null);
- Assert.AreEqual(_aInitValues.Count, aNull.Count, "count still same");
- Assert.IsTrue(aNull.ContainsAll(_aInitValues), "all A elements kept");
-
- ISet<string> bNull = Set<string>.ExclusiveOr(null, b);
- Assert.AreEqual(_bInitValues.Count, bNull.Count, "count still same");
- Assert.IsTrue(bNull.ContainsAll(_bInitValues), "all B elements kept");
-
- ISet<string> bothNull = Set<string>.ExclusiveOr(null, null);
- Assert.AreEqual(null, bothNull, "two null sets return null set");
- }
-
- [Test]
- public void Intersect()
- {
- ISet<string> a = CreateInstance(_aInitValues);
- ISet<string> b = CreateInstance(_bInitValues);
-
- ISet<string> ab = Set<string>.Intersect(a, b);
-
- Assert.AreEqual(2, ab.Count, "contains 2 elements - 'two', and 'three'");
- Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
- Assert.IsTrue(ab.Contains("three"), "should contain 'three'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
-
- ISet<string> aNull = Set<string>.Intersect(a, null);
- Assert.AreEqual(0, aNull.Count, "no elements intersected with null set");
-
- ISet<string> bNull = Set<string>.Intersect(null, b);
- Assert.AreEqual(0, bNull.Count, "no elements intersected with null set");
-
- ISet<string> bothNull = Set<string>.Intersect(null, null);
- Assert.AreEqual(null, bothNull, "null sets intersect as null set");
- }
-
- [Test]
- public void IsEmpty()
- {
- Assert.IsFalse(_set.IsEmpty, "set should have initial values");
-
- Assert.IsTrue(CreateInstance().IsEmpty, "new set is empty");
- }
-
- [Test]
- public void Minus()
- {
- ISet<string> a = CreateInstance(_aInitValues);
- ISet<string> b = CreateInstance(_bInitValues);
-
- ISet<string> ab = Set<string>.Minus(a, b);
-
- Assert.AreEqual(2, ab.Count, "contains 2 elements - 'zero', and 'one'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
-
- ISet<string> aNull = Set<string>.Minus(a, null);
- Assert.IsTrue(aNull.ContainsAll(_aInitValues), "should have removed no elements");
-
- ISet<string> bNull = Set<string>.Minus(null, b);
- Assert.AreEqual(null, bNull, "null set remained null");
-
- ISet<string> bothNull = Set<string>.Minus(null, null);
- Assert.AreEqual(null, bothNull, "both sets are null");
- }
-
- [Test]
- public void Remove()
- {
- try
- {
- Assert.IsTrue(_set.Remove(one), "should have removed 'one'");
- Assert.IsFalse(_set.Contains(one), "one should have been removed");
- Assert.AreEqual(2, _set.Count, "should be 2 items after one removed.");
-
- Assert.IsFalse(_set.Remove(one), "was already removed.");
- if (_set.IsReadOnly)
- Assert.Fail("Read-only set can be modified");
- }
- catch (NotSupportedException)
- {
- if (!_set.IsReadOnly)
- throw;
- }
- }
-
- [Test]
- public void RemoveAll()
- {
- List<string> all = new List<string>(2);
- all.Add(one);
- all.Add("not in there");
-
- try
- {
- Assert.IsTrue(_set.RemoveAll(all), "should have removed an element");
- Assert.AreEqual(2, _set.Count, "should be down to 2 elements.");
- Assert.IsFalse(_set.RemoveAll(all), "all of the elements already removed so set not modified.");
- if (_set.IsReadOnly)
- Assert.Fail("Read-only set can be modified");
- }
- catch (NotSupportedException)
- {
- if (!_set.IsReadOnly)
- throw;
- }
- }
-
- [Test]
- public void RetainAll()
- {
- List<string> retain = new List<string>(2);
- retain.Add(one);
- retain.Add("not in there");
-
- try
- {
- Assert.IsTrue(_set.RetainAll(retain), "set was modified");
- Assert.AreEqual(1, _set.Count, "only 1 element retained");
-
- Assert.IsFalse(_set.RetainAll(retain), "set was not modified");
- if (_set.IsReadOnly)
- Assert.Fail("Read-only set can be modified");
- }
- catch (NotSupportedException)
- {
- if (!_set.IsReadOnly)
- throw;
- }
- }
-
- [Test]
- public void Union()
- {
- ISet<string> a = CreateInstance(_aInitValues);
- ISet<string> b = CreateInstance(_bInitValues);
-
- ISet<string> ab = Set<string>.Union(a, b);
-
- Assert.AreEqual(5, ab.Count, "contains 5 elements - 'zero' through 'four'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
- Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
- Assert.IsTrue(ab.Contains("three"), "should contain 'three'");
- Assert.IsTrue(ab.Contains("four"), "should contain 'four'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
-
- ISet<string> aNull = Set<string>.Union(a, null);
- Assert.AreEqual(_aInitValues.Count, aNull.Count, "count not changed");
- Assert.IsTrue(aNull.ContainsAll(_aInitValues), "still contains all initial values");
-
- ISet<string> bNull = Set<string>.Union(null, b);
- Assert.AreEqual(_bInitValues.Count, bNull.Count, "count not changed");
- Assert.IsTrue(bNull.ContainsAll(_bInitValues), "still contains all initial values");
-
- ISet<string> bothNull = Set<string>.Union(null, null);
- Assert.AreEqual(null, bothNull, "two nulls intersect as null");
- }
-
- #endregion
-
- #region Iesi.Collection.ISet<string> Operator Tests
-
- [Test]
- public void ExclusiveOrOperator()
- {
- ISet<string> a = CreateInstance(_aInitValues);
- ISet<string> b = CreateInstance(_bInitValues);
-
- ISet<string> ab = (Set<string>) a ^ (Set<string>) b;
-
- Assert.AreEqual(3, ab.Count, "contains 3 elements - 'zero', 'one', and 'four'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
- Assert.IsTrue(ab.Contains("four"), "should contain 'four'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
- }
-
- [Test]
- public void IntersectOperator()
- {
- ISet<string> a = CreateInstance(_aInitValues);
- ISet<string> b = CreateInstance(_bInitValues);
-
- ISet<string> ab = (Set<string>) a & (Set<string>) b;
-
- Assert.AreEqual(2, ab.Count, "contains 2 elements - 'two', and 'three'");
- Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
- Assert.IsTrue(ab.Contains("three"), "should contain 'three'");
- }
-
- [Test]
- public void MinusOperator()
- {
- ISet<string> a = CreateInstance(_aInitValues);
- ISet<string> b = CreateInstance(_bInitValues);
-
- ISet<string> ab = (Set<string>) a - (Set<string>) b;
-
- Assert.AreEqual(2, ab.Count, "contains 2 elements - 'zero', and 'one'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
- }
-
- [Test]
- public void UnionOperator()
- {
- ISet<string> a = CreateInstance(_aInitValues);
- ISet<string> b = CreateInstance(_bInitValues);
-
- ISet<string> ab = (Set<string>) a | (Set<string>) b;
-
- Assert.AreEqual(5, ab.Count, "contains 5 elements - 'zero' through 'four'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
- Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
- Assert.IsTrue(ab.Contains("three"), "should contain 'three'");
- Assert.IsTrue(ab.Contains("four"), "should contain 'four'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
- }
-
- #endregion
-
- protected abstract ISet<string> CreateInstance();
-
- protected abstract ISet<string> CreateInstance(ICollection<string> init);
-
- protected abstract Type ExpectedType { get; }
- }
-}
View
69 src/Iesi.Collections.Test/Generic/SortedSetFixture.cs
@@ -1,69 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Iesi.Collections.Generic;
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test.Generic
-{
- /// <summary>
- /// Summary description for SortedSetFixture.
- /// </summary>
- [TestFixture]
- public class SortedSetFixture : GenericSetFixture
- {
- protected override ISet<string> CreateInstance()
- {
- return new SortedSet<string>();
- }
-
- protected override ISet<string> CreateInstance(ICollection<string> init)
- {
- return new SortedSet<string>(init);
- }
-
- protected override Type ExpectedType
- {
- get { return typeof(SortedSet<string>); }
- }
-
- [Test]
- public void OrderedEnumeration()
- {
- List<string> expectedOrder = new List<string>(3);
- expectedOrder.Add(one);
- expectedOrder.Add(two);
- expectedOrder.Add(three);
- expectedOrder.Sort();
-
- int index = 0;
- foreach (string str in _set)
- {
- Assert.AreEqual(str, expectedOrder[index], index.ToString() + " did not have same value");
- index++;
- }
- }
-
- [Test]
- public void OrderedCaseInsensitiveEnumeration()
- {
- ArrayList expectedOrder = new ArrayList(3);
- expectedOrder.Add("ONE");
- expectedOrder.Add("two");
- expectedOrder.Add("tHree");
-
- SortedSet<string> theSet = new SortedSet<string>(StringComparer.CurrentCultureIgnoreCase);
- foreach (string str in expectedOrder)
- theSet.Add(str);
-
- expectedOrder.Sort(StringComparer.CurrentCultureIgnoreCase);
-
- int index = 0;
- foreach (string str in theSet)
- {
- Assert.AreEqual(str, expectedOrder[index], index.ToString() + " did not have same value");
- index++;
- }
- }
- }
-}
View
50 src/Iesi.Collections.Test/HashedSetFixture.cs
@@ -1,50 +0,0 @@
-using System;
-using System.Collections;
-using System.IO;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Binary;
-
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test
-{
- /// <summary>
- /// Summary description for HashedSetFixture.
- /// </summary>
- [TestFixture]
- public class HashedSetFixture : SetFixture
- {
- protected override ISet CreateInstance()
- {
- return new HashedSet();
- }
-
- protected override ISet CreateInstance(ICollection init)
- {
- return new HashedSet(init);
- }
-
- protected override Type ExpectedType
- {
- get { return typeof(HashedSet); }
- }
-
- [Test]
- public void Serialization()
- {
- // serialize and then deserialize the ISet.
- Stream stream = new MemoryStream();
- IFormatter formatter = new BinaryFormatter();
- formatter.Serialize(stream, _set);
- stream.Position = 0;
-
- ISet desSet = (ISet) formatter.Deserialize(stream);
- stream.Close();
-
- Assert.AreEqual(3, desSet.Count, "should have des 3 items");
- Assert.IsTrue(desSet.Contains(one), "should contain one");
- Assert.IsTrue(desSet.Contains(two), "should contain two");
- Assert.IsTrue(desSet.Contains(three), "should contain three");
- }
- }
-}
View
29 src/Iesi.Collections.Test/HybridSetFixture.cs
@@ -1,29 +0,0 @@
-using System;
-using System.Collections;
-
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test
-{
- /// <summary>
- /// Summary description for HybridSetFixture.
- /// </summary>
- [TestFixture]
- public class HybridSetFixture : SetFixture
- {
- protected override ISet CreateInstance()
- {
- return new HybridSet();
- }
-
- protected override ISet CreateInstance(ICollection init)
- {
- return new HybridSet(init);
- }
-
- protected override Type ExpectedType
- {
- get { return typeof(HybridSet); }
- }
- }
-}
View
36 src/Iesi.Collections.Test/Iesi.Collections.Test.build
@@ -1,36 +0,0 @@
-<?xml version="1.0" ?>
-
-<project
- name="Iesi.Collections.Test"
- default="build"
- xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd"
->
-
- <property name="root.dir" value="../.." />
-
- <include buildfile="${root.dir}/build-common/common-project.xml" />
-
- <target name="init" depends="common.init">
-
- <property name="assembly.is-cls-compliant" value="false" />
- <property name="assembly.description" value="The Unit Tests for Iesi.Collections." />
- <property name="assembly.version" value="1.0.1.0" />
- <property name="assembly.version.informational" value="1.0" />
-
- <property name="clover.instrument" value="false" />
-
- <assemblyfileset id="project.references" basedir="${bin.dir}">
- <include name="System.dll" />
- <include name="System.XML.dll" />
- <include name="System.Data.dll" />
- <include name="Iesi.Collections.dll" />
- <include name="nunit.framework.dll"/>
- </assemblyfileset>
-
- </target>
-
- <target name="generate-assemblyinfo" depends="init common.generate-assemblyinfo" />
- <target name="build" depends="init generate-assemblyinfo common.compile-tests" />
- <target name="test" depends="init build common.run-tests" />
-
-</project>
View
121 src/Iesi.Collections.Test/Iesi.Collections.Test.csproj
@@ -1,121 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{58CE4584-31B9-4E74-A7FB-5D40BFAD0876}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Iesi.Collections.Test</RootNamespace>
- <AssemblyName>Iesi.Collections.Test</AssemblyName>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <OldToolsVersion>3.5</OldToolsVersion>
- <UpgradeBackupLocation>
- </UpgradeBackupLocation>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug-2.0\</OutputPath>
- <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
- <IntermediateOutputPath>obj\Debug-2.0\</IntermediateOutputPath>
- <DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release-2.0\</OutputPath>
- <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
- <IntermediateOutputPath>obj\Release-2.0\</IntermediateOutputPath>
- <DefineConstants>TRACE;NET_2_0</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="nunit.framework, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\lib\net\3.5\nunit.framework.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AssemblyInfo.cs" />
- <Compile Include="Generic\HashedSetFixture.cs" />
- <Compile Include="Generic\ImmutableSetFixture.cs" />
- <Compile Include="Generic\OrderedSetFixture.cs" />
- <Compile Include="Generic\SetFixture.cs" />
- <Compile Include="Generic\SortedSetFixture.cs" />
- <Compile Include="HashedSetFixture.cs" />
- <Compile Include="HybridSetFixture.cs" />
- <Compile Include="ListSetFixture.cs" />
- <Compile Include="SetFixture.cs" />
- <Compile Include="SortedSetFixture.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="Iesi.Collections.Test.build" />
- <None Include="Iesi.Collections.Test.nunit" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Iesi.Collections\Iesi.Collections.csproj">
- <Project>{4C251E3E-6EA1-4A51-BBCB-F9C42AE55344}</Project>
- <Name>Iesi.Collections</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
- </ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
View
9 src/Iesi.Collections.Test/Iesi.Collections.Test.nunit
@@ -1,9 +0,0 @@
-<NUnitProject>
- <Settings activeconfig="Debug" />
- <Config name="Debug" appbase="bin\Debug" binpathtype="Auto">
- <assembly path="Iesi.Collections.Test.dll" />
- </Config>
- <Config name="Release" appbase="bin\Release" binpathtype="Auto">
- <assembly path="Iesi.Collections.Test.dll" />
- </Config>
-</NUnitProject>
View
29 src/Iesi.Collections.Test/ListSetFixture.cs
@@ -1,29 +0,0 @@
-using System;
-using System.Collections;
-
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test
-{
- /// <summary>
- /// Summary description for ListSetFixture.
- /// </summary>
- [TestFixture]
- public class ListSetFixture : SetFixture
- {
- protected override ISet CreateInstance()
- {
- return new ListSet();
- }
-
- protected override ISet CreateInstance(ICollection init)
- {
- return new ListSet(init);
- }
-
- protected override Type ExpectedType
- {
- get { return typeof(ListSet); }
- }
- }
-}
View
395 src/Iesi.Collections.Test/SetFixture.cs
@@ -1,395 +0,0 @@
-using System;
-using System.Collections;
-
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test
-{
- /// <summary>
- /// Summary description for SetFixture.
- /// </summary>
- public abstract class SetFixture
- {
- private IList _aInitValues;
- private IList _bInitValues;
- protected ISet _set;
-
- public static object one = "one";
- public static object two = "two";
- public static object three = "three";
-
- [SetUp]
- public virtual void SetUp()
- {
- _aInitValues = new ArrayList();
- _aInitValues.Add("zero");
- _aInitValues.Add("one");
- _aInitValues.Add("two");
- _aInitValues.Add("three");
-
- _bInitValues = new ArrayList();
- _bInitValues.Add("two");
- _bInitValues.Add("three");
- _bInitValues.Add("four");
-
- _set = CreateInstance();
- _set.Add(one);
- _set.Add(two);
- _set.Add(three);
- }
-
- #region System.IClonable Member Tests
-
- [Test]
- public void Clone()
- {
- ISet clonedSet = (ISet) _set.Clone();
-
- Assert.AreEqual(ExpectedType, clonedSet.GetType(), "cloned set should be the same type");
- Assert.AreEqual(_set.Count, clonedSet.Count, "set and cloned version should be same");
-
- clonedSet.Add("not in original");
- Assert.IsFalse(_set.Count == clonedSet.Count, "adding to clone should not add to original.");
-
- foreach (object obj in _set)
- {
- Assert.IsTrue(clonedSet.Contains(obj), "cloned set should have same objects as original set.");
- }
- }
-
- #endregion
-
- #region System.Collections.ICollection Member Tests
-
- [Test]
- public void CopyTo()
- {
- object[] dest = new object[3];
- _set.CopyTo(dest, 0);
-
- int count = 0;
-
- foreach (object obj in dest)
- {
- Assert.IsTrue(_set.Contains(obj), "set should contain the object in the array");
- count++;
- }
-
- Assert.AreEqual(3, count, "should have 3 items in array");
- }
-
- [Test]
- public void Count()
- {
- Assert.AreEqual(3, _set.Count, "should be 3 items");
- Assert.AreEqual(0, CreateInstance().Count, "new set should have nothing in it.");
- }
-
- #endregion
-
- #region Iesi.Collections.ISet Constructor Tests
-
- [Test]
- public void CtorWithDefaults()
- {
- ArrayList init = new ArrayList(3);
- init.Add("one");
- init.Add("two");
- init.Add("three");
-
- ISet theSet = CreateInstance(init);
-
- Assert.AreEqual(3, init.Count, "3 items in set");
-
- int index = 0;
- foreach (object obj in init)
- {
- Assert.IsTrue(theSet.Contains(obj), "set should contain obj at index = " + index.ToString());
- index++;
- }
- }
-
- #endregion
-
- #region Iesi.Collections.ISet Member Tests
-
- [Test]
- public void Add()
- {
- Assert.IsTrue(_set.Add("four"), "should have added 'four'");
- Assert.AreEqual(4, _set.Count, "should have added 'four'");
-
- Assert.IsFalse(_set.Add(two), "'two' was already there");
- Assert.AreEqual(4, _set.Count, "object already in set");
- }
-
- [Test]
- public void AddAll()
- {
- ArrayList addAll = new ArrayList(3);
- addAll.Add("four");
- addAll.Add("five");
- addAll.Add("four");
-
- Assert.IsTrue(_set.AddAll(addAll), "should have modified set");
- Assert.AreEqual(5, _set.Count, "should have added one 'four' and 'five'");
-
- Assert.IsFalse(_set.AddAll(addAll), "all elements already in set");
- }
-
- [Test]
- public void Clear()
- {
- _set.Clear();
- Assert.AreEqual(0, _set.Count, "should have no items in ISet.");
- }
-
- [Test]
- public void Contains()
- {
- Assert.IsTrue(_set.Contains(one), "does contain one");
- Assert.IsFalse(_set.Contains("four"), "does not contain 'four'");
- }
-
- [Test]
- public void ContainsAll()
- {
- ArrayList all = new ArrayList(2);
- all.Add("one");
- all.Add("two");
-
- Assert.IsTrue(_set.ContainsAll(all), "should contain 'one' and 'two'");
-
- all.Add("not in there");
- Assert.IsFalse(_set.ContainsAll(all), "should not contain the just added 'not in there'");
- }
-
- [Test]
- public void ExclusiveOr()
- {
- ISet a = CreateInstance(_aInitValues);
- ISet b = CreateInstance(_bInitValues);
-
- ISet ab = Set.ExclusiveOr(a, b);
-
- Assert.AreEqual(3, ab.Count, "contains 3 elements - 'zero', 'one', and 'four'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
- Assert.IsTrue(ab.Contains("four"), "should contain 'four'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
-
- ISet aNull = Set.ExclusiveOr(a, null);
- Assert.AreEqual(_aInitValues.Count, aNull.Count, "count still same");
- Assert.IsTrue(aNull.ContainsAll(_aInitValues), "all A elements kept");
-
- ISet bNull = Set.ExclusiveOr(null, b);
- Assert.AreEqual(_bInitValues.Count, bNull.Count, "count still same");
- Assert.IsTrue(bNull.ContainsAll(_bInitValues), "all B elements kept");
-
- ISet bothNull = Set.ExclusiveOr(null, null);
- Assert.AreEqual(null, bothNull, "two null sets return null set");
- }
-
- [Test]
- public void Intersect()
- {
- ISet a = CreateInstance(_aInitValues);
- ISet b = CreateInstance(_bInitValues);
-
- ISet ab = Set.Intersect(a, b);
-
- Assert.AreEqual(2, ab.Count, "contains 2 elements - 'two', and 'three'");
- Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
- Assert.IsTrue(ab.Contains("three"), "should contain 'three'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
-
- ISet aNull = Set.Intersect(a, null);
- Assert.AreEqual(0, aNull.Count, "no elements intersected with null set");
-
- ISet bNull = Set.Intersect(null, b);
- Assert.AreEqual(0, bNull.Count, "no elements intersected with null set");
-
- ISet bothNull = Set.Intersect(null, null);
- Assert.AreEqual(null, bothNull, "null sets intersect as null set");
- }
-
- [Test]
- public void IsEmpty()
- {
- Assert.IsFalse(_set.IsEmpty, "set should have initial values");
-
- Assert.IsTrue(CreateInstance().IsEmpty, "new set is empty");
- }
-
- [Test]
- public void Minus()
- {
- ISet a = CreateInstance(_aInitValues);
- ISet b = CreateInstance(_bInitValues);
-
- ISet ab = Set.Minus(a, b);
-
- Assert.AreEqual(2, ab.Count, "contains 2 elements - 'zero', and 'one'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
-
- ISet aNull = Set.Minus(a, null);
- Assert.IsTrue(aNull.ContainsAll(_aInitValues), "should have removed no elements");
-
- ISet bNull = Set.Minus(null, b);
- Assert.AreEqual(null, bNull, "null set remained null");
-
- ISet bothNull = Set.Minus(null, null);
- Assert.AreEqual(null, bothNull, "both sets are null");
- }
-
- [Test]
- public void Remove()
- {
- Assert.IsTrue(_set.Remove(one), "should have removed 'one'");
- Assert.IsFalse(_set.Contains(one), "one should have been removed");
- Assert.AreEqual(2, _set.Count, "should be 2 items after one removed.");
-
- Assert.IsFalse(_set.Remove(one), "was already removed.");
- }
-
- [Test]
- public void RemoveAll()
- {
- ArrayList all = new ArrayList(2);
- all.Add(one);
- all.Add("not in there");
-
- Assert.IsTrue(_set.RemoveAll(all), "should have removed an element");
- Assert.AreEqual(2, _set.Count, "should be down to 2 elements.");
- Assert.IsFalse(_set.RemoveAll(all), "all of the elements already removed so set not modified.");
- }
-
- [Test]
- public void RetainAll()
- {
- ArrayList retain = new ArrayList(2);
- retain.Add(one);
- retain.Add("not in there");
-
- Assert.IsTrue(_set.RetainAll(retain), "set was modified");
- Assert.AreEqual(1, _set.Count, "only 1 element retained");
-
- Assert.IsFalse(_set.RetainAll(retain), "set was not modified");
- }
-
- [Test]
- public void Union()
- {
- ISet a = CreateInstance(_aInitValues);
- ISet b = CreateInstance(_bInitValues);
-
- ISet ab = Set.Union(a, b);
-
- Assert.AreEqual(5, ab.Count, "contains 5 elements - 'zero' through 'four'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
- Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
- Assert.IsTrue(ab.Contains("three"), "should contain 'three'");
- Assert.IsTrue(ab.Contains("four"), "should contain 'four'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
-
- ISet aNull = Set.Union(a, null);
- Assert.AreEqual(_aInitValues.Count, aNull.Count, "count not changed");
- Assert.IsTrue(aNull.ContainsAll(_aInitValues), "still contains all initial values");
-
- ISet bNull = Set.Union(null, b);
- Assert.AreEqual(_bInitValues.Count, bNull.Count, "count not changed");
- Assert.IsTrue(bNull.ContainsAll(_bInitValues), "still contains all initial values");
-
- ISet bothNull = Set.Union(null, null);
- Assert.AreEqual(null, bothNull, "two nulls intersect as null");
- }
-
- #endregion
-
- #region Iesi.Collection.ISet Operator Tests
-
- [Test]
- public void ExclusiveOrOperator()
- {
- ISet a = CreateInstance(_aInitValues);
- ISet b = CreateInstance(_bInitValues);
-
- ISet ab = (Set) a ^ (Set) b;
-
- Assert.AreEqual(3, ab.Count, "contains 3 elements - 'zero', 'one', and 'four'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
- Assert.IsTrue(ab.Contains("four"), "should contain 'four'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
- }
-
- [Test]
- public void IntersectOperator()
- {
- ISet a = CreateInstance(_aInitValues);
- ISet b = CreateInstance(_bInitValues);
-
- ISet ab = (Set) a & (Set) b;
-
- Assert.AreEqual(2, ab.Count, "contains 2 elements - 'two', and 'three'");
- Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
- Assert.IsTrue(ab.Contains("three"), "should contain 'three'");
- }
-
- [Test]
- public void MinusOperator()
- {
- ISet a = CreateInstance(_aInitValues);
- ISet b = CreateInstance(_bInitValues);
-
- ISet ab = (Set) a - (Set) b;
-
- Assert.AreEqual(2, ab.Count, "contains 2 elements - 'zero', and 'one'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
- }
-
- [Test]
- public void UnionOperator()
- {
- ISet a = CreateInstance(_aInitValues);
- ISet b = CreateInstance(_bInitValues);
-
- ISet ab = (Set) a | (Set) b;
-
- Assert.AreEqual(5, ab.Count, "contains 5 elements - 'zero' through 'four'");
- Assert.IsTrue(ab.Contains("zero"), "should contain 'zero'");
- Assert.IsTrue(ab.Contains("one"), "should contain 'one'");
- Assert.IsTrue(ab.Contains("two"), "should contain 'two'");
- Assert.IsTrue(ab.Contains("three"), "should contain 'three'");
- Assert.IsTrue(ab.Contains("four"), "should contain 'four'");
-
- Assert.IsTrue(a.ContainsAll(_aInitValues), "should not have modified a");
- Assert.IsTrue(b.ContainsAll(_bInitValues), "should not have modified b");
- }
-
- #endregion
-
- protected abstract ISet CreateInstance();
-
- protected abstract ISet CreateInstance(ICollection init);
-
- protected abstract Type ExpectedType { get; }
- }
-}
View
66 src/Iesi.Collections.Test/SortedSetFixture.cs
@@ -1,66 +0,0 @@
-using System;
-using System.Collections;
-
-using NUnit.Framework;
-
-namespace Iesi.Collections.Test
-{
- /// <summary>
- /// Summary description for SortedSetFixture.
- /// </summary>
- [TestFixture]
- public class SortedSetFixture : SetFixture
- {
- protected override ISet CreateInstance()
- {
- return new SortedSet();
- }
-
- protected override ISet CreateInstance(ICollection init)
- {
- return new SortedSet(init);
- }
-
- protected override Type ExpectedType
- {
- get { return typeof(SortedSet); }
- }
-
- [Test]
- public void OrderedEnumeration()
- {
- ArrayList expectedOrder = new ArrayList(3);
- expectedOrder.Add(one);
- expectedOrder.Add(two);
- expectedOrder.Add(three);
- expectedOrder.Sort();
-
- int index = 0;
- foreach (object obj in _set)
- {
- Assert.AreEqual(obj, expectedOrder[index], index.ToString() + " did not have same value");
- index++;
- }
- }
-
- [Test]
- public void OrderedCaseInsensitiveEnumeration()
- {
- ArrayList expectedOrder = new ArrayList(3);
- expectedOrder.Add("ONE");
- expectedOrder.Add("two");
- expectedOrder.Add("tHree");
-
- SortedSet theSet = new SortedSet(expectedOrder, new CaseInsensitiveComparer());
-
- expectedOrder.Sort(new CaseInsensitiveComparer());
-
- int index = 0;
- foreach (object obj in theSet)
- {
- Assert.AreEqual(obj, expectedOrder[index], index.ToString() + " did not have same value");
- index++;
- }
- }
- }
-}
View
24 src/Iesi.Collections.sln
@@ -1,24 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iesi.Collections", "Iesi.Collections\Iesi.Collections.csproj", "{4C251E3E-6EA1-4A51-BBCB-F9C42AE55344}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iesi.Collections.Test", "Iesi.Collections.Test\Iesi.Collections.Test.csproj", "{58CE4584-31B9-4E74-A7FB-5D40BFAD0876}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4C251E3E-6EA1-4A51-BBCB-F9C42AE55344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4C251E3E-6EA1-4A51-BBCB-F9C42AE55344}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4C251E3E-6EA1-4A51-BBCB-F9C42AE55344}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4C251E3E-6EA1-4A51-BBCB-F9C42AE55344}.Release|Any CPU.Build.0 = Release|Any CPU
- {58CE4584-31B9-4E74-A7FB-5D40BFAD0876}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {58CE4584-31B9-4E74-A7FB-5D40BFAD0876}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {58CE4584-31B9-4E74-A7FB-5D40BFAD0876}.Release|Any CPU.ActiveCfg = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
View
219 src/Iesi.Collections/DictionarySet.cs
@@ -1,219 +0,0 @@
-/* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
-using System;
-using System.Collections;
-
-namespace Iesi.Collections
-{
- /// <summary>
- /// <p><c>DictionarySet</c> is an abstract class that supports the creation of new <c>Set</c>
- /// types where the underlying data store is an <c>IDictionary</c> instance.</p>
- ///
- /// <p>You can use any object that implements the <c>IDictionary</c> interface to hold set data.
- /// You can define your own, or you can use one of the objects provided in the Framework.
- /// The type of <c>IDictionary</c> you choose will affect both the performance and the behavior
- /// of the <c>Set</c> using it. </p>
- ///
- /// <p>To make a <c>Set</c> typed based on your own <c>IDictionary</c>, simply derive a
- /// new class with a constructor that takes no parameters. Some <c>Set</c> implmentations
- /// cannot be defined with a default constructor. If this is the case for your class,
- /// you will need to override <c>Clone()</c> as well.</p>
- ///
- /// <p>It is also standard practice that at least one of your constructors takes an <c>ICollection</c> or
- /// an <c>ISet</c> as an argument.</p>
- /// </summary>
- [Serializable]
- public abstract class DictionarySet : Set
- {
- /// <summary>
- /// Provides the storage for elements in the <c>Set</c>, stored as the key-set
- /// of the <c>IDictionary</c> object. Set this object in the constructor
- /// if you create your own <c>Set</c> class.
- /// </summary>
- protected IDictionary InternalDictionary = null;
-
- private static readonly object PlaceholderObject = new object();
-
- /// <summary>
- /// The placeholder object used as the value for the <c>IDictionary</c> instance.
- /// </summary>
- /// <remarks>
- /// There is a single instance of this object globally, used for all <c>Sets</c>.
- /// </remarks>
- protected object Placeholder
- {
- get { return PlaceholderObject; }
- }
-
-
- /// <summary>
- /// Adds the specified element to this set if it is not already present.
- /// </summary>
- /// <param name="o">The object to add to the set.</param>
- /// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
- public override bool Add(object o)
- {
- if (InternalDictionary[o] != null)
- return false;
- else
- {
- //The object we are adding is just a placeholder. The thing we are
- //really concerned with is 'o', the key.
- InternalDictionary.Add(o, PlaceholderObject);
- return true;
- }
- }
-
- /// <summary>
- /// Adds all the elements in the specified collection to the set if they are not already present.
- /// </summary>
- /// <param name="c">A collection of objects to add to the set.</param>
- /// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
- public override bool AddAll(ICollection c)
- {
- bool changed = false;
- foreach (object o in c)
- changed |= this.Add(o);
- return changed;
- }
-
- /// <summary>
- /// Removes all objects from the set.
- /// </summary>
- public override void Clear()
- {
- InternalDictionary.Clear();
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if this set contains the specified element.
- /// </summary>
- /// <param name="o">The element to look for.</param>
- /// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
- public override bool Contains(object o)
- {
- return InternalDictionary[o] != null;
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
- /// </summary>
- /// <param name="c">A collection of objects.</param>
- /// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
- public override bool ContainsAll(ICollection c)
- {
- foreach (object o in c)
- {
- if (!this.Contains(o))
- return false;
- }
- return true;
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if this set contains no elements.
- /// </summary>
- public override bool IsEmpty
- {
- get { return InternalDictionary.Count == 0; }
- }
-
- /// <summary>
- /// Removes the specified element from the set.
- /// </summary>
- /// <param name="o">The element to be removed.</param>
- /// <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns>
- public override bool Remove(object o)
- {
- bool contained = this.Contains(o);
- if (contained)
- {
- InternalDictionary.Remove(o);
- }
- return contained;
- }
-
- /// <summary>
- /// Remove all the specified elements from this set, if they exist in this set.
- /// </summary>
- /// <param name="c">A collection of elements to remove.</param>
- /// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
- public override bool RemoveAll(ICollection c)
- {
- bool changed = false;
- foreach (object o in c)
- changed |= this.Remove(o);
- return changed;
- }
-
- /// <summary>
- /// Retains only the elements in this set that are contained in the specified collection.
- /// </summary>
- /// <param name="c">Collection that defines the set of elements to be retained.</param>
- /// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
- public override bool RetainAll(ICollection c)
- {
- //Put data from C into a set so we can use the Contains() method.
- Set cSet = new HybridSet(c);
-
- //We are going to build a set of elements to remove.
- Set removeSet = new HybridSet();
-
- foreach (object o in this)
- {
- //If C does not contain O, then we need to remove O from our
- //set. We can't do this while iterating through our set, so
- //we put it into RemoveSet for later.
- if (!cSet.Contains(o))
- removeSet.Add(o);
- }
-
- return this.RemoveAll(removeSet);
- }
-
-
- /// <summary>
- /// Copies the elements in the <c>Set</c> to an array. The type of array needs
- /// to be compatible with the objects in the <c>Set</c>, obviously.
- /// </summary>
- /// <param name="array">An array that will be the target of the copy operation.</param>
- /// <param name="index">The zero-based index where copying will start.</param>
- public override void CopyTo(Array array, int index)
- {
- InternalDictionary.Keys.CopyTo(array, index);
- }
-
- /// <summary>
- /// The number of elements contained in this collection.
- /// </summary>
- public override int Count
- {
- get { return InternalDictionary.Count; }
- }
-
- /// <summary>
- /// None of the objects based on <c>DictionarySet</c> are synchronized. Use the
- /// <c>SyncRoot</c> property instead.
- /// </summary>
- public override bool IsSynchronized
- {
- get { return false; }
- }
-
- /// <summary>
- /// Returns an object that can be used to synchronize the <c>Set</c> between threads.
- /// </summary>
- public override object SyncRoot
- {
- get { return InternalDictionary.SyncRoot; }
- }
-
- /// <summary>
- /// Gets an enumerator for the elements in the <c>Set</c>.
- /// </summary>
- /// <returns>An <c>IEnumerator</c> over the elements in the <c>Set</c>.</returns>
- public override IEnumerator GetEnumerator()
- {
- return InternalDictionary.Keys.GetEnumerator();
- }
- }
-}
View
249 src/Iesi.Collections/Generic/DictionarySet.cs
@@ -1,249 +0,0 @@
-/* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Iesi.Collections.Generic
-{
- /// <summary>
- /// <p><c>DictionarySet</c> is an abstract class that supports the creation of new <c>Set</c>
- /// types where the underlying data store is an <c>IDictionary</c> instance.</p>
- ///
- /// <p>You can use any object that implements the <c>IDictionary</c> interface to hold set data.
- /// You can define your own, or you can use one of the objects provided in the Framework.
- /// The type of <c>IDictionary</c> you choose will affect both the performance and the behavior
- /// of the <c>Set</c> using it. </p>
- ///
- /// <p>To make a <c>Set</c> typed based on your own <c>IDictionary</c>, simply derive a
- /// new class with a constructor that takes no parameters. Some <c>Set</c> implmentations
- /// cannot be defined with a default constructor. If this is the case for your class,
- /// you will need to override <c>Clone()</c> as well.</p>
- ///
- /// <p>It is also standard practice that at least one of your constructors takes an <c>ICollection</c> or
- /// an <c>ISet</c> as an argument.</p>
- /// </summary>
- [Serializable]
- public abstract class DictionarySet<T> : Set<T>
- {
- /// <summary>
- /// Provides the storage for elements in the <c>Set</c>, stored as the key-set
- /// of the <c>IDictionary</c> object. Set this object in the constructor
- /// if you create your own <c>Set</c> class.
- /// </summary>
- protected IDictionary<T, object> InternalDictionary = null;
-
- private static readonly object PlaceholderObject = new object();
-
- /// <summary>
- /// The placeholder object used as the value for the <c>IDictionary</c> instance.
- /// </summary>
- /// <remarks>
- /// There is a single instance of this object globally, used for all <c>Sets</c>.
- /// </remarks>
- protected object Placeholder
- {
- get { return PlaceholderObject; }
- }
-
-
- /// <summary>
- /// Adds the specified element to this set if it is not already present.
- /// </summary>
- /// <param name="o">The <typeparamref name="T"/> to add to the set.</param>
- /// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
- public override bool Add(T o)
- {
- if (InternalDictionary.ContainsKey(o))
- {
- return false;
- }
- else
- {
- //The object we are adding is just a placeholder. The thing we are
- //really concerned with is 'o', the key.
- InternalDictionary.Add(o, PlaceholderObject);
- return true;
- }
- }
-
- /// <summary>
- /// Adds all the elements in the specified collection to the set if they are not already present.
- /// </summary>
- /// <param name="c">A collection of objects to add to the set.</param>
- /// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
- public override bool AddAll(ICollection<T> c)
- {
- bool changed = false;
- foreach (T o in c)
- {
- changed |= this.Add(o);
- }
- return changed;
- }
-
- /// <summary>
- /// Removes all objects from the set.
- /// </summary>
- public override void Clear()
- {
- InternalDictionary.Clear();
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if this set contains the specified element.
- /// </summary>
- /// <param name="o">The element to look for.</param>
- /// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
- public override bool Contains(T o)
- {
- return InternalDictionary.ContainsKey(o);
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
- /// </summary>
- /// <param name="c">A collection of objects.</param>
- /// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
- public override bool ContainsAll(ICollection<T> c)
- {
- foreach (T o in c)
- {
- if (!this.Contains(o))
- {
- return false;
- }
- }
- return true;
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if this set contains no elements.
- /// </summary>
- public override bool IsEmpty
- {
- get { return InternalDictionary.Count == 0; }
- }
-
- /// <summary>
- /// Removes the specified element from the set.
- /// </summary>
- /// <param name="o">The element to be removed.</param>
- /// <returns><see langword="true" /> if the set contained the specified element, <see langword="false" /> otherwise.</returns>
- public override bool Remove(T o)
- {
- bool contained = this.Contains(o);
- if (contained)
- {
- InternalDictionary.Remove(o);
- }
- return contained;
- }
-
- /// <summary>
- /// Remove all the specified elements from this set, if they exist in this set.
- /// </summary>
- /// <param name="c">A collection of elements to remove.</param>
- /// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
- public override bool RemoveAll(ICollection<T> c)
- {
- bool changed = false;
- foreach (T o in c)
- {
- changed |= this.Remove(o);
- }
- return changed;
- }
-
- /// <summary>
- /// Retains only the elements in this set that are contained in the specified collection.
- /// </summary>
- /// <param name="c">Collection that defines the set of elements to be retained.</param>
- /// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
- public override bool RetainAll(ICollection<T> c)
- {
- //Put data from C into a set so we can use the Contains() method.
- Set<T> cSet = new HashedSet<T>(c);
-
- //We are going to build a set of elements to remove.
- Set<T> removeSet = new HashedSet<T>();
-
- foreach (T o in this)
- {
- //If C does not contain O, then we need to remove O from our
- //set. We can't do this while iterating through our set, so
- //we put it into RemoveSet for later.
- if (!cSet.Contains(o))
- removeSet.Add(o);
- }
-
- return this.RemoveAll(removeSet);
- }
-
-
- /// <summary>
- /// Copies the elements in the <c>Set</c> to an array of T. The type of array needs
- /// to be compatible with the objects in the <c>Set</c>, obviously.
- /// </summary>
- /// <param name="array">An array that will be the target of the copy operation.</param>
- /// <param name="index">The zero-based index where copying will start.</param>
- public override void CopyTo(T[] array, int index)
- {
- InternalDictionary.Keys.CopyTo(array, index);
- }
-
- /// <summary>
- /// The number of elements contained in this collection.
- /// </summary>
- public override int Count
- {
- get { return InternalDictionary.Count; }
- }
-
- /// <summary>
- /// None of the objects based on <c>DictionarySet</c> are synchronized. Use the
- /// <c>SyncRoot</c> property instead.
- /// </summary>
- public override bool IsSynchronized
- {
- get { return false; }
- }
-
- /// <summary>
- /// Returns an object that can be used to synchronize the <c>Set</c> between threads.
- /// </summary>
- public override object SyncRoot
- {
- get { return ((ICollection) InternalDictionary).SyncRoot; }
- }
-
- /// <summary>
- /// Gets an enumerator for the elements in the <c>Set</c>.
- /// </summary>
- /// <returns>An <c>IEnumerator</c> over the elements in the <c>Set</c>.</returns>
- public override IEnumerator<T> GetEnumerator()
- {
- return InternalDictionary.Keys.GetEnumerator();
- }
-
- /// <summary>
- /// Indicates wether the <c>Set</c> is read-only or not
- /// </summary>
- public override bool IsReadOnly
- {
- get { return InternalDictionary.IsReadOnly; }
- }
-
- /// <summary>
- /// Copies the elements in the <c>Set</c> to an array. The type of array needs
- /// to be compatible with the objects in the <c>Set</c>, obviously. Needed for
- /// non-generic ISet methods implementation
- /// </summary>
- /// <param name="array">An array that will be the target of the copy operation.</param>
- /// <param name="index">The zero-based index where copying will start.</param>
- protected override void NonGenericCopyTo(Array array, int index)
- {
- ((ICollection) InternalDictionary.Keys).CopyTo(array, index);
- }
- }
-}
View
33 src/Iesi.Collections/Generic/HashedSet.cs
@@ -1,33 +0,0 @@
-/* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
-using System;
-using System.Collections.Generic;
-
-namespace Iesi.Collections.Generic
-{
- /// <summary>
- /// Implements a <c>Set</c> based on a Dictionary (which is equivalent of
- /// non-genric <c>HashTable</c>) This will give the best lookup, add, and remove
- /// performance for very large data-sets, but iteration will occur in no particular order.
- /// </summary>
- [Serializable]
- public class HashedSet<T> : DictionarySet<T>
- {
- /// <summary>
- /// Creates a new set instance based on a Dictinary.
- /// </summary>
- public HashedSet()
- {
- InternalDictionary = new Dictionary<T, object>();
- }
-
- /// <summary>
- /// Creates a new set instance based on a Dictinary and
- /// initializes it based on a collection of elements.
- /// </summary>
- /// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
- public HashedSet(ICollection<T> initialValues) : this()
- {
- this.AddAll(initialValues);
- }
- }
-}
View
139 src/Iesi.Collections/Generic/ISet.cs
@@ -1,139 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Iesi.Collections.Generic
-{
- /// <summary>
- /// <p>A collection that contains no duplicate elements. This interface models the mathematical
- /// <c>Set</c> abstraction.
- /// The order of elements in a set is dependant on (a)the data-structure implementation, and
- /// (b)the implementation of the various <c>Set</c> methods, and thus is not guaranteed.</p>
- ///
- /// <p>None of the <c>Set</c> implementations in this library are guranteed to be thread-safe
- /// in any way unless wrapped in a <c>SynchronizedSet</c>.</p>
- ///
- /// <p>The following table summarizes the binary operators that are supported by the <c>Set</c> class.</p>
- /// <list type="table">
- /// <listheader>
- /// <term>Operation</term>
- /// <term>Description</term>
- /// <term>Method</term>
- /// </listheader>
- /// <item>
- /// <term>Union (OR)</term>
- /// <term>Element included in result if it exists in either <c>A</c> OR <c>B</c>.</term>
- /// <term><c>Union()</c></term>
- /// </item>
- /// <item>
- /// <term>Intersection (AND)</term>
- /// <term>Element included in result if it exists in both <c>A</c> AND <c>B</c>.</term>
- /// <term><c>InterSect()</c></term>
- /// </item>
- /// <item>
- /// <term>Exclusive Or (XOR)</term>
- /// <term>Element included in result if it exists in one, but not both, of <c>A</c> and <c>B</c>.</term>
- /// <term><c>ExclusiveOr()</c></term>
- /// </item>
- /// <item>
- /// <term>Minus (n/a)</term>
- /// <term>Take all the elements in <c>A</c>. Now, if any of them exist in <c>B</c>, remove
- /// them. Note that unlike the other operators, <c>A - B</c> is not the same as <c>B - A</c>.</term>
- /// <term><c>Minus()</c></term>
- /// </item>
- /// </list>
- /// </summary>
- public interface ISet<T> : ICollection<T>, IEnumerable<T>, IEnumerable, ICloneable
- {
- // Clear is declared in ICollection<T>, but not in ICollection
- // void Clear();
-
- // Remove is declared in ICollection<T>, but not in ICollection
- // bool Remove(T o);
-
- // Contains is declared in ICollection<T>, but not in ICollection
- // bool Contains(T o);
-
- /// <summary>
- /// Performs a "union" of the two sets, where all the elements
- /// in both sets are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>.
- /// Neither this set nor the input set are modified during the operation. The return value
- /// is a <c>Clone()</c> of this set with the extra elements added in.
- /// </summary>
- /// <param name="a">A collection of elements.</param>
- /// <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection.
- /// Neither of the input objects is modified by the union.</returns>
- ISet<T> Union(ISet<T> a);
-
- /// <summary>
- /// Performs an "intersection" of the two sets, where only the elements
- /// that are present in both sets remain. That is, the element is included if it exists in
- /// both sets. The <c>Intersect()</c> operation does not modify the input sets. It returns
- /// a <c>Clone()</c> of this set with the appropriate elements removed.
- /// </summary>
- /// <param name="a">A set of elements.</param>
- /// <returns>The intersection of this set with <c>a</c>.</returns>
- ISet<T> Intersect(ISet<T> a);
-
- /// <summary>
- /// Performs a "minus" of set <c>b</c> from set <c>a</c>. This returns a set of all
- /// the elements in set <c>a</c>, removing the elements that are also in set <c>b</c>.
- /// The original sets are not modified during this operation. The result set is a <c>Clone()</c>
- /// of this <c>Set</c> containing the elements from the operation.
- /// </summary>
- /// <param name="a">A set of elements.</param>
- /// <returns>A set containing the elements from this set with the elements in <c>a</c> removed.</returns>
- ISet<T> Minus(ISet<T> a);
-
- /// <summary>
- /// Performs an "exclusive-or" of the two sets, keeping only the elements that
- /// are in one of the sets, but not in both. The original sets are not modified
- /// during this operation. The result set is a <c>Clone()</c> of this set containing
- /// the elements from the exclusive-or operation.
- /// </summary>
- /// <param name="a">A set of elements.</param>
- /// <returns>A set containing the result of <c>a ^ b</c>.</returns>
- ISet<T> ExclusiveOr(ISet<T> a);
-
- /// <summary>
- /// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
- /// </summary>
- /// <param name="c">A collection of objects.</param>
- /// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
- bool ContainsAll(ICollection<T> c);
-
- /// <summary>
- /// Returns <see langword="true" /> if this set contains no elements.
- /// </summary>
- bool IsEmpty { get; }
-
- /// <summary>
- /// Adds the specified element to this set if it is not already present.
- /// </summary>
- /// <param name="o">The object to add to the set.</param>
- /// <returns><see langword="true" /> is the object was added, <see langword="false" /> if it was already present.</returns>
- new bool Add(T o);
-
- /// <summary>
- /// Adds all the elements in the specified collection to the set if they are not already present.
- /// </summary>
- /// <param name="c">A collection of objects to add to the set.</param>
- /// <returns><see langword="true" /> is the set changed as a result of this operation, <see langword="false" /> if not.</returns>
- bool AddAll(ICollection<T> c);
-
- /// <summary>
- /// Remove all the specified elements from this set, if they exist in this set.
- /// </summary>
- /// <param name="c">A collection of elements to remove.</param>
- /// <returns><see langword="true" /> if the set was modified as a result of this operation.</returns>
- bool RemoveAll(ICollection<T> c);
-
-
- /// <summary>
- /// Retains only the elements in this set that are contained in the specified collection.
- /// </summary>
- /// <param name="c">Collection that defines the set of elements to be retained.</param>
- /// <returns><see langword="true" /> if this set changed as a result of this operation.</returns>
- bool RetainAll(ICollection<T> c);
- }
-}
View
308 src/Iesi.Collections/Generic/ImmutableSet.cs
@@ -1,308 +0,0 @@
-/* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Iesi.Collections.Generic
-{
- /// <summary>
- /// <p>Implements an immutable (read-only) <c>Set</c> wrapper.</p>
- /// <p>Although this is advertised as immutable, it really isn't. Anyone with access to the
- /// <c>basisSet</c> can still change the data-set. So <c>GetHashCode()</c> is not implemented
- /// for this <c>Set</c>, as is the case for all <c>Set</c> implementations in this library.
- /// This design decision was based on the efficiency of not having to <c>Clone()</c> the
- /// <c>basisSet</c> every time you wrap a mutable <c>Set</c>.</p>
- /// </summary>
- [Serializable]
- public sealed class ImmutableSet<T> : Set<T>
- {
- private const string ERROR_MESSAGE = "Object is immutable.";
- private ISet<T> mBasisSet;
-
- internal ISet<T> BasisSet
- {
- get { return mBasisSet; }
- }
-
- /// <summary>
- /// Constructs an immutable (read-only) <c>Set</c> wrapper.
- /// </summary>
- /// <param name="basisSet">The <c>Set</c> that is wrapped.</param>
- public ImmutableSet(ISet<T> basisSet)
- {
- mBasisSet = basisSet;
- }
-
- /// <summary>
- /// Adds the specified element to this set if it is not already present.
- /// </summary>
- /// <param name="o">The object to add to the set.</param>
- /// <returns>nothing</returns>
- /// <exception cref="NotSupportedException"> is always thrown</exception>
- public override sealed bool Add(T o)
- {
- throw new NotSupportedException(ERROR_MESSAGE);
- }
-
- /// <summary>
- /// Adds all the elements in the specified collection to the set if they are not already present.
- /// </summary>
- /// <param name="c">A collection of objects to add to the set.</param>
- /// <returns>nothing</returns>
- /// <exception cref="NotSupportedException"> is always thrown</exception>
- public override sealed bool AddAll(ICollection<T> c)
- {
- throw new NotSupportedException(ERROR_MESSAGE);
- }
-
- /// <summary>
- /// Removes all objects from the set.
- /// </summary>
- /// <exception cref="NotSupportedException"> is always thrown</exception>
- public override sealed void Clear()
- {
- throw new NotSupportedException(ERROR_MESSAGE);
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if this set contains the specified element.
- /// </summary>
- /// <param name="o">The element to look for.</param>
- /// <returns><see langword="true" /> if this set contains the specified element, <see langword="false" /> otherwise.</returns>
- public override sealed bool Contains(T o)
- {
- return mBasisSet.Contains(o);
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if the set contains all the elements in the specified collection.
- /// </summary>
- /// <param name="c">A collection of objects.</param>
- /// <returns><see langword="true" /> if the set contains all the elements in the specified collection, <see langword="false" /> otherwise.</returns>
- public override sealed bool ContainsAll(ICollection<T> c)
- {
- return mBasisSet.ContainsAll(c);
- }
-
- /// <summary>
- /// Returns <see langword="true" /> if this set contains no elements.
- /// </summary>
- public override sealed bool IsEmpty
- {
- get { return mBasisSet.IsEmpty; }
- }
-
- /// <summary>
- /// Removes the specified element from the set.
- /// </summary>
- /// <param name="o">The element to be removed.</param>
- /// <returns>nothing</returns>
- /// <exception cref="NotSupportedException"> is always thrown</exception>
- public override sealed bool Remove(T o)
- {
- throw new NotSupportedException(ERROR_MESSAGE);
- }
-
- /// <summary>
- /// Remove all the specified elements from this set, if they exist in this set.
- /// </summary>
- /// <param name="c">A collection of elements to remove.</param>
- /// <returns>nothing</returns>
- /// <exception cref="NotSupportedException"> is always thrown</exception>
- public override sealed bool RemoveAll(ICollection<T> c)
- {
- throw new NotSupportedException(ERROR_MESSAGE);
- }
-
- /// <summary>
- /// Retains only the elements in this set that are contained in the specified collection.
- /// </summary>
- /// <param name="c">Collection that defines the set of elements to be retained.</param>
- /// <returns>nothing</returns>
- /// <exception cref="NotSupportedException"> is always thrown</exception>
- public override sealed bool RetainAll(ICollection<T> c)
- {
- throw new NotSupportedException(ERROR_MESSAGE);
- }
-
- /// <summary>
- /// Copies the elements in the <c>Set</c> to an array of T. The type of array needs
- /// to be compatible with the objects in the <c>Set</c>, obviously.
- /// </summary>
- /// <param name="array">An array that will be the target of the copy operation.</param>
- /// <param name="index">The zero-based index where copying will start.</param>
- public override sealed void CopyTo(T[] array, int index)
- {
- mBasisSet.CopyTo(array, index);
- }
-
- /// <summary>
- /// The number of elements contained in this collection.
- /// </summary>
- public override sealed int Count
- {
- get { return mBasisSet.Count; }
- }
-
- /// <summary>
- /// Returns an object that can be used to synchronize use of the <c>Set</c> across threads.
- /// </summary>
- public override sealed bool IsSynchronized
- {
- get { return ((ICollection) mBasisSet).IsSynchronized; }
- }
-
- /// <summary>
- /// Returns an object that can be used to synchronize the <c>Set</c> between threads.
- /// </summary>
- public override sealed object SyncRoot
- {
- get { return ((ICollection) mBasisSet).SyncRoot; }
- }
-
- /// <summary>
- /// Gets an enumerator for the elements in the <c>Set</c>.
- /// </summary>
- /// <returns>An <c>IEnumerator</c> over the elements in the <c>Set</c>.</returns>
- public override sealed IEnumerator<T> GetEnumerator()
- {
- return mBasisSet.GetEnumerator();
- }
-
- /// <summary>
- /// Returns a clone of the <c>Set</c> instance.
- /// </summary>
- /// <returns>A clone of this object.</returns>
- public override