-#if NET_2_0
-/*\r
- Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft\r
- Permission is hereby granted, free of charge, to any person obtaining a copy\r
- of this software and associated documentation files (the "Software"), to deal\r
- in the Software without restriction, including without limitation the rights\r
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
- copies of the Software, and to permit persons to whom the Software is\r
- furnished to do so, subject to the following conditions:\r
- \r
- The above copyright notice and this permission notice shall be included in\r
- all copies or substantial portions of the Software.\r
- \r
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
- SOFTWARE.\r
-*/\r
-\r
-using System;\r
-using SCG = System.Collections.Generic;\r
-\r
-namespace C5\r
-{\r
- /// <summary>\r
- /// A sorted generic dictionary based on a red-black tree set.\r
- /// </summary>\r
- public class TreeDictionary<K, V> : SortedDictionaryBase<K, V>, IDictionary<K, V>, ISortedDictionary<K, V>\r
- {\r
-\r
- #region Constructors\r
-\r
- /// <summary>\r
- /// Create a red-black tree dictionary using the natural comparer for keys.\r
- /// <exception cref="ArgumentException"/> if the key type K is not comparable.\r
- /// </summary>\r
- public TreeDictionary() : this(Comparer<K>.Default, EqualityComparer<K>.Default) { }\r
-\r
- /// <summary>\r
- /// Create a red-black tree dictionary using an external comparer for keys.\r
- /// </summary>\r
- /// <param name="comparer">The external comparer</param>\r
- public TreeDictionary(SCG.IComparer<K> comparer) : this(comparer, new ComparerZeroHashCodeEqualityComparer<K>(comparer)) { }\r
-\r
- TreeDictionary(SCG.IComparer<K> comparer, SCG.IEqualityComparer<K> equalityComparer) : base(comparer,equalityComparer)\r
- {\r
- pairs = sortedpairs = new TreeSet<KeyValuePair<K, V>>(new KeyValuePairComparer<K, V>(comparer));\r
- }\r
-\r
- #endregion\r
-\r
- //TODO: put in interface\r
- /// <summary>\r
- /// Make a snapshot of the current state of this dictionary\r
- /// </summary>\r
- /// <returns>The snapshot</returns>\r
- [Tested]\r
- public SCG.IEnumerable<KeyValuePair<K, V>> Snapshot()\r
- {\r
- TreeDictionary<K, V> res = (TreeDictionary<K, V>)MemberwiseClone();\r
-\r
- res.pairs = (TreeSet<KeyValuePair<K, V>>)((TreeSet<KeyValuePair<K, V>>)sortedpairs).Snapshot();\r
- return res;\r
- }\r
-\r
- /// <summary>\r
- /// \r
- /// </summary>\r
- /// <returns></returns>\r
- public override object Clone()\r
- {\r
- TreeDictionary<K, V> clone = new TreeDictionary<K, V>(Comparer, EqualityComparer);\r
- clone.sortedpairs.AddSorted(sortedpairs);\r
- return clone;\r
- }\r
-\r
- }\r
-}
-#endif
+/*
+ Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+using System;
+using SCG = System.Collections.Generic;
+
+namespace C5
+{
+ /// <summary>
+ /// A sorted generic dictionary based on a red-black tree set.
+ /// </summary>
+ [Serializable]
+ public class TreeDictionary<K, V> : SortedDictionaryBase<K, V>, IDictionary<K, V>, ISortedDictionary<K, V>
+ {
+
+ #region Constructors
+
+ /// <summary>
+ /// Create a red-black tree dictionary using the natural comparer for keys.
+ /// <exception cref="ArgumentException"/> if the key type K is not comparable.
+ /// </summary>
+ public TreeDictionary() : this(Comparer<K>.Default, EqualityComparer<K>.Default) { }
+
+ /// <summary>
+ /// Create a red-black tree dictionary using an external comparer for keys.
+ /// </summary>
+ /// <param name="comparer">The external comparer</param>
+ public TreeDictionary(SCG.IComparer<K> comparer) : this(comparer, new ComparerZeroHashCodeEqualityComparer<K>(comparer)) { }
+
+ TreeDictionary(SCG.IComparer<K> comparer, SCG.IEqualityComparer<K> equalityComparer) : base(comparer,equalityComparer)
+ {
+ pairs = sortedpairs = new TreeSet<KeyValuePair<K, V>>(new KeyValuePairComparer<K, V>(comparer));
+ }
+
+ #endregion
+
+ //TODO: put in interface
+ /// <summary>
+ /// Make a snapshot of the current state of this dictionary
+ /// </summary>
+ /// <returns>The snapshot</returns>
+ [Tested]
+ public SCG.IEnumerable<KeyValuePair<K, V>> Snapshot()
+ {
+ TreeDictionary<K, V> res = (TreeDictionary<K, V>)MemberwiseClone();
+
+ res.pairs = (TreeSet<KeyValuePair<K, V>>)((TreeSet<KeyValuePair<K, V>>)sortedpairs).Snapshot();
+ return res;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <returns></returns>
+ public override object Clone()
+ {
+ TreeDictionary<K, V> clone = new TreeDictionary<K, V>(Comparer, EqualityComparer);
+ clone.sortedpairs.AddSorted(sortedpairs);
+ return clone;
+ }
+
+ }
+}
\ No newline at end of file