summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Collections/SortedList.cs
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
commitdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch)
treee5435159cd1bf0519276363a6fe1663d1721bed3 /src/mscorlib/src/System/Collections/SortedList.cs
parent4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff)
downloadcoreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/mscorlib/src/System/Collections/SortedList.cs')
-rw-r--r--src/mscorlib/src/System/Collections/SortedList.cs39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/mscorlib/src/System/Collections/SortedList.cs b/src/mscorlib/src/System/Collections/SortedList.cs
index 8e3926af01..4a480a2c37 100644
--- a/src/mscorlib/src/System/Collections/SortedList.cs
+++ b/src/mscorlib/src/System/Collections/SortedList.cs
@@ -60,10 +60,8 @@ namespace System.Collections {
//
[DebuggerTypeProxy(typeof(System.Collections.SortedList.SortedListDebugView))]
[DebuggerDisplay("Count = {Count}")]
-[System.Runtime.InteropServices.ComVisible(true)]
-#if FEATURE_CORECLR
+ [System.Runtime.InteropServices.ComVisible(true)]
[Obsolete("Non-generic collections have been deprecated. Please use collections in System.Collections.Generic.")]
-#endif
[Serializable]
public class SortedList : IDictionary, ICloneable
{
@@ -107,7 +105,7 @@ namespace System.Collections {
//
public SortedList(int initialCapacity) {
if (initialCapacity < 0)
- throw new ArgumentOutOfRangeException("initialCapacity", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(initialCapacity), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
keys = new Object[initialCapacity];
values = new Object[initialCapacity];
@@ -164,7 +162,7 @@ namespace System.Collections {
public SortedList(IDictionary d, IComparer comparer)
: this(comparer, (d != null ? d.Count : 0)) {
if (d==null)
- throw new ArgumentNullException("d", Environment.GetResourceString("ArgumentNull_Dictionary"));
+ throw new ArgumentNullException(nameof(d), Environment.GetResourceString("ArgumentNull_Dictionary"));
Contract.EndContractBlock();
d.Keys.CopyTo(keys, 0);
d.Values.CopyTo(values, 0);
@@ -176,7 +174,7 @@ namespace System.Collections {
// ArgumentException is thrown if the key is already present in the sorted list.
//
public virtual void Add(Object key, Object value) {
- if (key == null) throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key"));
+ if (key == null) throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key"));
Contract.EndContractBlock();
int i = Array.BinarySearch(keys, 0, _size, key, comparer);
if (i >= 0)
@@ -196,7 +194,7 @@ namespace System.Collections {
}
set {
if (value < Count) {
- throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
+ throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
}
Contract.EndContractBlock();
@@ -213,7 +211,7 @@ namespace System.Collections {
}
else {
// size can only be zero here.
- Contract.Assert( _size == 0, "Size is not zero");
+ Debug.Assert( _size == 0, "Size is not zero");
keys = emptyArray;
values = emptyArray;
}
@@ -325,11 +323,11 @@ namespace System.Collections {
// Copies the values in this SortedList to an array.
public virtual void CopyTo(Array array, int arrayIndex) {
if (array == null)
- throw new ArgumentNullException("array", Environment.GetResourceString("ArgumentNull_Array"));
+ throw new ArgumentNullException(nameof(array), Environment.GetResourceString("ArgumentNull_Array"));
if (array.Rank != 1)
throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
if (arrayIndex < 0)
- throw new ArgumentOutOfRangeException("arrayIndex", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(arrayIndex), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
if (array.Length - arrayIndex < Count)
throw new ArgumentException(Environment.GetResourceString("Arg_ArrayPlusOffTooSmall"));
Contract.EndContractBlock();
@@ -368,7 +366,7 @@ namespace System.Collections {
//
public virtual Object GetByIndex(int index) {
if (index < 0 || index >= Count)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
return values[index];
}
@@ -394,7 +392,7 @@ namespace System.Collections {
// Returns the key of the entry at the given index.
//
public virtual Object GetKey(int index) {
- if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
return keys[index];
}
@@ -442,7 +440,7 @@ namespace System.Collections {
return null;
}
set {
- if (key == null) throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key"));
+ if (key == null) throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key"));
Contract.EndContractBlock();
int i = Array.BinarySearch(keys, 0, _size, key, comparer);
if (i >= 0) {
@@ -463,7 +461,7 @@ namespace System.Collections {
//
public virtual int IndexOfKey(Object key) {
if (key == null)
- throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key"));
+ throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key"));
Contract.EndContractBlock();
int ret = Array.BinarySearch(keys, 0, _size, key, comparer);
return ret >=0 ? ret : -1;
@@ -496,7 +494,7 @@ namespace System.Collections {
// decreased by one.
//
public virtual void RemoveAt(int index) {
- if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
_size--;
if (index < _size) {
@@ -522,7 +520,7 @@ namespace System.Collections {
// the given entry is overwritten.
//
public virtual void SetByIndex(int index, Object value) {
- if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
values[index] = value;
version++;
@@ -530,10 +528,9 @@ namespace System.Collections {
// Returns a thread-safe SortedList.
//
- [HostProtection(Synchronization=true)]
public static SortedList Synchronized(SortedList list) {
if (list==null)
- throw new ArgumentNullException("list");
+ throw new ArgumentNullException(nameof(list));
Contract.EndContractBlock();
return new SyncSortedList(list);
}
@@ -677,7 +674,7 @@ namespace System.Collections {
public override int IndexOfKey(Object key) {
if (key == null)
- throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key"));
+ throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key"));
Contract.EndContractBlock();
lock(_root) {
@@ -888,7 +885,7 @@ namespace System.Collections {
public virtual int IndexOf(Object key) {
if (key==null)
- throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key"));
+ throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key"));
Contract.EndContractBlock();
int i = Array.BinarySearch(sortedList.keys, 0,
@@ -993,7 +990,7 @@ namespace System.Collections {
public SortedListDebugView( SortedList sortedList) {
if( sortedList == null) {
- throw new ArgumentNullException("sortedList");
+ throw new ArgumentNullException(nameof(sortedList));
}
Contract.EndContractBlock();