From 00b7326283a7c53e2d47194351a863fcf649d378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Lystr=C3=B8m?= Date: Sun, 15 Dec 2019 19:00:06 +0100 Subject: [PATCH] Guarded dictionaries return proper Keys and Values (#92) --- C5.Tests/C5.Tests.csproj | 6 +- C5.Tests/Wrappers/GuardedDictionaryTests.cs | 68 +++++++++++++ .../Wrappers/GuardedSortedDictionaryTests.cs | 76 +++++++++++++++ C5/Interfaces/ISortedDictionary.cs | 52 ++++------ C5/Wrappers/GuardedDictionary.cs | 56 ++++------- C5/Wrappers/GuardedSortedDictionary.cs | 95 +++++++------------ 6 files changed, 221 insertions(+), 132 deletions(-) create mode 100644 C5.Tests/Wrappers/GuardedDictionaryTests.cs create mode 100644 C5.Tests/Wrappers/GuardedSortedDictionaryTests.cs diff --git a/C5.Tests/C5.Tests.csproj b/C5.Tests/C5.Tests.csproj index 7b16f8ab..b0cdf704 100644 --- a/C5.Tests/C5.Tests.csproj +++ b/C5.Tests/C5.Tests.csproj @@ -1,13 +1,13 @@  - netcoreapp2.2 + netcoreapp3.1 false - - + + diff --git a/C5.Tests/Wrappers/GuardedDictionaryTests.cs b/C5.Tests/Wrappers/GuardedDictionaryTests.cs new file mode 100644 index 00000000..e4d0ba42 --- /dev/null +++ b/C5.Tests/Wrappers/GuardedDictionaryTests.cs @@ -0,0 +1,68 @@ +using NUnit.Framework; + +namespace C5.Tests.Wrappers +{ + [TestFixture] + public class GuardedDictionaryTests + { + [Test] + public void Keys_returns_GuardedCollectionValue() + { + var source = new HashDictionary + { + [1] = "one", + [2] = "two", + [3] = "three" + }; + + var guarded = new GuardedDictionary(source); + + Assert.IsAssignableFrom>(guarded.Keys); + } + + [Test] + public void Keys_returns_Keys() + { + var source = new HashDictionary + { + [1] = "one", + [2] = "two", + [3] = "three" + }; + + var guarded = new GuardedDictionary(source); + + CollectionAssert.AreEquivalent(new[] { 1, 2, 3 }, guarded.Keys); + } + + [Test] + public void Values_returns_GuardedCollectionValue() + { + var source = new HashDictionary + { + [1] = "one", + [2] = "two", + [3] = "three" + }; + + var guarded = new GuardedDictionary(source); + + Assert.IsAssignableFrom>(guarded.Values); + } + + [Test] + public void Values_returns_Values() + { + var source = new HashDictionary + { + [1] = "one", + [2] = "two", + [3] = "three" + }; + + var guarded = new GuardedDictionary(source); + + CollectionAssert.AreEquivalent(new[] { "one", "two", "three" }, guarded.Values); + } + } +} diff --git a/C5.Tests/Wrappers/GuardedSortedDictionaryTests.cs b/C5.Tests/Wrappers/GuardedSortedDictionaryTests.cs new file mode 100644 index 00000000..cf79cc14 --- /dev/null +++ b/C5.Tests/Wrappers/GuardedSortedDictionaryTests.cs @@ -0,0 +1,76 @@ +using NUnit.Framework; + +namespace C5.Tests.Wrappers +{ + [TestFixture] + public class GuardedSortedDictionaryTests + { + [Test] + public void Keys_returns_GuardedSorted() + { + var reverse = ComparerFactory.CreateComparer((a, b) => a > b ? -1 : 1); + + var source = new SortedArrayDictionary(reverse) + { + [1] = "one", + [2] = "two", + [3] = "three" + }; + + var guarded = new GuardedSortedDictionary(source); + + Assert.IsAssignableFrom>(guarded.Keys); + } + + [Test] + public void Keys_returns_Keys() + { + var reverse = ComparerFactory.CreateComparer((a, b) => a > b ? -1 : 1); + + var source = new SortedArrayDictionary(reverse) + { + [1] = "one", + [2] = "two", + [3] = "three" + }; + + var guarded = new GuardedSortedDictionary(source); + + CollectionAssert.AreEquivalent(new[] { 3, 2, 1 }, guarded.Keys); + } + + [Test] + public void Values_returns_GuardedCollectionValue() + { + var reverse = ComparerFactory.CreateComparer((a, b) => a > b ? -1 : 1); + + var source = new SortedArrayDictionary(reverse) + { + [1] = "one", + [2] = "two", + [3] = "three" + }; + + var guarded = new GuardedSortedDictionary(source); + + Assert.IsAssignableFrom>(guarded.Values); + } + + [Test] + public void Values_returns_Values() + { + var reverse = ComparerFactory.CreateComparer((a, b) => a > b ? -1 : 1); + + var source = new SortedArrayDictionary(reverse) + { + [1] = "one", + [2] = "two", + [3] = "three" + }; + + var guarded = new GuardedSortedDictionary(source); + + CollectionAssert.AreEquivalent(new[] { "one", "two", "three" }, guarded.Values); + } + } +} diff --git a/C5/Interfaces/ISortedDictionary.cs b/C5/Interfaces/ISortedDictionary.cs index 5cb677c2..9342becf 100644 --- a/C5/Interfaces/ISortedDictionary.cs +++ b/C5/Interfaces/ISortedDictionary.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using SCG = System.Collections.Generic; namespace C5 { @@ -12,14 +12,14 @@ public interface ISortedDictionary : IDictionary /// /// /// - new ISorted? Keys { get; } + new ISorted Keys { get; } /// /// Find the current least item of this sorted collection. /// /// if the collection is empty. /// The least item. - System.Collections.Generic.KeyValuePair FindMin(); + SCG.KeyValuePair FindMin(); /// @@ -27,7 +27,7 @@ public interface ISortedDictionary : IDictionary /// /// if the collection is empty. /// The removed item. - System.Collections.Generic.KeyValuePair DeleteMin(); + SCG.KeyValuePair DeleteMin(); /// @@ -35,7 +35,7 @@ public interface ISortedDictionary : IDictionary /// /// if the collection is empty. /// The largest item. - System.Collections.Generic.KeyValuePair FindMax(); + SCG.KeyValuePair FindMax(); /// @@ -43,13 +43,13 @@ public interface ISortedDictionary : IDictionary /// /// if the collection is empty. /// The removed item. - System.Collections.Generic.KeyValuePair DeleteMax(); + SCG.KeyValuePair DeleteMax(); /// /// The key comparer used by this dictionary. /// /// - System.Collections.Generic.IComparer Comparer { get; } + SCG.IComparer Comparer { get; } /// /// Find the entry in the dictionary whose key is the @@ -58,7 +58,7 @@ public interface ISortedDictionary : IDictionary /// The key /// The predecessor, if any /// True if key has a predecessor - bool TryPredecessor(K key, out System.Collections.Generic.KeyValuePair res); + bool TryPredecessor(K key, out SCG.KeyValuePair res); /// /// Find the entry in the dictionary whose key is the @@ -67,7 +67,7 @@ public interface ISortedDictionary : IDictionary /// The key /// The successor, if any /// True if the key has a successor - bool TrySuccessor(K key, out System.Collections.Generic.KeyValuePair res); + bool TrySuccessor(K key, out SCG.KeyValuePair res); /// /// Find the entry in the dictionary whose key is the @@ -76,7 +76,7 @@ public interface ISortedDictionary : IDictionary /// The key /// The predecessor, if any /// True if key has a weak predecessor - bool TryWeakPredecessor(K key, out System.Collections.Generic.KeyValuePair res); + bool TryWeakPredecessor(K key, out SCG.KeyValuePair res); /// /// Find the entry in the dictionary whose key is the @@ -85,7 +85,7 @@ public interface ISortedDictionary : IDictionary /// The key /// The weak successor, if any /// True if the key has a weak successor - bool TryWeakSuccessor(K key, out System.Collections.Generic.KeyValuePair res); + bool TryWeakSuccessor(K key, out SCG.KeyValuePair res); /// /// Find the entry with the largest key less than a given key. @@ -93,8 +93,7 @@ public interface ISortedDictionary : IDictionary /// if there is no such entry. /// The key to compare to /// The entry - System.Collections.Generic.KeyValuePair Predecessor(K key); - + SCG.KeyValuePair Predecessor(K key); /// /// Find the entry with the least key greater than a given key. @@ -102,8 +101,7 @@ public interface ISortedDictionary : IDictionary /// if there is no such entry. /// The key to compare to /// The entry - System.Collections.Generic.KeyValuePair Successor(K key); - + SCG.KeyValuePair Successor(K key); /// /// Find the entry with the largest key less than or equal to a given key. @@ -111,8 +109,7 @@ public interface ISortedDictionary : IDictionary /// if there is no such entry. /// The key to compare to /// The entry - System.Collections.Generic.KeyValuePair WeakPredecessor(K key); - + SCG.KeyValuePair WeakPredecessor(K key); /// /// Find the entry with the least key greater than or equal to a given key. @@ -120,7 +117,7 @@ public interface ISortedDictionary : IDictionary /// if there is no such entry. /// The key to compare to /// The entry - System.Collections.Generic.KeyValuePair WeakSuccessor(K key); + SCG.KeyValuePair WeakSuccessor(K key); /// /// Given a "cut" function from the items of the sorted collection to int @@ -159,7 +156,7 @@ public interface ISortedDictionary : IDictionary /// on this collection. /// True if the cut function is zero somewhere /// on this collection. - bool Cut(IComparable cutFunction, out System.Collections.Generic.KeyValuePair lowEntry, out bool lowIsValid, out System.Collections.Generic.KeyValuePair highEntry, out bool highIsValid); + bool Cut(IComparable cutFunction, out SCG.KeyValuePair lowEntry, out bool lowIsValid, out System.Collections.Generic.KeyValuePair highEntry, out bool highIsValid); /// /// Query this sorted collection for items greater than or equal to a supplied value. @@ -169,8 +166,7 @@ public interface ISortedDictionary : IDictionary /// /// The lower bound (inclusive). /// The result directed collection. - IDirectedEnumerable> RangeFrom(K bot); - + IDirectedEnumerable> RangeFrom(K bot); /// /// Query this sorted collection for items between two supplied values. @@ -181,8 +177,7 @@ public interface ISortedDictionary : IDictionary /// The lower bound (inclusive). /// The upper bound (exclusive). /// The result directed collection. - IDirectedEnumerable> RangeFromTo(K lowerBound, K upperBound); - + IDirectedEnumerable> RangeFromTo(K lowerBound, K upperBound); /// /// Query this sorted collection for items less than a supplied value. @@ -192,8 +187,7 @@ public interface ISortedDictionary : IDictionary /// /// The upper bound (exclusive). /// The result directed collection. - IDirectedEnumerable> RangeTo(K top); - + IDirectedEnumerable> RangeTo(K top); /// /// Create a directed collection with the same items as this collection. @@ -202,8 +196,7 @@ public interface ISortedDictionary : IDictionary /// invalidate the view so that further operations on the view throws InvalidView exceptions. /// /// The result directed collection. - IDirectedCollectionValue> RangeAll(); - + IDirectedCollectionValue> RangeAll(); //TODO: remove now that we assume that we can check the sorting order? /// @@ -213,8 +206,7 @@ public interface ISortedDictionary : IDictionary /// if the enumerated items turns out /// not to be in increasing order. /// The collection to add. - void AddSorted(IEnumerable> items); - + void AddSorted(SCG.IEnumerable> items); /// /// Remove all items of this collection above or at a supplied threshold. @@ -222,7 +214,6 @@ public interface ISortedDictionary : IDictionary /// The lower threshold (inclusive). void RemoveRangeFrom(K low); - /// /// Remove all items of this collection between two supplied thresholds. /// @@ -230,7 +221,6 @@ public interface ISortedDictionary : IDictionary /// The upper threshold (exclusive). void RemoveRangeFromTo(K low, K hi); - /// /// Remove all items of this collection below a supplied threshold. /// diff --git a/C5/Wrappers/GuardedDictionary.cs b/C5/Wrappers/GuardedDictionary.cs index 0e610099..248325d0 100644 --- a/C5/Wrappers/GuardedDictionary.cs +++ b/C5/Wrappers/GuardedDictionary.cs @@ -1,4 +1,5 @@ using System; +using SCG = System.Collections.Generic; namespace C5 { @@ -8,7 +9,7 @@ namespace C5 /// Suitable for wrapping a HashDictionary. /// [Serializable] - public class GuardedDictionary : GuardedCollectionValue>, IDictionary + public class GuardedDictionary : GuardedCollectionValue>, IDictionary { #region Fields @@ -32,7 +33,7 @@ public class GuardedDictionary : GuardedCollectionValue /// - public System.Collections.Generic.IEqualityComparer EqualityComparer => dict.EqualityComparer; + public SCG.IEqualityComparer EqualityComparer => dict.EqualityComparer; /// /// @@ -51,48 +52,42 @@ public V this[K key] /// True public bool IsReadOnly => true; - - //TODO: guard with a read-only wrapper? Probably so! /// /// The collection of keys of the wrapped dictionary - public ICollectionValue Keys => dict.Keys; + public ICollectionValue Keys => new GuardedCollectionValue(dict.Keys); /// /// The collection of values of the wrapped dictionary - public ICollectionValue Values => dict.Values; + public ICollectionValue Values => new GuardedCollectionValue(dict.Values); /// /// /// - public virtual Func Func => delegate (K k) { return this[k]; }; + public virtual Func Func => k => this[k]; /// /// /// since this is a read-only wrapper /// /// - public void Add(K key, V val) - { throw new ReadOnlyCollectionException(); } + public void Add(K key, V val) => throw new ReadOnlyCollectionException(); /// /// /// /// since this is a read-only wrapper /// - public void AddAll(System.Collections.Generic.IEnumerable> items) + public void AddAll(SCG.IEnumerable> items) where L : K - where W : V - { throw new ReadOnlyCollectionException(); } + where W : V => throw new ReadOnlyCollectionException(); /// /// /// since this is a read-only wrapper /// /// - public bool Remove(K key) - { throw new ReadOnlyCollectionException(); } - + public bool Remove(K key) => throw new ReadOnlyCollectionException(); /// /// @@ -100,15 +95,12 @@ public bool Remove(K key) /// /// /// - public bool Remove(K key, out V val) - { throw new ReadOnlyCollectionException(); } - + public bool Remove(K key, out V val) => throw new ReadOnlyCollectionException(); /// /// /// since this is a read-only wrapper - public void Clear() - { throw new ReadOnlyCollectionException(); } + public void Clear() => throw new ReadOnlyCollectionException(); /// /// @@ -121,14 +113,14 @@ public void Clear() /// /// The key /// True if it does - public bool Contains(K key) { return dict.Contains(key); } + public bool Contains(K key) => dict.Contains(key); /// /// /// /// /// - public bool ContainsAll(System.Collections.Generic.IEnumerable keys) where H : K { return dict.ContainsAll(keys); } + public bool ContainsAll(SCG.IEnumerable keys) where H : K => dict.ContainsAll(keys); /// /// Search for a key in the wrapped dictionary, reporting the value if found @@ -136,7 +128,7 @@ public void Clear() /// The key /// On exit: the value if found /// True if found - public bool Find(ref K key, out V val) { return dict.Find(ref key, out val); } + public bool Find(ref K key, out V val) => dict.Find(ref key, out val); /// /// @@ -144,9 +136,7 @@ public void Clear() /// /// /// - public bool Update(K key, V val) - { throw new ReadOnlyCollectionException(); } - + public bool Update(K key, V val) => throw new ReadOnlyCollectionException(); /// /// @@ -155,9 +145,7 @@ public bool Update(K key, V val) /// /// /// - public bool Update(K key, V val, out V oldval) - { throw new ReadOnlyCollectionException(); } - + public bool Update(K key, V val, out V oldval) => throw new ReadOnlyCollectionException(); /// /// @@ -165,9 +153,7 @@ public bool Update(K key, V val, out V oldval) /// /// /// - public bool FindOrAdd(K key, ref V val) - { throw new ReadOnlyCollectionException(); } - + public bool FindOrAdd(K key, ref V val) => throw new ReadOnlyCollectionException(); /// /// @@ -175,8 +161,7 @@ public bool FindOrAdd(K key, ref V val) /// /// /// - public bool UpdateOrAdd(K key, V val) - { throw new ReadOnlyCollectionException(); } + public bool UpdateOrAdd(K key, V val) => throw new ReadOnlyCollectionException(); /// /// @@ -185,8 +170,7 @@ public bool UpdateOrAdd(K key, V val) /// /// /// - public bool UpdateOrAdd(K key, V val, out V oldval) - { throw new ReadOnlyCollectionException(); } + public bool UpdateOrAdd(K key, V val, out V oldval) => throw new ReadOnlyCollectionException(); /// diff --git a/C5/Wrappers/GuardedSortedDictionary.cs b/C5/Wrappers/GuardedSortedDictionary.cs index 97ea4060..3aa21257 100644 --- a/C5/Wrappers/GuardedSortedDictionary.cs +++ b/C5/Wrappers/GuardedSortedDictionary.cs @@ -1,4 +1,5 @@ using System; +using SCG = System.Collections.Generic; namespace C5 { @@ -24,7 +25,9 @@ public class GuardedSortedDictionary : GuardedDictionary, ISortedDic /// the dictionary public GuardedSortedDictionary(ISortedDictionary sorteddict) : base(sorteddict) - { this.sorteddict = sorteddict; } + { + this.sorteddict = sorteddict; + } #endregion @@ -34,13 +37,11 @@ public GuardedSortedDictionary(ISortedDictionary sorteddict) /// The key comparer used by this dictionary. /// /// - public System.Collections.Generic.IComparer Comparer => sorteddict.Comparer; + public SCG.IComparer Comparer => sorteddict.Comparer; - /// - /// - /// - /// - public new ISorted? Keys => null; + /// + /// The collection of keys of the wrapped dictionary + public new ISorted Keys => new GuardedSorted(sorteddict.Keys); /// /// Find the entry in the dictionary whose key is the @@ -49,10 +50,7 @@ public GuardedSortedDictionary(ISortedDictionary sorteddict) /// The key /// The predecessor, if any /// True if key has a predecessor - public bool TryPredecessor(K key, out System.Collections.Generic.KeyValuePair res) - { - return sorteddict.TryPredecessor(key, out res); - } + public bool TryPredecessor(K key, out SCG.KeyValuePair res) => sorteddict.TryPredecessor(key, out res); /// /// Find the entry in the dictionary whose key is the @@ -61,10 +59,7 @@ public bool TryPredecessor(K key, out System.Collections.Generic.KeyValuePairThe key /// The successor, if any /// True if the key has a successor - public bool TrySuccessor(K key, out System.Collections.Generic.KeyValuePair res) - { - return sorteddict.TrySuccessor(key, out res); - } + public bool TrySuccessor(K key, out SCG.KeyValuePair res) => sorteddict.TrySuccessor(key, out res); /// /// Find the entry in the dictionary whose key is the @@ -73,10 +68,7 @@ public bool TrySuccessor(K key, out System.Collections.Generic.KeyValuePairThe key /// The predecessor, if any /// True if key has a weak predecessor - public bool TryWeakPredecessor(K key, out System.Collections.Generic.KeyValuePair res) - { - return sorteddict.TryWeakPredecessor(key, out res); - } + public bool TryWeakPredecessor(K key, out SCG.KeyValuePair res) => sorteddict.TryWeakPredecessor(key, out res); /// /// Find the entry in the dictionary whose key is the @@ -85,10 +77,7 @@ public bool TryWeakPredecessor(K key, out System.Collections.Generic.KeyValuePai /// The key /// The weak successor, if any /// True if the key has a weak successor - public bool TryWeakSuccessor(K key, out System.Collections.Generic.KeyValuePair res) - { - return sorteddict.TryWeakSuccessor(key, out res); - } + public bool TryWeakSuccessor(K key, out SCG.KeyValuePair res) => sorteddict.TryWeakSuccessor(key, out res); /// /// Get the entry in the wrapped dictionary whose key is the @@ -97,8 +86,7 @@ public bool TryWeakSuccessor(K key, out System.Collections.Generic.KeyValuePair< /// if no such entry exists /// The key /// The entry - public System.Collections.Generic.KeyValuePair Predecessor(K key) - { return sorteddict.Predecessor(key); } + public SCG.KeyValuePair Predecessor(K key) => sorteddict.Predecessor(key); /// /// Get the entry in the wrapped dictionary whose key is the @@ -107,9 +95,7 @@ public System.Collections.Generic.KeyValuePair Predecessor(K key) /// if no such entry exists /// The key /// The entry - public System.Collections.Generic.KeyValuePair Successor(K key) - { return sorteddict.Successor(key); } - + public SCG.KeyValuePair Successor(K key) => sorteddict.Successor(key); /// /// Get the entry in the wrapped dictionary whose key is the @@ -118,9 +104,7 @@ public System.Collections.Generic.KeyValuePair Successor(K key) /// if no such entry exists /// The key /// The entry - public System.Collections.Generic.KeyValuePair WeakPredecessor(K key) - { return sorteddict.WeakPredecessor(key); } - + public SCG.KeyValuePair WeakPredecessor(K key) => sorteddict.WeakPredecessor(key); /// /// Get the entry in the wrapped dictionary whose key is the @@ -129,42 +113,33 @@ public System.Collections.Generic.KeyValuePair WeakPredecessor(K key) /// if no such entry exists /// The key /// The entry - public System.Collections.Generic.KeyValuePair WeakSuccessor(K key) - { return sorteddict.WeakSuccessor(key); } + public SCG.KeyValuePair WeakSuccessor(K key) => sorteddict.WeakSuccessor(key); /// /// /// /// - public System.Collections.Generic.KeyValuePair FindMin() - { - return sorteddict.FindMin(); - } + public SCG.KeyValuePair FindMin() => sorteddict.FindMin(); /// /// /// /// since this is a read-only wrapper /// - public System.Collections.Generic.KeyValuePair DeleteMin() - { throw new ReadOnlyCollectionException(); } + public SCG.KeyValuePair DeleteMin() => throw new ReadOnlyCollectionException(); /// /// /// /// - public System.Collections.Generic.KeyValuePair FindMax() - { - return sorteddict.FindMax(); - } + public SCG.KeyValuePair FindMax() => sorteddict.FindMax(); /// /// /// /// since this is a read-only wrapper /// - public System.Collections.Generic.KeyValuePair DeleteMax() - { throw new ReadOnlyCollectionException(); } + public SCG.KeyValuePair DeleteMax() => throw new ReadOnlyCollectionException(); /// /// @@ -175,7 +150,7 @@ public System.Collections.Generic.KeyValuePair DeleteMax() /// /// /// - public bool Cut(IComparable c, out System.Collections.Generic.KeyValuePair lowEntry, out bool lowIsValid, out System.Collections.Generic.KeyValuePair highEntry, out bool highIsValid) + public bool Cut(IComparable c, out SCG.KeyValuePair lowEntry, out bool lowIsValid, out SCG.KeyValuePair highEntry, out bool highIsValid) { return sorteddict.Cut(c, out lowEntry, out lowIsValid, out highEntry, out highIsValid); ; } @@ -185,9 +160,9 @@ public bool Cut(IComparable c, out System.Collections.Generic.KeyValuePair /// /// - public IDirectedEnumerable> RangeFrom(K bot) + public IDirectedEnumerable> RangeFrom(K bot) { - return new GuardedDirectedEnumerable>(sorteddict.RangeFrom(bot)); + return new GuardedDirectedEnumerable>(sorteddict.RangeFrom(bot)); } /// @@ -196,9 +171,9 @@ public bool Cut(IComparable c, out System.Collections.Generic.KeyValuePair /// /// - public IDirectedEnumerable> RangeFromTo(K bot, K top) + public IDirectedEnumerable> RangeFromTo(K bot, K top) { - return new GuardedDirectedEnumerable>(sorteddict.RangeFromTo(bot, top)); + return new GuardedDirectedEnumerable>(sorteddict.RangeFromTo(bot, top)); } /// @@ -206,18 +181,18 @@ public bool Cut(IComparable c, out System.Collections.Generic.KeyValuePair /// /// - public IDirectedEnumerable> RangeTo(K top) + public IDirectedEnumerable> RangeTo(K top) { - return new GuardedDirectedEnumerable>(sorteddict.RangeTo(top)); + return new GuardedDirectedEnumerable>(sorteddict.RangeTo(top)); } /// /// /// /// - public IDirectedCollectionValue> RangeAll() + public IDirectedCollectionValue> RangeAll() { - return new GuardedDirectedCollectionValue>(sorteddict.RangeAll()); + return new GuardedDirectedCollectionValue>(sorteddict.RangeAll()); } /// @@ -225,16 +200,14 @@ public bool Cut(IComparable c, out System.Collections.Generic.KeyValuePair /// since this is a read-only wrapper /// - public void AddSorted(System.Collections.Generic.IEnumerable> items) - { throw new ReadOnlyCollectionException(); } + public void AddSorted(SCG.IEnumerable> items) => throw new ReadOnlyCollectionException(); /// /// /// /// since this is a read-only wrapper /// - public void RemoveRangeFrom(K low) - { throw new ReadOnlyCollectionException(); } + public void RemoveRangeFrom(K low) => throw new ReadOnlyCollectionException(); /// /// @@ -242,16 +215,14 @@ public void RemoveRangeFrom(K low) /// since this is a read-only wrapper /// /// - public void RemoveRangeFromTo(K low, K hi) - { throw new ReadOnlyCollectionException(); } + public void RemoveRangeFromTo(K low, K hi) => throw new ReadOnlyCollectionException(); /// /// /// /// since this is a read-only wrapper /// - public void RemoveRangeTo(K hi) - { throw new ReadOnlyCollectionException(); } + public void RemoveRangeTo(K hi) => throw new ReadOnlyCollectionException(); #endregion }