diff --git a/src/Spring/Spring.Core/Collections/Generic/DictionarySet.cs b/src/Spring/Spring.Core/Collections/Generic/DictionarySet.cs index d41228fb..ed904150 100644 --- a/src/Spring/Spring.Core/Collections/Generic/DictionarySet.cs +++ b/src/Spring/Spring.Core/Collections/Generic/DictionarySet.cs @@ -1,249 +1,254 @@ /* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */ +#if NET_2_0 + + using System; using System.Collections; using System.Collections.Generic; namespace Spring.Collections.Generic { - /// - ///

DictionarySet is an abstract class that supports the creation of new Set - /// types where the underlying data store is an IDictionary instance.

- /// - ///

You can use any object that implements the IDictionary 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 IDictionary you choose will affect both the performance and the behavior - /// of the Set using it.

- /// - ///

To make a Set typed based on your own IDictionary, simply derive a - /// new class with a constructor that takes no parameters. Some Set implmentations - /// cannot be defined with a default constructor. If this is the case for your class, - /// you will need to override Clone() as well.

- /// - ///

It is also standard practice that at least one of your constructors takes an ICollection or - /// an ISet as an argument.

- ///
- [Serializable] - public abstract class DictionarySet : Set - { - /// - /// Provides the storage for elements in the Set, stored as the key-set - /// of the IDictionary object. Set this object in the constructor - /// if you create your own Set class. - /// - protected IDictionary InternalDictionary = null; + /// + ///

DictionarySet is an abstract class that supports the creation of new Set + /// types where the underlying data store is an IDictionary instance.

+ /// + ///

You can use any object that implements the IDictionary 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 IDictionary you choose will affect both the performance and the behavior + /// of the Set using it.

+ /// + ///

To make a Set typed based on your own IDictionary, simply derive a + /// new class with a constructor that takes no parameters. Some Set implmentations + /// cannot be defined with a default constructor. If this is the case for your class, + /// you will need to override Clone() as well.

+ /// + ///

It is also standard practice that at least one of your constructors takes an ICollection or + /// an ISet as an argument.

+ ///
+ [Serializable] + public abstract class DictionarySet : Set + { + /// + /// Provides the storage for elements in the Set, stored as the key-set + /// of the IDictionary object. Set this object in the constructor + /// if you create your own Set class. + /// + protected IDictionary InternalDictionary = null; - private static readonly object PlaceholderObject = new object(); + private static readonly object PlaceholderObject = new object(); - /// - /// The placeholder object used as the value for the IDictionary instance. - /// - /// - /// There is a single instance of this object globally, used for all Sets. - /// - protected object Placeholder - { - get { return PlaceholderObject; } - } + /// + /// The placeholder object used as the value for the IDictionary instance. + /// + /// + /// There is a single instance of this object globally, used for all Sets. + /// + protected object Placeholder + { + get { return PlaceholderObject; } + } - /// - /// Adds the specified element to this set if it is not already present. - /// - /// The to add to the set. - /// is the object was added, if it was already present. - 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; - } - } + /// + /// Adds the specified element to this set if it is not already present. + /// + /// The to add to the set. + /// is the object was added, if it was already present. + 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; + } + } - /// - /// Adds all the elements in the specified collection to the set if they are not already present. - /// - /// A collection of objects to add to the set. - /// is the set changed as a result of this operation, if not. - public override bool AddAll(ICollection c) - { - bool changed = false; - foreach (T o in c) - { - changed |= this.Add(o); - } - return changed; - } + /// + /// Adds all the elements in the specified collection to the set if they are not already present. + /// + /// A collection of objects to add to the set. + /// is the set changed as a result of this operation, if not. + public override bool AddAll(ICollection c) + { + bool changed = false; + foreach (T o in c) + { + changed |= this.Add(o); + } + return changed; + } - /// - /// Removes all objects from the set. - /// - public override void Clear() - { - InternalDictionary.Clear(); - } + /// + /// Removes all objects from the set. + /// + public override void Clear() + { + InternalDictionary.Clear(); + } - /// - /// Returns if this set contains the specified element. - /// - /// The element to look for. - /// if this set contains the specified element, otherwise. - public override bool Contains(T o) - { - return InternalDictionary.ContainsKey(o); - } + /// + /// Returns if this set contains the specified element. + /// + /// The element to look for. + /// if this set contains the specified element, otherwise. + public override bool Contains(T o) + { + return InternalDictionary.ContainsKey(o); + } - /// - /// Returns if the set contains all the elements in the specified collection. - /// - /// A collection of objects. - /// if the set contains all the elements in the specified collection, otherwise. - public override bool ContainsAll(ICollection c) - { - foreach (T o in c) - { - if (!this.Contains(o)) - { - return false; - } - } - return true; - } + /// + /// Returns if the set contains all the elements in the specified collection. + /// + /// A collection of objects. + /// if the set contains all the elements in the specified collection, otherwise. + public override bool ContainsAll(ICollection c) + { + foreach (T o in c) + { + if (!this.Contains(o)) + { + return false; + } + } + return true; + } - /// - /// Returns if this set contains no elements. - /// - public override bool IsEmpty - { - get { return InternalDictionary.Count == 0; } - } + /// + /// Returns if this set contains no elements. + /// + public override bool IsEmpty + { + get { return InternalDictionary.Count == 0; } + } - /// - /// Removes the specified element from the set. - /// - /// The element to be removed. - /// if the set contained the specified element, otherwise. - public override bool Remove(T o) - { - bool contained = this.Contains(o); - if (contained) - { - InternalDictionary.Remove(o); - } - return contained; - } + /// + /// Removes the specified element from the set. + /// + /// The element to be removed. + /// if the set contained the specified element, otherwise. + public override bool Remove(T o) + { + bool contained = this.Contains(o); + if (contained) + { + InternalDictionary.Remove(o); + } + return contained; + } - /// - /// Remove all the specified elements from this set, if they exist in this set. - /// - /// A collection of elements to remove. - /// if the set was modified as a result of this operation. - public override bool RemoveAll(ICollection c) - { - bool changed = false; - foreach (T o in c) - { - changed |= this.Remove(o); - } - return changed; - } + /// + /// Remove all the specified elements from this set, if they exist in this set. + /// + /// A collection of elements to remove. + /// if the set was modified as a result of this operation. + public override bool RemoveAll(ICollection c) + { + bool changed = false; + foreach (T o in c) + { + changed |= this.Remove(o); + } + return changed; + } - /// - /// Retains only the elements in this set that are contained in the specified collection. - /// - /// Collection that defines the set of elements to be retained. - /// if this set changed as a result of this operation. - public override bool RetainAll(ICollection c) - { - //Put data from C into a set so we can use the Contains() method. - Set cSet = new HashedSet(c); + /// + /// Retains only the elements in this set that are contained in the specified collection. + /// + /// Collection that defines the set of elements to be retained. + /// if this set changed as a result of this operation. + public override bool RetainAll(ICollection c) + { + //Put data from C into a set so we can use the Contains() method. + Set cSet = new HashedSet(c); - //We are going to build a set of elements to remove. - Set removeSet = new HashedSet(); + //We are going to build a set of elements to remove. + Set removeSet = new HashedSet(); - 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); - } + 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); - } + return this.RemoveAll(removeSet); + } - /// - /// Copies the elements in the Set to an array of T. The type of array needs - /// to be compatible with the objects in the Set, obviously. - /// - /// An array that will be the target of the copy operation. - /// The zero-based index where copying will start. - public override void CopyTo(T[] array, int index) - { - InternalDictionary.Keys.CopyTo(array, index); - } + /// + /// Copies the elements in the Set to an array of T. The type of array needs + /// to be compatible with the objects in the Set, obviously. + /// + /// An array that will be the target of the copy operation. + /// The zero-based index where copying will start. + public override void CopyTo(T[] array, int index) + { + InternalDictionary.Keys.CopyTo(array, index); + } - /// - /// The number of elements contained in this collection. - /// - public override int Count - { - get { return InternalDictionary.Count; } - } + /// + /// The number of elements contained in this collection. + /// + public override int Count + { + get { return InternalDictionary.Count; } + } - /// - /// None of the objects based on DictionarySet are synchronized. Use the - /// SyncRoot property instead. - /// - public override bool IsSynchronized - { - get { return false; } - } + /// + /// None of the objects based on DictionarySet are synchronized. Use the + /// SyncRoot property instead. + /// + public override bool IsSynchronized + { + get { return false; } + } - /// - /// Returns an object that can be used to synchronize the Set between threads. - /// - public override object SyncRoot - { - get { return ((ICollection) InternalDictionary).SyncRoot; } - } + /// + /// Returns an object that can be used to synchronize the Set between threads. + /// + public override object SyncRoot + { + get { return ((ICollection)InternalDictionary).SyncRoot; } + } - /// - /// Gets an enumerator for the elements in the Set. - /// - /// An IEnumerator over the elements in the Set. - public override IEnumerator GetEnumerator() - { - return InternalDictionary.Keys.GetEnumerator(); - } + /// + /// Gets an enumerator for the elements in the Set. + /// + /// An IEnumerator over the elements in the Set. + public override IEnumerator GetEnumerator() + { + return InternalDictionary.Keys.GetEnumerator(); + } - /// - /// Indicates wether the Set is read-only or not - /// - public override bool IsReadOnly - { - get { return InternalDictionary.IsReadOnly; } - } + /// + /// Indicates wether the Set is read-only or not + /// + public override bool IsReadOnly + { + get { return InternalDictionary.IsReadOnly; } + } - /// - /// Copies the elements in the Set to an array. The type of array needs - /// to be compatible with the objects in the Set, obviously. Needed for - /// non-generic ISet methods implementation - /// - /// An array that will be the target of the copy operation. - /// The zero-based index where copying will start. - protected override void NonGenericCopyTo(Array array, int index) - { - ((ICollection) InternalDictionary.Keys).CopyTo(array, index); - } - } + /// + /// Copies the elements in the Set to an array. The type of array needs + /// to be compatible with the objects in the Set, obviously. Needed for + /// non-generic ISet methods implementation + /// + /// An array that will be the target of the copy operation. + /// The zero-based index where copying will start. + protected override void NonGenericCopyTo(Array array, int index) + { + ((ICollection)InternalDictionary.Keys).CopyTo(array, index); + } + } } + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Collections/Generic/HashedSet.cs b/src/Spring/Spring.Core/Collections/Generic/HashedSet.cs index 4cfcf694..6800291d 100644 --- a/src/Spring/Spring.Core/Collections/Generic/HashedSet.cs +++ b/src/Spring/Spring.Core/Collections/Generic/HashedSet.cs @@ -1,33 +1,40 @@ /* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */ + +#if NET_2_0 + + using System; using System.Collections.Generic; namespace Spring.Collections.Generic { - /// - /// Implements a Set based on a Dictionary (which is equivalent of - /// non-genric HashTable) This will give the best lookup, add, and remove - /// performance for very large data-sets, but iteration will occur in no particular order. - /// - [Serializable] - public class HashedSet : DictionarySet - { - /// - /// Creates a new set instance based on a Dictinary. - /// - public HashedSet() - { - InternalDictionary = new Dictionary(); - } + /// + /// Implements a Set based on a Dictionary (which is equivalent of + /// non-genric HashTable) This will give the best lookup, add, and remove + /// performance for very large data-sets, but iteration will occur in no particular order. + /// + [Serializable] + public class HashedSet : DictionarySet + { + /// + /// Creates a new set instance based on a Dictinary. + /// + public HashedSet() + { + InternalDictionary = new Dictionary(); + } - /// - /// Creates a new set instance based on a Dictinary and - /// initializes it based on a collection of elements. - /// - /// A collection of elements that defines the initial set contents. - public HashedSet(ICollection initialValues) : this() - { - this.AddAll(initialValues); - } - } + /// + /// Creates a new set instance based on a Dictinary and + /// initializes it based on a collection of elements. + /// + /// A collection of elements that defines the initial set contents. + public HashedSet(ICollection initialValues) + : this() + { + this.AddAll(initialValues); + } + } } + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Collections/Generic/ISet.cs b/src/Spring/Spring.Core/Collections/Generic/ISet.cs index c2182a2c..a44b2689 100644 --- a/src/Spring/Spring.Core/Collections/Generic/ISet.cs +++ b/src/Spring/Spring.Core/Collections/Generic/ISet.cs @@ -1,139 +1,145 @@ + +#if NET_2_0 + + using System; using System.Collections; using System.Collections.Generic; namespace Spring.Collections.Generic { - /// - ///

A collection that contains no duplicate elements. This interface models the mathematical - /// Set abstraction. - /// The order of elements in a set is dependant on (a)the data-structure implementation, and - /// (b)the implementation of the various Set methods, and thus is not guaranteed.

- /// - ///

None of the Set implementations in this library are guranteed to be thread-safe - /// in any way unless wrapped in a SynchronizedSet.

- /// - ///

The following table summarizes the binary operators that are supported by the Set class.

- /// - /// - /// Operation - /// Description - /// Method - /// - /// - /// Union (OR) - /// Element included in result if it exists in either A OR B. - /// Union() - /// - /// - /// Intersection (AND) - /// Element included in result if it exists in both A AND B. - /// InterSect() - /// - /// - /// Exclusive Or (XOR) - /// Element included in result if it exists in one, but not both, of A and B. - /// ExclusiveOr() - /// - /// - /// Minus (n/a) - /// Take all the elements in A. Now, if any of them exist in B, remove - /// them. Note that unlike the other operators, A - B is not the same as B - A. - /// Minus() - /// - /// - ///
- public interface ISet : ICollection, IEnumerable, IEnumerable, ICloneable - { - // Clear is declared in ICollection, but not in ICollection - // void Clear(); + /// + ///

A collection that contains no duplicate elements. This interface models the mathematical + /// Set abstraction. + /// The order of elements in a set is dependant on (a)the data-structure implementation, and + /// (b)the implementation of the various Set methods, and thus is not guaranteed.

+ /// + ///

None of the Set implementations in this library are guranteed to be thread-safe + /// in any way unless wrapped in a SynchronizedSet.

+ /// + ///

The following table summarizes the binary operators that are supported by the Set class.

+ /// + /// + /// Operation + /// Description + /// Method + /// + /// + /// Union (OR) + /// Element included in result if it exists in either A OR B. + /// Union() + /// + /// + /// Intersection (AND) + /// Element included in result if it exists in both A AND B. + /// InterSect() + /// + /// + /// Exclusive Or (XOR) + /// Element included in result if it exists in one, but not both, of A and B. + /// ExclusiveOr() + /// + /// + /// Minus (n/a) + /// Take all the elements in A. Now, if any of them exist in B, remove + /// them. Note that unlike the other operators, A - B is not the same as B - A. + /// Minus() + /// + /// + ///
+ public interface ISet : ICollection, IEnumerable, IEnumerable, ICloneable + { + // Clear is declared in ICollection, but not in ICollection + // void Clear(); - // Remove is declared in ICollection, but not in ICollection - // bool Remove(T o); + // Remove is declared in ICollection, but not in ICollection + // bool Remove(T o); - // Contains is declared in ICollection, but not in ICollection - // bool Contains(T o); + // Contains is declared in ICollection, but not in ICollection + // bool Contains(T o); - /// - /// 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 a or b. - /// Neither this set nor the input set are modified during the operation. The return value - /// is a Clone() of this set with the extra elements added in. - /// - /// A collection of elements. - /// A new Set containing the union of this Set with the specified collection. - /// Neither of the input objects is modified by the union. - ISet Union(ISet a); + /// + /// 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 a or b. + /// Neither this set nor the input set are modified during the operation. The return value + /// is a Clone() of this set with the extra elements added in. + /// + /// A collection of elements. + /// A new Set containing the union of this Set with the specified collection. + /// Neither of the input objects is modified by the union. + ISet Union(ISet a); - /// - /// 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 Intersect() operation does not modify the input sets. It returns - /// a Clone() of this set with the appropriate elements removed. - /// - /// A set of elements. - /// The intersection of this set with a. - ISet Intersect(ISet a); + /// + /// 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 Intersect() operation does not modify the input sets. It returns + /// a Clone() of this set with the appropriate elements removed. + /// + /// A set of elements. + /// The intersection of this set with a. + ISet Intersect(ISet a); - /// - /// Performs a "minus" of set b from set a. This returns a set of all - /// the elements in set a, removing the elements that are also in set b. - /// The original sets are not modified during this operation. The result set is a Clone() - /// of this Set containing the elements from the operation. - /// - /// A set of elements. - /// A set containing the elements from this set with the elements in a removed. - ISet Minus(ISet a); + /// + /// Performs a "minus" of set b from set a. This returns a set of all + /// the elements in set a, removing the elements that are also in set b. + /// The original sets are not modified during this operation. The result set is a Clone() + /// of this Set containing the elements from the operation. + /// + /// A set of elements. + /// A set containing the elements from this set with the elements in a removed. + ISet Minus(ISet a); - /// - /// 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 Clone() of this set containing - /// the elements from the exclusive-or operation. - /// - /// A set of elements. - /// A set containing the result of a ^ b. - ISet ExclusiveOr(ISet a); + /// + /// 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 Clone() of this set containing + /// the elements from the exclusive-or operation. + /// + /// A set of elements. + /// A set containing the result of a ^ b. + ISet ExclusiveOr(ISet a); - /// - /// Returns if the set contains all the elements in the specified collection. - /// - /// A collection of objects. - /// if the set contains all the elements in the specified collection, otherwise. - bool ContainsAll(ICollection c); + /// + /// Returns if the set contains all the elements in the specified collection. + /// + /// A collection of objects. + /// if the set contains all the elements in the specified collection, otherwise. + bool ContainsAll(ICollection c); - /// - /// Returns if this set contains no elements. - /// - bool IsEmpty { get; } + /// + /// Returns if this set contains no elements. + /// + bool IsEmpty { get; } - /// - /// Adds the specified element to this set if it is not already present. - /// - /// The object to add to the set. - /// is the object was added, if it was already present. - new bool Add(T o); + /// + /// Adds the specified element to this set if it is not already present. + /// + /// The object to add to the set. + /// is the object was added, if it was already present. + new bool Add(T o); - /// - /// Adds all the elements in the specified collection to the set if they are not already present. - /// - /// A collection of objects to add to the set. - /// is the set changed as a result of this operation, if not. - bool AddAll(ICollection c); + /// + /// Adds all the elements in the specified collection to the set if they are not already present. + /// + /// A collection of objects to add to the set. + /// is the set changed as a result of this operation, if not. + bool AddAll(ICollection c); - /// - /// Remove all the specified elements from this set, if they exist in this set. - /// - /// A collection of elements to remove. - /// if the set was modified as a result of this operation. - bool RemoveAll(ICollection c); + /// + /// Remove all the specified elements from this set, if they exist in this set. + /// + /// A collection of elements to remove. + /// if the set was modified as a result of this operation. + bool RemoveAll(ICollection c); - /// - /// Retains only the elements in this set that are contained in the specified collection. - /// - /// Collection that defines the set of elements to be retained. - /// if this set changed as a result of this operation. - bool RetainAll(ICollection c); - } + /// + /// Retains only the elements in this set that are contained in the specified collection. + /// + /// Collection that defines the set of elements to be retained. + /// if this set changed as a result of this operation. + bool RetainAll(ICollection c); + } } + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Collections/Generic/ImmutableSet.cs b/src/Spring/Spring.Core/Collections/Generic/ImmutableSet.cs index 1f3fea0e..71014764 100644 --- a/src/Spring/Spring.Core/Collections/Generic/ImmutableSet.cs +++ b/src/Spring/Spring.Core/Collections/Generic/ImmutableSet.cs @@ -1,308 +1,313 @@ /* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */ + +#if NET_2_0 + using System; using System.Collections; using System.Collections.Generic; namespace Spring.Collections.Generic { - /// - ///

Implements an immutable (read-only) Set wrapper.

- ///

Although this is advertised as immutable, it really isn't. Anyone with access to the - /// basisSet can still change the data-set. So GetHashCode() is not implemented - /// for this Set, as is the case for all Set implementations in this library. - /// This design decision was based on the efficiency of not having to Clone() the - /// basisSet every time you wrap a mutable Set.

- ///
- [Serializable] - public sealed class ImmutableSet : Set - { - private const string ERROR_MESSAGE = "Object is immutable."; - private ISet mBasisSet; + /// + ///

Implements an immutable (read-only) Set wrapper.

+ ///

Although this is advertised as immutable, it really isn't. Anyone with access to the + /// basisSet can still change the data-set. So GetHashCode() is not implemented + /// for this Set, as is the case for all Set implementations in this library. + /// This design decision was based on the efficiency of not having to Clone() the + /// basisSet every time you wrap a mutable Set.

+ ///
+ [Serializable] + public sealed class ImmutableSet : Set + { + private const string ERROR_MESSAGE = "Object is immutable."; + private ISet mBasisSet; - internal ISet BasisSet - { - get { return mBasisSet; } - } + internal ISet BasisSet + { + get { return mBasisSet; } + } - /// - /// Constructs an immutable (read-only) Set wrapper. - /// - /// The Set that is wrapped. - public ImmutableSet(ISet basisSet) - { - mBasisSet = basisSet; - } + /// + /// Constructs an immutable (read-only) Set wrapper. + /// + /// The Set that is wrapped. + public ImmutableSet(ISet basisSet) + { + mBasisSet = basisSet; + } - /// - /// Adds the specified element to this set if it is not already present. - /// - /// The object to add to the set. - /// nothing - /// is always thrown - public override sealed bool Add(T o) - { - throw new NotSupportedException(ERROR_MESSAGE); - } + /// + /// Adds the specified element to this set if it is not already present. + /// + /// The object to add to the set. + /// nothing + /// is always thrown + public override sealed bool Add(T o) + { + throw new NotSupportedException(ERROR_MESSAGE); + } - /// - /// Adds all the elements in the specified collection to the set if they are not already present. - /// - /// A collection of objects to add to the set. - /// nothing - /// is always thrown - public override sealed bool AddAll(ICollection c) - { - throw new NotSupportedException(ERROR_MESSAGE); - } + /// + /// Adds all the elements in the specified collection to the set if they are not already present. + /// + /// A collection of objects to add to the set. + /// nothing + /// is always thrown + public override sealed bool AddAll(ICollection c) + { + throw new NotSupportedException(ERROR_MESSAGE); + } - /// - /// Removes all objects from the set. - /// - /// is always thrown - public override sealed void Clear() - { - throw new NotSupportedException(ERROR_MESSAGE); - } + /// + /// Removes all objects from the set. + /// + /// is always thrown + public override sealed void Clear() + { + throw new NotSupportedException(ERROR_MESSAGE); + } - /// - /// Returns if this set contains the specified element. - /// - /// The element to look for. - /// if this set contains the specified element, otherwise. - public override sealed bool Contains(T o) - { - return mBasisSet.Contains(o); - } + /// + /// Returns if this set contains the specified element. + /// + /// The element to look for. + /// if this set contains the specified element, otherwise. + public override sealed bool Contains(T o) + { + return mBasisSet.Contains(o); + } - /// - /// Returns if the set contains all the elements in the specified collection. - /// - /// A collection of objects. - /// if the set contains all the elements in the specified collection, otherwise. - public override sealed bool ContainsAll(ICollection c) - { - return mBasisSet.ContainsAll(c); - } + /// + /// Returns if the set contains all the elements in the specified collection. + /// + /// A collection of objects. + /// if the set contains all the elements in the specified collection, otherwise. + public override sealed bool ContainsAll(ICollection c) + { + return mBasisSet.ContainsAll(c); + } - /// - /// Returns if this set contains no elements. - /// - public override sealed bool IsEmpty - { - get { return mBasisSet.IsEmpty; } - } + /// + /// Returns if this set contains no elements. + /// + public override sealed bool IsEmpty + { + get { return mBasisSet.IsEmpty; } + } - /// - /// Removes the specified element from the set. - /// - /// The element to be removed. - /// nothing - /// is always thrown - public override sealed bool Remove(T o) - { - throw new NotSupportedException(ERROR_MESSAGE); - } + /// + /// Removes the specified element from the set. + /// + /// The element to be removed. + /// nothing + /// is always thrown + public override sealed bool Remove(T o) + { + throw new NotSupportedException(ERROR_MESSAGE); + } - /// - /// Remove all the specified elements from this set, if they exist in this set. - /// - /// A collection of elements to remove. - /// nothing - /// is always thrown - public override sealed bool RemoveAll(ICollection c) - { - throw new NotSupportedException(ERROR_MESSAGE); - } + /// + /// Remove all the specified elements from this set, if they exist in this set. + /// + /// A collection of elements to remove. + /// nothing + /// is always thrown + public override sealed bool RemoveAll(ICollection c) + { + throw new NotSupportedException(ERROR_MESSAGE); + } - /// - /// Retains only the elements in this set that are contained in the specified collection. - /// - /// Collection that defines the set of elements to be retained. - /// nothing - /// is always thrown - public override sealed bool RetainAll(ICollection c) - { - throw new NotSupportedException(ERROR_MESSAGE); - } + /// + /// Retains only the elements in this set that are contained in the specified collection. + /// + /// Collection that defines the set of elements to be retained. + /// nothing + /// is always thrown + public override sealed bool RetainAll(ICollection c) + { + throw new NotSupportedException(ERROR_MESSAGE); + } - /// - /// Copies the elements in the Set to an array of T. The type of array needs - /// to be compatible with the objects in the Set, obviously. - /// - /// An array that will be the target of the copy operation. - /// The zero-based index where copying will start. - public override sealed void CopyTo(T[] array, int index) - { - mBasisSet.CopyTo(array, index); - } + /// + /// Copies the elements in the Set to an array of T. The type of array needs + /// to be compatible with the objects in the Set, obviously. + /// + /// An array that will be the target of the copy operation. + /// The zero-based index where copying will start. + public override sealed void CopyTo(T[] array, int index) + { + mBasisSet.CopyTo(array, index); + } - /// - /// The number of elements contained in this collection. - /// - public override sealed int Count - { - get { return mBasisSet.Count; } - } + /// + /// The number of elements contained in this collection. + /// + public override sealed int Count + { + get { return mBasisSet.Count; } + } - /// - /// Returns an object that can be used to synchronize use of the Set across threads. - /// - public override sealed bool IsSynchronized - { - get { return ((ICollection) mBasisSet).IsSynchronized; } - } + /// + /// Returns an object that can be used to synchronize use of the Set across threads. + /// + public override sealed bool IsSynchronized + { + get { return ((ICollection)mBasisSet).IsSynchronized; } + } - /// - /// Returns an object that can be used to synchronize the Set between threads. - /// - public override sealed object SyncRoot - { - get { return ((ICollection) mBasisSet).SyncRoot; } - } + /// + /// Returns an object that can be used to synchronize the Set between threads. + /// + public override sealed object SyncRoot + { + get { return ((ICollection)mBasisSet).SyncRoot; } + } - /// - /// Gets an enumerator for the elements in the Set. - /// - /// An IEnumerator over the elements in the Set. - public override sealed IEnumerator GetEnumerator() - { - return mBasisSet.GetEnumerator(); - } + /// + /// Gets an enumerator for the elements in the Set. + /// + /// An IEnumerator over the elements in the Set. + public override sealed IEnumerator GetEnumerator() + { + return mBasisSet.GetEnumerator(); + } - /// - /// Returns a clone of the Set instance. - /// - /// A clone of this object. - public override sealed object Clone() - { - return new ImmutableSet(mBasisSet); - } + /// + /// Returns a clone of the Set instance. + /// + /// A clone of this object. + public override sealed object Clone() + { + return new ImmutableSet(mBasisSet); + } - /// - /// 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 a or b. - /// Neither this set nor the input set are modified during the operation. The return value - /// is a Clone() of this set with the extra elements added in. - /// - /// A collection of elements. - /// A new Set containing the union of this Set with the specified collection. - /// Neither of the input objects is modified by the union. - public override sealed ISet Union(ISet a) - { - ISet m = GetUltimateBasisSet(); - return new ImmutableSet(m.Union(a)); - } + /// + /// 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 a or b. + /// Neither this set nor the input set are modified during the operation. The return value + /// is a Clone() of this set with the extra elements added in. + /// + /// A collection of elements. + /// A new Set containing the union of this Set with the specified collection. + /// Neither of the input objects is modified by the union. + public override sealed ISet Union(ISet a) + { + ISet m = GetUltimateBasisSet(); + return new ImmutableSet(m.Union(a)); + } - /// - /// 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 Intersect() operation does not modify the input sets. It returns - /// a Clone() of this set with the appropriate elements removed. - /// - /// A set of elements. - /// The intersection of this set with a. - public override sealed ISet Intersect(ISet a) - { - ISet m = GetUltimateBasisSet(); - return new ImmutableSet(m.Intersect(a)); - } + /// + /// 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 Intersect() operation does not modify the input sets. It returns + /// a Clone() of this set with the appropriate elements removed. + /// + /// A set of elements. + /// The intersection of this set with a. + public override sealed ISet Intersect(ISet a) + { + ISet m = GetUltimateBasisSet(); + return new ImmutableSet(m.Intersect(a)); + } - /// - /// Performs a "minus" of set b from set a. This returns a set of all - /// the elements in set a, removing the elements that are also in set b. - /// The original sets are not modified during this operation. The result set is a Clone() - /// of this Set containing the elements from the operation. - /// - /// A set of elements. - /// A set containing the elements from this set with the elements in a removed. - public override sealed ISet Minus(ISet a) - { - ISet m = GetUltimateBasisSet(); - return new ImmutableSet(m.Minus(a)); - } + /// + /// Performs a "minus" of set b from set a. This returns a set of all + /// the elements in set a, removing the elements that are also in set b. + /// The original sets are not modified during this operation. The result set is a Clone() + /// of this Set containing the elements from the operation. + /// + /// A set of elements. + /// A set containing the elements from this set with the elements in a removed. + public override sealed ISet Minus(ISet a) + { + ISet m = GetUltimateBasisSet(); + return new ImmutableSet(m.Minus(a)); + } - /// - /// 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 Clone() of this set containing - /// the elements from the exclusive-or operation. - /// - /// A set of elements. - /// A set containing the result of a ^ b. - public override sealed ISet ExclusiveOr(ISet a) - { - ISet m = GetUltimateBasisSet(); - return new ImmutableSet(m.ExclusiveOr(a)); - } + /// + /// 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 Clone() of this set containing + /// the elements from the exclusive-or operation. + /// + /// A set of elements. + /// A set containing the result of a ^ b. + public override sealed ISet ExclusiveOr(ISet a) + { + ISet m = GetUltimateBasisSet(); + return new ImmutableSet(m.ExclusiveOr(a)); + } - /// - /// Indicates that the given instance is read-only - /// - public override sealed bool IsReadOnly - { - get { return true; } - } + /// + /// Indicates that the given instance is read-only + /// + public override sealed bool IsReadOnly + { + get { return true; } + } - /// - /// Performs CopyTo when called trhough non-generic ISet (ICollection) interface - /// - /// - /// - protected override void NonGenericCopyTo(Array array, int index) - { - ((ICollection) this.BasisSet).CopyTo(array, index); - } + /// + /// Performs CopyTo when called trhough non-generic ISet (ICollection) interface + /// + /// + /// + protected override void NonGenericCopyTo(Array array, int index) + { + ((ICollection)this.BasisSet).CopyTo(array, index); + } - /// - /// Performs Union when called trhough non-generic ISet interface - /// - /// - /// - protected override sealed ISet NonGenericUnion(ISet a) - { - ISet m = GetUltimateBasisSet(); - return new ImmutableSet(((ISet) m).Union(a)); - } + /// + /// Performs Union when called trhough non-generic ISet interface + /// + /// + /// + protected override sealed ISet NonGenericUnion(ISet a) + { + ISet m = GetUltimateBasisSet(); + return new ImmutableSet(((ISet)m).Union(a)); + } - /// - /// Performs Minus when called trhough non-generic ISet interface - /// - /// - /// - protected override sealed ISet NonGenericMinus(ISet a) - { - ISet m = GetUltimateBasisSet(); - return new ImmutableSet(((ISet) m).Minus(a)); - } + /// + /// Performs Minus when called trhough non-generic ISet interface + /// + /// + /// + protected override sealed ISet NonGenericMinus(ISet a) + { + ISet m = GetUltimateBasisSet(); + return new ImmutableSet(((ISet)m).Minus(a)); + } - /// - /// Performs Intersect when called trhough non-generic ISet interface - /// - /// - /// - protected override sealed ISet NonGenericIntersect(ISet a) - { - ISet m = GetUltimateBasisSet(); - return new ImmutableSet(((ISet) m).Intersect(a)); - } + /// + /// Performs Intersect when called trhough non-generic ISet interface + /// + /// + /// + protected override sealed ISet NonGenericIntersect(ISet a) + { + ISet m = GetUltimateBasisSet(); + return new ImmutableSet(((ISet)m).Intersect(a)); + } - /// - /// Performs ExclusiveOr when called trhough non-generic ISet interface - /// - /// - /// - protected override sealed ISet NonGenericExclusiveOr(ISet a) - { - ISet m = GetUltimateBasisSet(); - return new ImmutableSet(((ISet) m).ExclusiveOr(a)); - } + /// + /// Performs ExclusiveOr when called trhough non-generic ISet interface + /// + /// + /// + protected override sealed ISet NonGenericExclusiveOr(ISet a) + { + ISet m = GetUltimateBasisSet(); + return new ImmutableSet(((ISet)m).ExclusiveOr(a)); + } - private ISet GetUltimateBasisSet() - { - ISet m = this.mBasisSet; - while (m is ImmutableSet) - m = ((ImmutableSet) m).mBasisSet; - return m; - } - } + private ISet GetUltimateBasisSet() + { + ISet m = this.mBasisSet; + while (m is ImmutableSet) + m = ((ImmutableSet)m).mBasisSet; + return m; + } + } } + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Collections/Generic/OrderedSet.cs b/src/Spring/Spring.Core/Collections/Generic/OrderedSet.cs index 30107594..ffa6f932 100644 --- a/src/Spring/Spring.Core/Collections/Generic/OrderedSet.cs +++ b/src/Spring/Spring.Core/Collections/Generic/OrderedSet.cs @@ -1,30 +1,35 @@ +#if NET_2_0 + + using System; using System.Collections.Generic; namespace Spring.Collections.Generic { - /// - /// Implements an ordered Set based on a dictionary. - /// - [Serializable] - public class OrderedSet : DictionarySet - { - /// - /// Initializes a new instance of the class. - /// - public OrderedSet() - { - InternalDictionary = new Dictionary(); - } + /// + /// Implements an ordered Set based on a dictionary. + /// + [Serializable] + public class OrderedSet : DictionarySet + { + /// + /// Initializes a new instance of the class. + /// + public OrderedSet() + { + InternalDictionary = new Dictionary(); + } - /// - /// Initializes a new instance of the class. - /// - /// A collection of elements that defines the initial set contents. - public OrderedSet(ICollection initialValues) - : this() - { - AddAll(initialValues); - } - } + /// + /// Initializes a new instance of the class. + /// + /// A collection of elements that defines the initial set contents. + public OrderedSet(ICollection initialValues) + : this() + { + AddAll(initialValues); + } + } } + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Collections/Generic/Set.cs b/src/Spring/Spring.Core/Collections/Generic/Set.cs index 84a3ea8c..0dd62872 100644 --- a/src/Spring/Spring.Core/Collections/Generic/Set.cs +++ b/src/Spring/Spring.Core/Collections/Generic/Set.cs @@ -1,561 +1,568 @@ /* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */ + +#if NET_2_0 + + using System; using System.Collections; using System.Collections.Generic; namespace Spring.Collections.Generic { - ///

A collection that contains no duplicate elements. This class models the mathematical - /// Set abstraction, and is the base class for all other Set implementations. - /// The order of elements in a set is dependant on (a)the data-structure implementation, and - /// (b)the implementation of the various Set methods, and thus is not guaranteed.

- /// - ///

None of the Set implementations in this library are guranteed to be thread-safe - /// in any way unless wrapped in a SynchronizedSet.

- /// - ///

The following table summarizes the binary operators that are supported by the Set class.

- /// - /// - /// Operation - /// Description - /// Method - /// Operator - /// - /// - /// Union (OR) - /// Element included in result if it exists in either A OR B. - /// Union() - /// | - /// - /// - /// Intersection (AND) - /// Element included in result if it exists in both A AND B. - /// InterSect() - /// & - /// - /// - /// Exclusive Or (XOR) - /// Element included in result if it exists in one, but not both, of A and B. - /// ExclusiveOr() - /// ^ - /// - /// - /// Minus (n/a) - /// Take all the elements in A. Now, if any of them exist in B, remove - /// them. Note that unlike the other operators, A - B is not the same as B - A. - /// Minus() - /// - - /// - /// - ///
- [Serializable] - public abstract class Set : ISet, ICollection, IEnumerable, - ISet, ICollection, IEnumerable, ICloneable - { - /// - /// 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 a or b. - /// Neither this set nor the input set are modified during the operation. The return value - /// is a Clone() of this set with the extra elements added in. - /// - /// A collection of elements. - /// A new Set containing the union of this Set with the specified collection. - /// Neither of the input objects is modified by the union. - public virtual ISet Union(ISet a) - { - ISet resultSet = (ISet) this.Clone(); - if (a != null) - { - resultSet.AddAll(a); - } - return resultSet; - } + ///

A collection that contains no duplicate elements. This class models the mathematical + /// Set abstraction, and is the base class for all other Set implementations. + /// The order of elements in a set is dependant on (a)the data-structure implementation, and + /// (b)the implementation of the various Set methods, and thus is not guaranteed.

+ /// + ///

None of the Set implementations in this library are guranteed to be thread-safe + /// in any way unless wrapped in a SynchronizedSet.

+ /// + ///

The following table summarizes the binary operators that are supported by the Set class.

+ /// + /// + /// Operation + /// Description + /// Method + /// Operator + /// + /// + /// Union (OR) + /// Element included in result if it exists in either A OR B. + /// Union() + /// | + /// + /// + /// Intersection (AND) + /// Element included in result if it exists in both A AND B. + /// InterSect() + /// & + /// + /// + /// Exclusive Or (XOR) + /// Element included in result if it exists in one, but not both, of A and B. + /// ExclusiveOr() + /// ^ + /// + /// + /// Minus (n/a) + /// Take all the elements in A. Now, if any of them exist in B, remove + /// them. Note that unlike the other operators, A - B is not the same as B - A. + /// Minus() + /// - + /// + /// + ///
+ [Serializable] + public abstract class Set : ISet, ICollection, IEnumerable, + ISet, ICollection, IEnumerable, ICloneable + { + /// + /// 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 a or b. + /// Neither this set nor the input set are modified during the operation. The return value + /// is a Clone() of this set with the extra elements added in. + /// + /// A collection of elements. + /// A new Set containing the union of this Set with the specified collection. + /// Neither of the input objects is modified by the union. + public virtual ISet Union(ISet a) + { + ISet resultSet = (ISet)this.Clone(); + if (a != null) + { + resultSet.AddAll(a); + } + return resultSet; + } - /// - /// Performs a "union" of two sets, where all the elements - /// in both are present. That is, the element is included if it is in either a or b. - /// The return value is a Clone() of one of the sets (a if it is not ) with elements of the other set - /// added in. Neither of the input sets is modified by the operation. - /// - /// A set of elements. - /// A set of elements. - /// A set containing the union of the input sets. if both sets are . - public static ISet Union(ISet a, ISet b) - { - if (a == null && b == null) - return null; - else if (a == null) - return (ISet) b.Clone(); - else if (b == null) - return (ISet) a.Clone(); - else - return a.Union(b); - } + /// + /// Performs a "union" of two sets, where all the elements + /// in both are present. That is, the element is included if it is in either a or b. + /// The return value is a Clone() of one of the sets (a if it is not ) with elements of the other set + /// added in. Neither of the input sets is modified by the operation. + /// + /// A set of elements. + /// A set of elements. + /// A set containing the union of the input sets. if both sets are . + public static ISet Union(ISet a, ISet b) + { + if (a == null && b == null) + return null; + else if (a == null) + return (ISet)b.Clone(); + else if (b == null) + return (ISet)a.Clone(); + else + return a.Union(b); + } - /// - /// Performs a "union" of two sets, where all the elements - /// in both are present. That is, the element is included if it is in either a or b. - /// The return value is a Clone() of one of the sets (a if it is not ) with elements of the other set - /// added in. Neither of the input sets is modified by the operation. - /// - /// A set of elements. - /// A set of elements. - /// A set containing the union of the input sets. if both sets are . - public static Set operator |(Set a, Set b) - { - return (Set) Union(a, b); - } + /// + /// Performs a "union" of two sets, where all the elements + /// in both are present. That is, the element is included if it is in either a or b. + /// The return value is a Clone() of one of the sets (a if it is not ) with elements of the other set + /// added in. Neither of the input sets is modified by the operation. + /// + /// A set of elements. + /// A set of elements. + /// A set containing the union of the input sets. if both sets are . + public static Set operator |(Set a, Set b) + { + return (Set)Union(a, b); + } - /// - /// 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 Intersect() operation does not modify the input sets. It returns - /// a Clone() of this set with the appropriate elements removed. - /// - /// A set of elements. - /// The intersection of this set with a. - public virtual ISet Intersect(ISet a) - { - ISet resultSet = (ISet) this.Clone(); - if (a != null) - resultSet.RetainAll(a); - else - resultSet.Clear(); - return resultSet; - } + /// + /// 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 Intersect() operation does not modify the input sets. It returns + /// a Clone() of this set with the appropriate elements removed. + /// + /// A set of elements. + /// The intersection of this set with a. + public virtual ISet Intersect(ISet a) + { + ISet resultSet = (ISet)this.Clone(); + if (a != null) + resultSet.RetainAll(a); + else + resultSet.Clear(); + return resultSet; + } - /// - /// Performs an "intersection" of the two sets, where only the elements - /// that are present in both sets remain. That is, the element is included only if it exists in - /// both a and b. Neither input object is modified by the operation. - /// The result object is a Clone() of one of the input objects (a if it is not ) containing the - /// elements from the intersect operation. - /// - /// A set of elements. - /// A set of elements. - /// The intersection of the two input sets. if both sets are . - public static ISet Intersect(ISet a, ISet b) - { - if (a == null && b == null) - return null; - else if (a == null) - { - return b.Intersect(a); - } - else - return a.Intersect(b); - } + /// + /// Performs an "intersection" of the two sets, where only the elements + /// that are present in both sets remain. That is, the element is included only if it exists in + /// both a and b. Neither input object is modified by the operation. + /// The result object is a Clone() of one of the input objects (a if it is not ) containing the + /// elements from the intersect operation. + /// + /// A set of elements. + /// A set of elements. + /// The intersection of the two input sets. if both sets are . + public static ISet Intersect(ISet a, ISet b) + { + if (a == null && b == null) + return null; + else if (a == null) + { + return b.Intersect(a); + } + else + return a.Intersect(b); + } - /// - /// Performs an "intersection" of the two sets, where only the elements - /// that are present in both sets remain. That is, the element is included only if it exists in - /// both a and b. Neither input object is modified by the operation. - /// The result object is a Clone() of one of the input objects (a if it is not ) containing the - /// elements from the intersect operation. - /// - /// A set of elements. - /// A set of elements. - /// The intersection of the two input sets. if both sets are . - public static Set operator &(Set a, Set b) - { - return (Set) Intersect(a, b); - } + /// + /// Performs an "intersection" of the two sets, where only the elements + /// that are present in both sets remain. That is, the element is included only if it exists in + /// both a and b. Neither input object is modified by the operation. + /// The result object is a Clone() of one of the input objects (a if it is not ) containing the + /// elements from the intersect operation. + /// + /// A set of elements. + /// A set of elements. + /// The intersection of the two input sets. if both sets are . + public static Set operator &(Set a, Set b) + { + return (Set)Intersect(a, b); + } - /// - /// Performs a "minus" of set b from set a. This returns a set of all - /// the elements in set a, removing the elements that are also in set b. - /// The original sets are not modified during this operation. The result set is a Clone() - /// of this Set containing the elements from the operation. - /// - /// A set of elements. - /// A set containing the elements from this set with the elements in a removed. - public virtual ISet Minus(ISet a) - { - ISet resultSet = (ISet) this.Clone(); - if (a != null) - resultSet.RemoveAll(a); - return resultSet; - } + /// + /// Performs a "minus" of set b from set a. This returns a set of all + /// the elements in set a, removing the elements that are also in set b. + /// The original sets are not modified during this operation. The result set is a Clone() + /// of this Set containing the elements from the operation. + /// + /// A set of elements. + /// A set containing the elements from this set with the elements in a removed. + public virtual ISet Minus(ISet a) + { + ISet resultSet = (ISet)this.Clone(); + if (a != null) + resultSet.RemoveAll(a); + return resultSet; + } - /// - /// Performs a "minus" of set b from set a. This returns a set of all - /// the elements in set a, removing the elements that are also in set b. - /// The original sets are not modified during this operation. The result set is a Clone() - /// of set a containing the elements from the operation. - /// - /// A set of elements. - /// A set of elements. - /// A set containing A - B elements. if a is . - public static ISet Minus(ISet a, ISet b) - { - if (a == null) - return null; - else - return a.Minus(b); - } + /// + /// Performs a "minus" of set b from set a. This returns a set of all + /// the elements in set a, removing the elements that are also in set b. + /// The original sets are not modified during this operation. The result set is a Clone() + /// of set a containing the elements from the operation. + /// + /// A set of elements. + /// A set of elements. + /// A set containing A - B elements. if a is . + public static ISet Minus(ISet a, ISet b) + { + if (a == null) + return null; + else + return a.Minus(b); + } - /// - /// Performs a "minus" of set b from set a. This returns a set of all - /// the elements in set a, removing the elements that are also in set b. - /// The original sets are not modified during this operation. The result set is a Clone() - /// of set a containing the elements from the operation. - /// - /// A set of elements. - /// A set of elements. - /// A set containing A - B elements. if a is . - public static Set operator -(Set a, Set b) - { - return (Set) Minus(a, b); - } + /// + /// Performs a "minus" of set b from set a. This returns a set of all + /// the elements in set a, removing the elements that are also in set b. + /// The original sets are not modified during this operation. The result set is a Clone() + /// of set a containing the elements from the operation. + /// + /// A set of elements. + /// A set of elements. + /// A set containing A - B elements. if a is . + public static Set operator -(Set a, Set b) + { + return (Set)Minus(a, b); + } - /// - /// 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 Clone() of this set containing - /// the elements from the exclusive-or operation. - /// - /// A set of elements. - /// A set containing the result of a ^ b. - public virtual ISet ExclusiveOr(ISet a) - { - ISet resultSet = (ISet) this.Clone(); - foreach (T element in a) - { - if (resultSet.Contains(element)) - resultSet.Remove(element); - else - resultSet.Add(element); - } - return resultSet; - } + /// + /// 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 Clone() of this set containing + /// the elements from the exclusive-or operation. + /// + /// A set of elements. + /// A set containing the result of a ^ b. + public virtual ISet ExclusiveOr(ISet a) + { + ISet resultSet = (ISet)this.Clone(); + foreach (T element in a) + { + if (resultSet.Contains(element)) + resultSet.Remove(element); + else + resultSet.Add(element); + } + return resultSet; + } - /// - /// 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 Clone() of one of the sets - /// (a if it is not ) containing - /// the elements from the exclusive-or operation. - /// - /// A set of elements. - /// A set of elements. - /// A set containing the result of a ^ b. if both sets are . - public static ISet ExclusiveOr(ISet a, ISet b) - { - if (a == null && b == null) - return null; - else if (a == null) - return (ISet) b.Clone(); - else if (b == null) - return (ISet) a.Clone(); - else - return a.ExclusiveOr(b); - } + /// + /// 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 Clone() of one of the sets + /// (a if it is not ) containing + /// the elements from the exclusive-or operation. + /// + /// A set of elements. + /// A set of elements. + /// A set containing the result of a ^ b. if both sets are . + public static ISet ExclusiveOr(ISet a, ISet b) + { + if (a == null && b == null) + return null; + else if (a == null) + return (ISet)b.Clone(); + else if (b == null) + return (ISet)a.Clone(); + else + return a.ExclusiveOr(b); + } - /// - /// 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 Clone() of one of the sets - /// (a if it is not ) containing - /// the elements from the exclusive-or operation. - /// - /// A set of elements. - /// A set of elements. - /// A set containing the result of a ^ b. if both sets are . - public static Set operator ^(Set a, Set b) - { - return (Set) ExclusiveOr(a, b); - } + /// + /// 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 Clone() of one of the sets + /// (a if it is not ) containing + /// the elements from the exclusive-or operation. + /// + /// A set of elements. + /// A set of elements. + /// A set containing the result of a ^ b. if both sets are . + public static Set operator ^(Set a, Set b) + { + return (Set)ExclusiveOr(a, b); + } - /// - /// Adds the specified element to this set if it is not already present. - /// - /// The object to add to the set. - /// is the object was added, if it was already present. - public abstract bool Add(T o); + /// + /// Adds the specified element to this set if it is not already present. + /// + /// The object to add to the set. + /// is the object was added, if it was already present. + public abstract bool Add(T o); - /// - /// Adds all the elements in the specified collection to the set if they are not already present. - /// - /// A collection of objects to add to the set. - /// is the set changed as a result of this operation, if not. - public abstract bool AddAll(ICollection c); + /// + /// Adds all the elements in the specified collection to the set if they are not already present. + /// + /// A collection of objects to add to the set. + /// is the set changed as a result of this operation, if not. + public abstract bool AddAll(ICollection c); - /// - /// Removes all objects from the set. - /// - public abstract void Clear(); + /// + /// Removes all objects from the set. + /// + public abstract void Clear(); - /// - /// Returns if this set contains the specified element. - /// - /// The element to look for. - /// if this set contains the specified element, otherwise. - public abstract bool Contains(T o); + /// + /// Returns if this set contains the specified element. + /// + /// The element to look for. + /// if this set contains the specified element, otherwise. + public abstract bool Contains(T o); - /// - /// Returns if the set contains all the elements in the specified collection. - /// - /// A collection of objects. - /// if the set contains all the elements in the specified collection, otherwise. - public abstract bool ContainsAll(ICollection c); + /// + /// Returns if the set contains all the elements in the specified collection. + /// + /// A collection of objects. + /// if the set contains all the elements in the specified collection, otherwise. + public abstract bool ContainsAll(ICollection c); - /// - /// Returns if this set contains no elements. - /// - public abstract bool IsEmpty { get; } + /// + /// Returns if this set contains no elements. + /// + public abstract bool IsEmpty { get; } - /// - /// Removes the specified element from the set. - /// - /// The element to be removed. - /// if the set contained the specified element, otherwise. - public abstract bool Remove(T o); + /// + /// Removes the specified element from the set. + /// + /// The element to be removed. + /// if the set contained the specified element, otherwise. + public abstract bool Remove(T o); - /// - /// Remove all the specified elements from this set, if they exist in this set. - /// - /// A collection of elements to remove. - /// if the set was modified as a result of this operation. - public abstract bool RemoveAll(ICollection c); + /// + /// Remove all the specified elements from this set, if they exist in this set. + /// + /// A collection of elements to remove. + /// if the set was modified as a result of this operation. + public abstract bool RemoveAll(ICollection c); - /// - /// Retains only the elements in this set that are contained in the specified collection. - /// - /// Collection that defines the set of elements to be retained. - /// if this set changed as a result of this operation. - public abstract bool RetainAll(ICollection c); + /// + /// Retains only the elements in this set that are contained in the specified collection. + /// + /// Collection that defines the set of elements to be retained. + /// if this set changed as a result of this operation. + public abstract bool RetainAll(ICollection c); - /// - /// Returns a clone of the Set instance. This will work for derived Set - /// classes if the derived class implements a constructor that takes no arguments. - /// - /// A clone of this object. - public virtual object Clone() - { - Set newSet = (Set) Activator.CreateInstance(this.GetType()); - newSet.AddAll(this); - return newSet; - } + /// + /// Returns a clone of the Set instance. This will work for derived Set + /// classes if the derived class implements a constructor that takes no arguments. + /// + /// A clone of this object. + public virtual object Clone() + { + Set newSet = (Set)Activator.CreateInstance(this.GetType()); + newSet.AddAll(this); + return newSet; + } - /// - /// Copies the elements in the Set to an array. The type of array needs - /// to be compatible with the objects in the Set, obviously. - /// - /// An array that will be the target of the copy operation. - /// The zero-based index where copying will start. - public abstract void CopyTo(T[] array, int index); + /// + /// Copies the elements in the Set to an array. The type of array needs + /// to be compatible with the objects in the Set, obviously. + /// + /// An array that will be the target of the copy operation. + /// The zero-based index where copying will start. + public abstract void CopyTo(T[] array, int index); - /// - /// The number of elements currently contained in this collection. - /// - public abstract int Count { get; } + /// + /// The number of elements currently contained in this collection. + /// + public abstract int Count { get; } - /// - /// Returns if the Set is synchronized across threads. Note that - /// enumeration is inherently not thread-safe. Use the SyncRoot to lock the - /// object during enumeration. - /// - public abstract bool IsSynchronized { get; } + /// + /// Returns if the Set is synchronized across threads. Note that + /// enumeration is inherently not thread-safe. Use the SyncRoot to lock the + /// object during enumeration. + /// + public abstract bool IsSynchronized { get; } - /// - /// An object that can be used to synchronize this collection to make it thread-safe. - /// When implementing this, if your object uses a base object, like an IDictionary, - /// or anything that has a SyncRoot, return that object instead of "this". - /// - public abstract object SyncRoot { get; } + /// + /// An object that can be used to synchronize this collection to make it thread-safe. + /// When implementing this, if your object uses a base object, like an IDictionary, + /// or anything that has a SyncRoot, return that object instead of "this". + /// + public abstract object SyncRoot { get; } - /// - /// Gets an enumerator for the elements in the Set. - /// - /// An IEnumerator over the elements in the Set. - public abstract IEnumerator GetEnumerator(); + /// + /// Gets an enumerator for the elements in the Set. + /// + /// An IEnumerator over the elements in the Set. + public abstract IEnumerator GetEnumerator(); - /// - /// Indicates whether the given instance is read-only or not - /// - /// - /// if the ISet is read-only; otherwise, . - /// In the default implementation of Set, this property always returns false. - /// - public virtual bool IsReadOnly - { - get { return false; } - } + /// + /// Indicates whether the given instance is read-only or not + /// + /// + /// if the ISet is read-only; otherwise, . + /// In the default implementation of Set, this property always returns false. + /// + public virtual bool IsReadOnly + { + get { return false; } + } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } - void ICollection.Add(T item) - { - this.Add(item); - } + void ICollection.Add(T item) + { + this.Add(item); + } - #region Protected helpers + #region Protected helpers - /// - /// Performs CopyTo when called trhough non-generic ISet (ICollection) interface - /// - /// - /// - protected abstract void NonGenericCopyTo(Array array, int index); + /// + /// Performs CopyTo when called trhough non-generic ISet (ICollection) interface + /// + /// + /// + protected abstract void NonGenericCopyTo(Array array, int index); - /// - /// Performs Union when called trhough non-generic ISet interface - /// - /// - /// - protected virtual ISet NonGenericUnion(ISet a) - { - ISet resultSet = (ISet) this.Clone(); - if (a != null) - resultSet.AddAll(a); - return resultSet; - } + /// + /// Performs Union when called trhough non-generic ISet interface + /// + /// + /// + protected virtual ISet NonGenericUnion(ISet a) + { + ISet resultSet = (ISet)this.Clone(); + if (a != null) + resultSet.AddAll(a); + return resultSet; + } - /// - /// Performs Minus when called trhough non-generic ISet interface - /// - /// - /// - protected virtual ISet NonGenericMinus(ISet a) - { - ISet resultSet = (ISet) this.Clone(); - if (a != null) - resultSet.RemoveAll(a); - return resultSet; - } + /// + /// Performs Minus when called trhough non-generic ISet interface + /// + /// + /// + protected virtual ISet NonGenericMinus(ISet a) + { + ISet resultSet = (ISet)this.Clone(); + if (a != null) + resultSet.RemoveAll(a); + return resultSet; + } - /// - /// Performs Intersect when called trhough non-generic ISet interface - /// - /// - /// - protected virtual ISet NonGenericIntersect(ISet a) - { - ISet resultSet = (ISet) this.Clone(); - if (a != null) - resultSet.RetainAll(a); - else - resultSet.Clear(); - return resultSet; - } + /// + /// Performs Intersect when called trhough non-generic ISet interface + /// + /// + /// + protected virtual ISet NonGenericIntersect(ISet a) + { + ISet resultSet = (ISet)this.Clone(); + if (a != null) + resultSet.RetainAll(a); + else + resultSet.Clear(); + return resultSet; + } - /// - /// Performs ExclusiveOr when called trhough non-generic ISet interface - /// - /// - /// - protected virtual ISet NonGenericExclusiveOr(ISet a) - { - ISet resultSet = (ISet) this.Clone(); - foreach (object element in a) - { - if (resultSet.Contains(element)) - resultSet.Remove(element); - else - resultSet.Add(element); - } - return resultSet; - } + /// + /// Performs ExclusiveOr when called trhough non-generic ISet interface + /// + /// + /// + protected virtual ISet NonGenericExclusiveOr(ISet a) + { + ISet resultSet = (ISet)this.Clone(); + foreach (object element in a) + { + if (resultSet.Contains(element)) + resultSet.Remove(element); + else + resultSet.Add(element); + } + return resultSet; + } - #endregion Protected helpers + #endregion Protected helpers - #region ISet implementation + #region ISet implementation - void ICollection.CopyTo(Array array, int index) - { - this.NonGenericCopyTo(array, index); - } + void ICollection.CopyTo(Array array, int index) + { + this.NonGenericCopyTo(array, index); + } - ISet ISet.Union(ISet a) - { - return this.NonGenericUnion(a); - } + ISet ISet.Union(ISet a) + { + return this.NonGenericUnion(a); + } - ISet ISet.Intersect(ISet a) - { - return NonGenericIntersect(a); - } + ISet ISet.Intersect(ISet a) + { + return NonGenericIntersect(a); + } - ISet ISet.Minus(ISet a) - { - return NonGenericMinus(a); - } + ISet ISet.Minus(ISet a) + { + return NonGenericMinus(a); + } - ISet ISet.ExclusiveOr(ISet a) - { - return NonGenericExclusiveOr(a); - } + ISet ISet.ExclusiveOr(ISet a) + { + return NonGenericExclusiveOr(a); + } - bool ISet.Contains(object o) - { - if (o is T) - return this.Contains((T) o); - else - return false; - } + bool ISet.Contains(object o) + { + if (o is T) + return this.Contains((T)o); + else + return false; + } - bool ISet.ContainsAll(ICollection c) - { - ICollection col = new List(c.Count); - foreach (object o in c) - { - if (o is T) - col.Add((T) o); - else - return false; - } - return this.ContainsAll(col); - } + bool ISet.ContainsAll(ICollection c) + { + ICollection col = new List(c.Count); + foreach (object o in c) + { + if (o is T) + col.Add((T)o); + else + return false; + } + return this.ContainsAll(col); + } - bool ISet.Add(object o) - { - return this.Add((T) o); - } + bool ISet.Add(object o) + { + return this.Add((T)o); + } - bool ISet.AddAll(ICollection c) - { - bool changed = false; - foreach (T obj in c) - changed |= this.Add(obj); - return changed; - } + bool ISet.AddAll(ICollection c) + { + bool changed = false; + foreach (T obj in c) + changed |= this.Add(obj); + return changed; + } - bool ISet.Remove(object o) - { - if (o is T) - return this.Remove((T) o); - else - return false; - } + bool ISet.Remove(object o) + { + if (o is T) + return this.Remove((T)o); + else + return false; + } - bool ISet.RemoveAll(ICollection c) - { - ICollection col = new List(c.Count); - foreach (object o in c) - { - if (o is T) - col.Add((T) o); - } - return this.RemoveAll(col); - } + bool ISet.RemoveAll(ICollection c) + { + ICollection col = new List(c.Count); + foreach (object o in c) + { + if (o is T) + col.Add((T)o); + } + return this.RemoveAll(col); + } - bool ISet.RetainAll(ICollection c) - { - ICollection col = new List(c.Count); - foreach (object o in c) - { - if (o is T) - col.Add((T) o); - } - return this.RetainAll(col); - } + bool ISet.RetainAll(ICollection c) + { + ICollection col = new List(c.Count); + foreach (object o in c) + { + if (o is T) + col.Add((T)o); + } + return this.RetainAll(col); + } - #endregion ISet implementation - } + #endregion ISet implementation + } } + + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Collections/Generic/SortedSet.cs b/src/Spring/Spring.Core/Collections/Generic/SortedSet.cs index 6e3c20c6..d7f96382 100644 --- a/src/Spring/Spring.Core/Collections/Generic/SortedSet.cs +++ b/src/Spring/Spring.Core/Collections/Generic/SortedSet.cs @@ -1,69 +1,76 @@ /* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */ + +#if NET_2_0 + + using System; using System.Collections; using System.Collections.Generic; namespace Spring.Collections.Generic { - /// - /// Implements a Set based on a sorted tree. This gives good performance for operations on very - /// large data-sets, though not as good - asymptotically - as a HashedSet. However, iteration - /// occurs in order. Elements that you put into this type of collection must implement IComparable, - /// and they must actually be comparable. You can't mix string and int values, for example. - /// - [Serializable] - public class SortedSet : DictionarySet - { - /// - /// Creates a new set instance based on a sorted tree. - /// - public SortedSet() - { - InternalDictionary = new SortedDictionary(); - } + /// + /// Implements a Set based on a sorted tree. This gives good performance for operations on very + /// large data-sets, though not as good - asymptotically - as a HashedSet. However, iteration + /// occurs in order. Elements that you put into this type of collection must implement IComparable, + /// and they must actually be comparable. You can't mix string and int values, for example. + /// + [Serializable] + public class SortedSet : DictionarySet + { + /// + /// Creates a new set instance based on a sorted tree. + /// + public SortedSet() + { + InternalDictionary = new SortedDictionary(); + } - /// - /// Creates a new set instance based on a sorted tree. - /// - /// The to use for sorting. - public SortedSet(IComparer comparer) - { - InternalDictionary = new SortedList(comparer); - } + /// + /// Creates a new set instance based on a sorted tree. + /// + /// The to use for sorting. + public SortedSet(IComparer comparer) + { + InternalDictionary = new SortedList(comparer); + } - /// - /// Creates a new set instance based on a sorted tree and - /// initializes it based on a collection of elements. - /// - /// A collection of elements that defines the initial set contents. - public SortedSet(ICollection initialValues) - : this() - { - this.AddAll(initialValues); - } + /// + /// Creates a new set instance based on a sorted tree and + /// initializes it based on a collection of elements. + /// + /// A collection of elements that defines the initial set contents. + public SortedSet(ICollection initialValues) + : this() + { + this.AddAll(initialValues); + } - /// - /// Creates a new set instance based on a sorted tree and - /// initializes it based on a collection of elements. - /// - /// A collection of elements that defines the initial set contents. - public SortedSet(ICollection initialValues) - : this() - { - ((ISet) this).AddAll(initialValues); - } + /// + /// Creates a new set instance based on a sorted tree and + /// initializes it based on a collection of elements. + /// + /// A collection of elements that defines the initial set contents. + public SortedSet(ICollection initialValues) + : this() + { + ((ISet)this).AddAll(initialValues); + } - /// - /// Creates a new set instance based on a sorted tree and - /// initializes it based on a collection of elements. - /// - /// A collection of elements that defines the initial set contents. - /// The to use for sorting. - public SortedSet(ICollection initialValues, IComparer comparer) - : this(comparer) - { - this.AddAll(initialValues); - } - } + /// + /// Creates a new set instance based on a sorted tree and + /// initializes it based on a collection of elements. + /// + /// A collection of elements that defines the initial set contents. + /// The to use for sorting. + public SortedSet(ICollection initialValues, IComparer comparer) + : this(comparer) + { + this.AddAll(initialValues); + } + } } + + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Collections/Generic/SynchronizedSet.cs b/src/Spring/Spring.Core/Collections/Generic/SynchronizedSet.cs index ee6c77cd..b99bb35e 100644 --- a/src/Spring/Spring.Core/Collections/Generic/SynchronizedSet.cs +++ b/src/Spring/Spring.Core/Collections/Generic/SynchronizedSet.cs @@ -1,262 +1,269 @@ /* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */ + +#if NET_2_0 + + using System; using System.Collections; using System.Collections.Generic; namespace Spring.Collections.Generic { - /// - ///

Implements a thread-safe Set wrapper. The implementation is extremely conservative, - /// serializing critical sections to prevent possible deadlocks, and locking on everything. - /// The one exception is for enumeration, which is inherently not thread-safe. For this, you - /// have to lock the SyncRoot object for the duration of the enumeration.

- ///
- [Serializable] - public sealed class SynchronizedSet : Set - { - private ISet mBasisSet; - private object mSyncRoot; + /// + ///

Implements a thread-safe Set wrapper. The implementation is extremely conservative, + /// serializing critical sections to prevent possible deadlocks, and locking on everything. + /// The one exception is for enumeration, which is inherently not thread-safe. For this, you + /// have to lock the SyncRoot object for the duration of the enumeration.

+ ///
+ [Serializable] + public sealed class SynchronizedSet : Set + { + private ISet mBasisSet; + private object mSyncRoot; - /// - /// Constructs a thread-safe Set wrapper. - /// - /// The Set object that this object will wrap. - public SynchronizedSet(ISet basisSet) - { - mBasisSet = basisSet; - mSyncRoot = ((ICollection) basisSet).SyncRoot; - if (mSyncRoot == null) - throw new NullReferenceException("The Set you specified returned a null SyncRoot."); - } + /// + /// Constructs a thread-safe Set wrapper. + /// + /// The Set object that this object will wrap. + public SynchronizedSet(ISet basisSet) + { + mBasisSet = basisSet; + mSyncRoot = ((ICollection)basisSet).SyncRoot; + if (mSyncRoot == null) + throw new NullReferenceException("The Set you specified returned a null SyncRoot."); + } - /// - /// Adds the specified element to this set if it is not already present. - /// - /// The object to add to the set. - /// is the object was added, if it was already present. - public override sealed bool Add(T o) - { - lock (mSyncRoot) - { - return mBasisSet.Add(o); - } - } + /// + /// Adds the specified element to this set if it is not already present. + /// + /// The object to add to the set. + /// is the object was added, if it was already present. + public override sealed bool Add(T o) + { + lock (mSyncRoot) + { + return mBasisSet.Add(o); + } + } - /// - /// Adds all the elements in the specified collection to the set if they are not already present. - /// - /// A collection of objects to add to the set. - /// is the set changed as a result of this operation, if not. - public override sealed bool AddAll(ICollection c) - { - Set temp; - lock (((ICollection) c).SyncRoot) - { - temp = new HashedSet(c); - } + /// + /// Adds all the elements in the specified collection to the set if they are not already present. + /// + /// A collection of objects to add to the set. + /// is the set changed as a result of this operation, if not. + public override sealed bool AddAll(ICollection c) + { + Set temp; + lock (((ICollection)c).SyncRoot) + { + temp = new HashedSet(c); + } - lock (mSyncRoot) - { - return mBasisSet.AddAll(temp); - } - } + lock (mSyncRoot) + { + return mBasisSet.AddAll(temp); + } + } - /// - /// Removes all objects from the set. - /// - public override sealed void Clear() - { - lock (mSyncRoot) - { - mBasisSet.Clear(); - } - } + /// + /// Removes all objects from the set. + /// + public override sealed void Clear() + { + lock (mSyncRoot) + { + mBasisSet.Clear(); + } + } - /// - /// Returns if this set contains the specified element. - /// - /// The element to look for. - /// if this set contains the specified element, otherwise. - public override sealed bool Contains(T o) - { - lock (mSyncRoot) - { - return mBasisSet.Contains(o); - } - } + /// + /// Returns if this set contains the specified element. + /// + /// The element to look for. + /// if this set contains the specified element, otherwise. + public override sealed bool Contains(T o) + { + lock (mSyncRoot) + { + return mBasisSet.Contains(o); + } + } - /// - /// Returns if the set contains all the elements in the specified collection. - /// - /// A collection of objects. - /// if the set contains all the elements in the specified collection, otherwise. - public override sealed bool ContainsAll(ICollection c) - { - Set temp; - lock (((ICollection) c).SyncRoot) - { - temp = new HashedSet(c); - } - lock (mSyncRoot) - { - return mBasisSet.ContainsAll(temp); - } - } + /// + /// Returns if the set contains all the elements in the specified collection. + /// + /// A collection of objects. + /// if the set contains all the elements in the specified collection, otherwise. + public override sealed bool ContainsAll(ICollection c) + { + Set temp; + lock (((ICollection)c).SyncRoot) + { + temp = new HashedSet(c); + } + lock (mSyncRoot) + { + return mBasisSet.ContainsAll(temp); + } + } - /// - /// Returns if this set contains no elements. - /// - public override sealed bool IsEmpty - { - get - { - lock (mSyncRoot) - { - return mBasisSet.IsEmpty; - } - } - } + /// + /// Returns if this set contains no elements. + /// + public override sealed bool IsEmpty + { + get + { + lock (mSyncRoot) + { + return mBasisSet.IsEmpty; + } + } + } - /// - /// Removes the specified element from the set. - /// - /// The element to be removed. - /// if the set contained the specified element, otherwise. - public override sealed bool Remove(T o) - { - lock (mSyncRoot) - { - return mBasisSet.Remove(o); - } - } + /// + /// Removes the specified element from the set. + /// + /// The element to be removed. + /// if the set contained the specified element, otherwise. + public override sealed bool Remove(T o) + { + lock (mSyncRoot) + { + return mBasisSet.Remove(o); + } + } - /// - /// Remove all the specified elements from this set, if they exist in this set. - /// - /// A collection of elements to remove. - /// if the set was modified as a result of this operation. - public override sealed bool RemoveAll(ICollection c) - { - Set temp; - lock (((ICollection) c).SyncRoot) - { - temp = new HashedSet(c); - } - lock (mSyncRoot) - { - return mBasisSet.RemoveAll(temp); - } - } + /// + /// Remove all the specified elements from this set, if they exist in this set. + /// + /// A collection of elements to remove. + /// if the set was modified as a result of this operation. + public override sealed bool RemoveAll(ICollection c) + { + Set temp; + lock (((ICollection)c).SyncRoot) + { + temp = new HashedSet(c); + } + lock (mSyncRoot) + { + return mBasisSet.RemoveAll(temp); + } + } - /// - /// Retains only the elements in this set that are contained in the specified collection. - /// - /// Collection that defines the set of elements to be retained. - /// if this set changed as a result of this operation. - public override sealed bool RetainAll(ICollection c) - { - Set temp; - lock (((ICollection) c).SyncRoot) - { - temp = new HashedSet(c); - } - lock (mSyncRoot) - { - return mBasisSet.RetainAll(temp); - } - } + /// + /// Retains only the elements in this set that are contained in the specified collection. + /// + /// Collection that defines the set of elements to be retained. + /// if this set changed as a result of this operation. + public override sealed bool RetainAll(ICollection c) + { + Set temp; + lock (((ICollection)c).SyncRoot) + { + temp = new HashedSet(c); + } + lock (mSyncRoot) + { + return mBasisSet.RetainAll(temp); + } + } - /// - /// Copies the elements in the Set to an array. The type of array needs - /// to be compatible with the objects in the Set, obviously. - /// - /// An array that will be the target of the copy operation. - /// The zero-based index where copying will start. - public override sealed void CopyTo(T[] array, int index) - { - lock (mSyncRoot) - { - mBasisSet.CopyTo(array, index); - } - } + /// + /// Copies the elements in the Set to an array. The type of array needs + /// to be compatible with the objects in the Set, obviously. + /// + /// An array that will be the target of the copy operation. + /// The zero-based index where copying will start. + public override sealed void CopyTo(T[] array, int index) + { + lock (mSyncRoot) + { + mBasisSet.CopyTo(array, index); + } + } - /// - /// The number of elements contained in this collection. - /// - public override sealed int Count - { - get - { - lock (mSyncRoot) - { - return mBasisSet.Count; - } - } - } + /// + /// The number of elements contained in this collection. + /// + public override sealed int Count + { + get + { + lock (mSyncRoot) + { + return mBasisSet.Count; + } + } + } - /// - /// Returns , indicating that this object is thread-safe. The exception to this - /// is enumeration, which is inherently not thread-safe. Use the SyncRoot object to - /// lock this object for the entire duration of the enumeration. - /// - public override sealed bool IsSynchronized - { - get { return true; } - } + /// + /// Returns , indicating that this object is thread-safe. The exception to this + /// is enumeration, which is inherently not thread-safe. Use the SyncRoot object to + /// lock this object for the entire duration of the enumeration. + /// + public override sealed bool IsSynchronized + { + get { return true; } + } - /// - /// Returns an object that can be used to synchronize the Set between threads. - /// - public override sealed object SyncRoot - { - get { return mSyncRoot; } - } + /// + /// Returns an object that can be used to synchronize the Set between threads. + /// + public override sealed object SyncRoot + { + get { return mSyncRoot; } + } - /// - /// Enumeration is, by definition, not thread-safe. Use a lock on the SyncRoot - /// to synchronize the entire enumeration process. - /// - /// - public override sealed IEnumerator GetEnumerator() - { - return mBasisSet.GetEnumerator(); - } + /// + /// Enumeration is, by definition, not thread-safe. Use a lock on the SyncRoot + /// to synchronize the entire enumeration process. + /// + /// + public override sealed IEnumerator GetEnumerator() + { + return mBasisSet.GetEnumerator(); + } - /// - /// Returns a clone of the Set instance. - /// - /// A clone of this object. - public override object Clone() - { - return new SynchronizedSet((ISet) mBasisSet.Clone()); - } + /// + /// Returns a clone of the Set instance. + /// + /// A clone of this object. + public override object Clone() + { + return new SynchronizedSet((ISet)mBasisSet.Clone()); + } - /// - /// Indicates whether given instace is read-only or not - /// - public override bool IsReadOnly - { - get - { - lock (mSyncRoot) - { - return mBasisSet.IsReadOnly; - } - } - } + /// + /// Indicates whether given instace is read-only or not + /// + public override bool IsReadOnly + { + get + { + lock (mSyncRoot) + { + return mBasisSet.IsReadOnly; + } + } + } - /// - /// Performs CopyTo when called trhough non-generic ISet (ICollection) interface - /// - /// - /// - protected override void NonGenericCopyTo(Array array, int index) - { - lock (mSyncRoot) - { - ((ICollection) this.mBasisSet).CopyTo(array, index); - } - } - } + /// + /// Performs CopyTo when called trhough non-generic ISet (ICollection) interface + /// + /// + /// + protected override void NonGenericCopyTo(Array array, int index) + { + lock (mSyncRoot) + { + ((ICollection)this.mBasisSet).CopyTo(array, index); + } + } + } } + + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Objects/Factory/Parsing/FailFastProblemReporter.cs b/src/Spring/Spring.Core/Objects/Factory/Parsing/FailFastProblemReporter.cs index 54211e89..8564f8e6 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Parsing/FailFastProblemReporter.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Parsing/FailFastProblemReporter.cs @@ -1,4 +1,7 @@ -using System; +#if NET_2_0 + + +using System; using System.Collections.Generic; using System.Text; using Common.Logging; @@ -29,8 +32,11 @@ namespace Spring.Objects.Factory.Parsing public void Warning(Problem problem) { _logger.Warn(problem.Message); - + } } } + + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Objects/Factory/Parsing/IProblemReporter.cs b/src/Spring/Spring.Core/Objects/Factory/Parsing/IProblemReporter.cs index 9d265b99..fdb1a569 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Parsing/IProblemReporter.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Parsing/IProblemReporter.cs @@ -1,5 +1,6 @@ -using System; -using System.Collections.Generic; +#if NET_2_0 + +using System; using System.Text; namespace Spring.Objects.Factory.Parsing @@ -11,3 +12,5 @@ namespace Spring.Objects.Factory.Parsing void Error(Problem problem); } } + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Objects/Factory/Parsing/Location.cs b/src/Spring/Spring.Core/Objects/Factory/Parsing/Location.cs index 6ca9a321..ada96e78 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Parsing/Location.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Parsing/Location.cs @@ -1,4 +1,7 @@ -using System; +#if NET_2_0 + + +using System; using System.Collections.Generic; using System.Text; using Spring.Core.IO; @@ -31,7 +34,7 @@ namespace Spring.Objects.Factory.Parsing public Location(IResource resource) : this(resource, null) { - + } public IResource Resource { @@ -51,3 +54,5 @@ namespace Spring.Objects.Factory.Parsing } } + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Objects/Factory/Parsing/ObjectDefinitionParsingException.cs b/src/Spring/Spring.Core/Objects/Factory/Parsing/ObjectDefinitionParsingException.cs index 31c28370..5ce8f69d 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Parsing/ObjectDefinitionParsingException.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Parsing/ObjectDefinitionParsingException.cs @@ -1,7 +1,11 @@ -using System; +#if NET_2_0 + + +using System; using System.Collections.Generic; using System.Text; using System.Runtime.Serialization; +using Spring.Core.IO; namespace Spring.Objects.Factory.Parsing { @@ -17,7 +21,132 @@ namespace Spring.Objects.Factory.Parsing public ObjectDefinitionParsingException(Problem problem) : base(problem.Location.Resource, problem.ResourceDescription, problem.Message) { + + } + /// + /// Creates a new instance of the ObjectDefinitionParsingException class. + /// + public ObjectDefinitionParsingException() + { + + } + /// + /// Creates a new instance of the ObjectDefinitionParsingException class. + /// + /// + /// A message about the exception. + /// + public ObjectDefinitionParsingException(string message) + : base(message) + { } + /// + /// Creates a new instance of the ObjectDefinitionParsingException class. + /// + /// + /// The description of the resource that the object definition came from + /// + /// + /// The name of the object that triggered the exception. + /// + /// + /// A message about the exception. + /// + public ObjectDefinitionParsingException(string resourceDescription, string name, string message) + : base(resourceDescription, name, message) + { + + } + /// + /// Initializes a new instance of the class. + /// + /// + /// The description of the resource that the object definition came from + /// + /// The detail message (used as exception message as-is) + /// The root cause. (may be null + public ObjectDefinitionParsingException(string resourceDescription, string msg, Exception cause) + : base(resourceDescription, msg, cause) + { + + } + /// + /// Creates a new instance of the ObjectDefinitionParsingException class. + /// + /// + /// The resource location (e.g. an XML object definition file) associated + /// with the offending object definition. + /// + /// + /// A message about the exception. + /// + /// + /// The name of the object that triggered the exception. + /// + public ObjectDefinitionParsingException(IResource resourceLocation, string name, string message) + : base(resourceLocation, name, message) + { + + } + /// + /// Creates a new instance of the ObjectDefinitionParsingException class. + /// + /// + /// The resource location (e.g. an XML object definition file) associated + /// with the offending object definition. + /// + /// + /// A message about the exception. + /// + /// + /// The name of the object that triggered the exception. + /// + /// + /// The root exception that is being wrapped. + /// + public ObjectDefinitionParsingException(IResource resourceLocation, string name, string message, Exception rootCause) + : base(resourceLocation, name, message, rootCause) + { + + } + /// + /// Creates a new instance of the ObjectDefinitionParsingException class. + /// + /// + /// The description of the resource that the object definition came from + /// + /// + /// A message about the exception. + /// + /// + /// The name of the object that triggered the exception. + /// + /// + /// The root exception that is being wrapped. + /// + public ObjectDefinitionParsingException(string resourceDescription, string name, string message, Exception rootCause) + : base(resourceDescription, name, message, rootCause) + { + + } + /// + /// Creates a new instance of the ObjectDefinitionParsingException class. + /// + /// + /// A message about the exception. + /// + /// + /// The root exception that is being wrapped. + /// + public ObjectDefinitionParsingException(string message, Exception rootCause) + : base(message, rootCause) + { + + } + } } + + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Objects/Factory/Parsing/Problem.cs b/src/Spring/Spring.Core/Objects/Factory/Parsing/Problem.cs index 7fa96f46..1af67273 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Parsing/Problem.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Parsing/Problem.cs @@ -1,4 +1,7 @@ -using System; +#if NET_2_0 + + +using System; using System.Collections.Generic; using System.Text; using Spring.Core.IO; @@ -14,11 +17,12 @@ namespace Spring.Objects.Factory.Parsing private Exception _rootCause; + /// - /// Initializes a new instance of the Problem class. + /// Initializes a new instance of the class. /// - /// - /// + /// The message. + /// The location. public Problem(string message, Location location) : this(message, location, null) { @@ -59,7 +63,7 @@ namespace Spring.Objects.Factory.Parsing public string ResourceDescription { - get { return _location.Resource!=null ? _location.Resource.Description : string.Empty; } + get { return _location.Resource != null ? _location.Resource.Description : string.Empty; } } public override string ToString() @@ -76,3 +80,5 @@ namespace Spring.Objects.Factory.Parsing } } + +#endif \ No newline at end of file diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistryPostProcessor.cs b/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistryPostProcessor.cs index 292d4fc2..8eeeccee 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistryPostProcessor.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistryPostProcessor.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Spring.Objects.Factory.Config; namespace Spring.Objects.Factory.Support @@ -9,4 +7,4 @@ namespace Spring.Objects.Factory.Support { void PostProcessObjectDefinitionRegistry(IObjectDefinitionRegistry registry); } -} +} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Util/ReflectionUtils.cs b/src/Spring/Spring.Core/Util/ReflectionUtils.cs index 1e85ac54..dc7e5e48 100644 --- a/src/Spring/Spring.Core/Util/ReflectionUtils.cs +++ b/src/Spring/Spring.Core/Util/ReflectionUtils.cs @@ -63,7 +63,7 @@ namespace Spring.Util /// Avoid BeforeFieldInit problem /// static ReflectionUtils() - {} + { } /// /// Checks, if the specified type is a nullable @@ -1074,7 +1074,7 @@ namespace Spring.Util private static object ConvertConstructorArgsToObjectArrayIfNecessary(object value) { - if (value == null) + if (value == null) return value; IList constructorArguments = value as IList; @@ -1083,7 +1083,7 @@ namespace Spring.Util return value; object[] arguments = new object[constructorArguments.Count]; - + for (int i = 0; i < constructorArguments.Count; i++) { arguments[i] = constructorArguments[i].Value; @@ -1091,7 +1091,7 @@ namespace Spring.Util return arguments; } - + #endif /// @@ -1429,7 +1429,7 @@ namespace Spring.Util { if (obj == null) throw new ArgumentNullException("obj", "obj is null."); - if (String.IsNullOrEmpty(fieldName)) + if (StringUtils.IsNullOrEmpty(fieldName)) throw new ArgumentException("fieldName is null or empty.", "fieldName"); FieldInfo f = obj.GetType().GetField(fieldName, BindingFlags.SetField | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); @@ -1453,7 +1453,7 @@ namespace Spring.Util if (obj == null) throw new ArgumentNullException("obj", "obj is null."); - if (String.IsNullOrEmpty(fieldName)) + if (StringUtils.IsNullOrEmpty(fieldName)) throw new ArgumentException("fieldName is null or empty.", "fieldName"); if (fieldValue == null) throw new ArgumentNullException("fieldValue", "fieldValue is null.");