refactor: Adding NotNull attributes to collections

This commit is contained in:
Chris Cameron
2019-10-09 10:47:29 -04:00
parent 238d6518ab
commit 41755cb472
5 changed files with 155 additions and 79 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using ICD.Common.Properties;
namespace ICD.Common.Utils.Collections
{
@@ -20,8 +21,10 @@ namespace ICD.Common.Utils.Collections
public bool IsReadOnly { get { return false; } }
[NotNull]
public ICollection<TKey> Keys { get { return m_KeyToValue.Keys; } }
[NotNull]
public ICollection<TValue> Values { get { return m_ValueToKey.Keys; } }
#endregion
@@ -30,21 +33,20 @@ namespace ICD.Common.Utils.Collections
/// Constructor.
/// </summary>
public BiDictionary()
: this(null)
{
m_KeyToValue = new Dictionary<TKey, TValue>();
m_ValueToKey = new Dictionary<TValue, TKey>();
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="dict"></param>
public BiDictionary(Dictionary<TKey, TValue> dict)
public BiDictionary([NotNull] Dictionary<TKey, TValue> dict)
: this()
{
m_KeyToValue = new Dictionary<TKey, TValue>();
m_ValueToKey = new Dictionary<TValue, TKey>();
if (dict == null)
return;
throw new ArgumentNullException("dict");
foreach (KeyValuePair<TKey, TValue> kvp in dict)
Add(kvp.Key, kvp.Value);
@@ -58,24 +60,31 @@ namespace ICD.Common.Utils.Collections
m_ValueToKey.Clear();
}
public bool ContainsKey(TKey key)
public bool ContainsKey([NotNull] TKey key)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
return m_KeyToValue.ContainsKey(key);
}
public bool ContainsValue(TValue value)
public bool ContainsValue([NotNull] TValue value)
{
return m_ValueToKey.ContainsKey(value);
}
public void Add(TKey key, TValue value)
public void Add([NotNull] TKey key, [NotNull] TValue value)
{
// ReSharper disable once CompareNonConstrainedGenericWithNull
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
// ReSharper disable once CompareNonConstrainedGenericWithNull
// ReSharper disable CompareNonConstrainedGenericWithNull
if (value == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("value");
if (ContainsKey(key))
@@ -88,14 +97,16 @@ namespace ICD.Common.Utils.Collections
m_ValueToKey.Add(value, key);
}
public void Set(TKey key, TValue value)
public void Set([NotNull] TKey key, [NotNull] TValue value)
{
// ReSharper disable once CompareNonConstrainedGenericWithNull
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
// ReSharper disable once CompareNonConstrainedGenericWithNull
// ReSharper disable CompareNonConstrainedGenericWithNull
if (value == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("value");
RemoveKey(key);
@@ -104,18 +115,35 @@ namespace ICD.Common.Utils.Collections
Add(key, value);
}
public TKey GetKey(TValue value)
[NotNull]
public TKey GetKey([NotNull] TValue value)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (value == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("value");
return m_ValueToKey[value];
}
public TValue GetValue(TKey key)
[NotNull]
public TValue GetValue([NotNull] TKey key)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
return m_KeyToValue[key];
}
public bool RemoveKey(TKey key)
public bool RemoveKey([NotNull] TKey key)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
if (!ContainsKey(key))
return false;
@@ -127,8 +155,13 @@ namespace ICD.Common.Utils.Collections
return true;
}
public bool RemoveValue(TValue value)
public bool RemoveValue([NotNull] TValue value)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (value == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("value");
if (!ContainsValue(value))
return false;
@@ -137,13 +170,23 @@ namespace ICD.Common.Utils.Collections
return RemoveKey(key);
}
public bool TryGetValue(TKey key, out TValue value)
public bool TryGetValue([NotNull] TKey key, out TValue value)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
return m_KeyToValue.TryGetValue(key, out value);
}
public bool TryGetKey(TValue value, out TKey key)
public bool TryGetKey([NotNull] TValue value, out TKey key)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (value == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("value");
return m_ValueToKey.TryGetValue(value, out key);
}
@@ -151,9 +194,10 @@ namespace ICD.Common.Utils.Collections
#region IDictionary
TValue IDictionary<TKey, TValue>.this[TKey key] { get { return GetValue(key); } set { Set(key, value); } }
[NotNull]
TValue IDictionary<TKey, TValue>.this[[NotNull] TKey key] { get { return GetValue(key); } set { Set(key, value); } }
bool IDictionary<TKey, TValue>.Remove(TKey key)
bool IDictionary<TKey, TValue>.Remove([NotNull] TKey key)
{
return RemoveKey(key);
}
@@ -177,7 +221,7 @@ namespace ICD.Common.Utils.Collections
return RemoveKey(item.Key);
}
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo([NotNull] KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
(m_KeyToValue as IDictionary<TKey, TValue>).CopyTo(array, arrayIndex);
}
@@ -186,11 +230,13 @@ namespace ICD.Common.Utils.Collections
#region IEnumerable
[NotNull]
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return m_KeyToValue.GetEnumerator();
}
[NotNull]
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();

View File

@@ -49,7 +49,7 @@ namespace ICD.Common.Utils.Collections
/// Constructor.
/// </summary>
/// <param name="items"></param>
public IcdHashSet(IEnumerable<T> items)
public IcdHashSet([NotNull] IEnumerable<T> items)
: this(EqualityComparer<T>.Default, items)
{
}
@@ -58,7 +58,7 @@ namespace ICD.Common.Utils.Collections
/// Constructor.
/// </summary>
/// <param name="comparer"></param>
public IcdHashSet(IEqualityComparer<T> comparer)
public IcdHashSet([NotNull] IEqualityComparer<T> comparer)
: this(comparer, Enumerable.Empty<T>())
{
}
@@ -68,7 +68,7 @@ namespace ICD.Common.Utils.Collections
/// </summary>
/// <param name="comparer"></param>
/// <param name="items"></param>
public IcdHashSet(IEqualityComparer<T> comparer, IEnumerable<T> items)
public IcdHashSet([NotNull] IEqualityComparer<T> comparer, [NotNull] IEnumerable<T> items)
{
if (comparer == null)
throw new ArgumentNullException("comparer");
@@ -91,7 +91,8 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public IcdHashSet<T> Union(IEnumerable<T> set)
[NotNull]
public IcdHashSet<T> Union([NotNull] IEnumerable<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -108,7 +109,8 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public IcdHashSet<T> Subtract(IEnumerable<T> set)
[NotNull]
public IcdHashSet<T> Subtract([NotNull] IEnumerable<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -127,7 +129,8 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public IcdHashSet<T> Intersection(IEnumerable<T> set)
[NotNull]
public IcdHashSet<T> Intersection([NotNull] IEnumerable<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -146,7 +149,8 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public IcdHashSet<T> NonIntersection(IEnumerable<T> set)
[NotNull]
public IcdHashSet<T> NonIntersection([NotNull] IEnumerable<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -170,7 +174,7 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public bool IsSubsetOf(IcdHashSet<T> set)
public bool IsSubsetOf([NotNull] IcdHashSet<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -184,7 +188,7 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public bool IsProperSubsetOf(IcdHashSet<T> set)
public bool IsProperSubsetOf([NotNull] IcdHashSet<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -198,7 +202,7 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public bool IsSupersetOf(IcdHashSet<T> set)
public bool IsSupersetOf([NotNull] IcdHashSet<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -212,7 +216,7 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public bool IsProperSupersetOf(IcdHashSet<T> set)
public bool IsProperSupersetOf([NotNull] IcdHashSet<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -226,7 +230,7 @@ namespace ICD.Common.Utils.Collections
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public bool SetEquals(IcdHashSet<T> set)
public bool SetEquals([NotNull] IcdHashSet<T> set)
{
if (set == null)
throw new ArgumentNullException("set");
@@ -243,7 +247,7 @@ namespace ICD.Common.Utils.Collections
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Add(T item)
public bool Add([NotNull] T item)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (item == null)
@@ -261,7 +265,7 @@ namespace ICD.Common.Utils.Collections
/// Adds the item to the collection.
/// </summary>
/// <param name="item"></param>
void ICollection<T>.Add(T item)
void ICollection<T>.Add([NotNull] T item)
{
Add(item);
}
@@ -270,7 +274,7 @@ namespace ICD.Common.Utils.Collections
/// Adds each of the items in the sequence to the collection.
/// </summary>
/// <param name="items"></param>
public void AddRange(IEnumerable<T> items)
public void AddRange([NotNull] IEnumerable<T> items)
{
if (items == null)
throw new ArgumentNullException("items");
@@ -293,7 +297,7 @@ namespace ICD.Common.Utils.Collections
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Contains(T item)
public bool Contains([NotNull] T item)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (item == null)
@@ -307,8 +311,11 @@ namespace ICD.Common.Utils.Collections
/// Copies the items of the <see cref="T:System.Collections.Generic.ICollection`1"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index.
/// </summary>
/// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the items copied from <see cref="T:System.Collections.Generic.ICollection`1"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param><param name="arrayIndex">The zero-based index in <paramref name="array"/> at which copying begins.</param><exception cref="T:System.ArgumentNullException"><paramref name="array"/> is null.</exception><exception cref="T:System.ArgumentOutOfRangeException"><paramref name="arrayIndex"/> is less than 0.</exception><exception cref="T:System.ArgumentException"><paramref name="array"/> is multidimensional.-or-<paramref name="arrayIndex"/> is equal to or greater than the length of <paramref name="array"/>.-or-The number of items in the source <see cref="T:System.Collections.Generic.ICollection`1"/> is greater than the available space from <paramref name="arrayIndex"/> to the end of the destination <paramref name="array"/>.-or-Type T cannot be cast automatically to the type of the destination <paramref name="array"/>.</exception>
public void CopyTo(T[] array, int arrayIndex)
public void CopyTo([NotNull] T[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException("array");
m_Dict.Keys.CopyTo(array, arrayIndex);
}
@@ -319,7 +326,7 @@ namespace ICD.Common.Utils.Collections
/// true if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1"/>.
/// </returns>
/// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param><exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.</exception>
public bool Remove(T item)
public bool Remove([NotNull] T item)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (item == null)
@@ -333,7 +340,7 @@ namespace ICD.Common.Utils.Collections
/// Removes each of the items in the sequence from the collection.
/// </summary>
/// <param name="items"></param>
public void RemoveRange(IEnumerable<T> items)
public void RemoveRange([NotNull] IEnumerable<T> items)
{
if (items == null)
throw new ArgumentNullException("items");
@@ -352,6 +359,7 @@ namespace ICD.Common.Utils.Collections
/// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection.
/// </returns>
/// <filterpriority>1</filterpriority>
[NotNull]
public IEnumerator<T> GetEnumerator()
{
return m_Dict.Keys.GetEnumerator();
@@ -364,6 +372,7 @@ namespace ICD.Common.Utils.Collections
/// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
/// </returns>
/// <filterpriority>2</filterpriority>
[NotNull]
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();

View File

@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using ICD.Common.Properties;
using ICD.Common.Utils.Extensions;
namespace ICD.Common.Utils.Collections
@@ -19,11 +20,14 @@ namespace ICD.Common.Utils.Collections
public bool IsReadOnly { get { return false; } }
[NotNull]
public ICollection<TKey> Keys { get { return m_OrderedKeys; } }
[NotNull]
public ICollection<TValue> Values { get { return m_ValuesOrderedByKey; } }
public TValue this[TKey key]
[CanBeNull]
public TValue this[[NotNull] TKey key]
{
get { return m_Dictionary[key]; }
set
@@ -51,7 +55,7 @@ namespace ICD.Common.Utils.Collections
/// Constructor.
/// </summary>
/// <param name="comparer"></param>
public IcdOrderedDictionary(IComparer<TKey> comparer)
public IcdOrderedDictionary([NotNull] IComparer<TKey> comparer)
: this(comparer, EqualityComparer<TKey>.Default)
{
}
@@ -61,7 +65,7 @@ namespace ICD.Common.Utils.Collections
/// </summary>
/// <param name="comparer"></param>
/// <param name="equalityComparer"></param>
public IcdOrderedDictionary(IComparer<TKey> comparer, IEqualityComparer<TKey> equalityComparer)
public IcdOrderedDictionary([NotNull] IComparer<TKey> comparer, [NotNull] IEqualityComparer<TKey> equalityComparer)
{
if (comparer == null)
throw new ArgumentNullException("comparer");
@@ -79,7 +83,7 @@ namespace ICD.Common.Utils.Collections
/// Constructor.
/// </summary>
/// <param name="dictionary"></param>
public IcdOrderedDictionary(IEnumerable<KeyValuePair<TKey, TValue>> dictionary)
public IcdOrderedDictionary([NotNull] IEnumerable<KeyValuePair<TKey, TValue>> dictionary)
: this()
{
if (dictionary == null)
@@ -91,16 +95,18 @@ namespace ICD.Common.Utils.Collections
#region Methods
[NotNull]
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return m_OrderedKeys.Select(k => new KeyValuePair<TKey, TValue>(k, m_Dictionary[k]))
.GetEnumerator();
}
public void Add(TKey key, TValue value)
public void Add([NotNull] TKey key, [CanBeNull] TValue value)
{
// ReSharper disable once CompareNonConstrainedGenericWithNull
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
if (m_Dictionary.ContainsKey(key))
@@ -119,15 +125,21 @@ namespace ICD.Common.Utils.Collections
m_Dictionary.Clear();
}
public bool ContainsKey(TKey key)
public bool ContainsKey([NotNull] TKey key)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
return m_Dictionary.ContainsKey(key);
}
public bool Remove(TKey key)
public bool Remove([NotNull] TKey key)
{
// ReSharper disable once CompareNonConstrainedGenericWithNull
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
if (!m_Dictionary.Remove(key))
@@ -141,8 +153,13 @@ namespace ICD.Common.Utils.Collections
return true;
}
public bool TryGetValue(TKey key, out TValue value)
public bool TryGetValue([NotNull] TKey key, out TValue value)
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
return m_Dictionary.TryGetValue(key, out value);
}
@@ -150,6 +167,7 @@ namespace ICD.Common.Utils.Collections
#region Private Methods
[NotNull]
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
@@ -167,8 +185,11 @@ namespace ICD.Common.Utils.Collections
EqualityComparer<TValue>.Default.Equals(value, item.Value);
}
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int index)
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo([NotNull] KeyValuePair<TKey, TValue>[] array, int index)
{
if (array == null)
throw new ArgumentNullException("array");
foreach (KeyValuePair<TKey, TValue> kvp in this)
{
array.SetValue(kvp, index);

View File

@@ -30,6 +30,7 @@ namespace ICD.Common.Utils.Collections
/// <summary>
/// Gets a reference for locking.
/// </summary>
[NotNull]
public object SyncRoot { get { return this; } }
#endregion
@@ -59,7 +60,7 @@ namespace ICD.Common.Utils.Collections
/// </summary>
/// <param name="item"></param>
[PublicAPI]
public void Enqueue(T item)
public void Enqueue([CanBeNull] T item)
{
Enqueue(item, int.MaxValue);
}
@@ -71,16 +72,10 @@ namespace ICD.Common.Utils.Collections
/// <param name="item"></param>
/// <param name="priority"></param>
[PublicAPI]
public void Enqueue(T item, int priority)
public void Enqueue([CanBeNull] T item, int priority)
{
List<T> queue;
if (!m_PriorityToQueue.TryGetValue(priority, out queue))
{
queue = new List<T>();
m_PriorityToQueue.Add(priority, queue);
}
queue.Add(item);
m_PriorityToQueue.GetOrAddNew(priority, () => new List<T>())
.Add(item);
m_Count++;
}
@@ -89,18 +84,10 @@ namespace ICD.Common.Utils.Collections
/// </summary>
/// <param name="item"></param>
[PublicAPI]
public void EnqueueFirst(T item)
public void EnqueueFirst([CanBeNull] T item)
{
const int priority = int.MinValue;
List<T> queue;
if (!m_PriorityToQueue.TryGetValue(priority, out queue))
{
queue = new List<T>();
m_PriorityToQueue.Add(priority, queue);
}
queue.Insert(0, item);
m_PriorityToQueue.GetOrAddNew(int.MinValue, () => new List<T>())
.Insert(0, item);
m_Count++;
}
@@ -112,7 +99,7 @@ namespace ICD.Common.Utils.Collections
/// <param name="item"></param>
/// <param name="remove"></param>
[PublicAPI]
public void EnqueueRemove(T item, Func<T, bool> remove)
public void EnqueueRemove([CanBeNull] T item, [NotNull] Func<T, bool> remove)
{
if (remove == null)
throw new ArgumentNullException("remove");
@@ -129,7 +116,7 @@ namespace ICD.Common.Utils.Collections
/// <param name="remove"></param>
/// <param name="priority"></param>
[PublicAPI]
public void EnqueueRemove(T item, Func<T, bool> remove, int priority)
public void EnqueueRemove([CanBeNull] T item, [NotNull] Func<T, bool> remove, int priority)
{
if (remove == null)
throw new ArgumentNullException("remove");
@@ -180,6 +167,7 @@ namespace ICD.Common.Utils.Collections
/// </summary>
/// <returns></returns>
[PublicAPI]
[CanBeNull]
public T Dequeue()
{
T output;
@@ -227,6 +215,7 @@ namespace ICD.Common.Utils.Collections
/// Gets an enumerator for the items.
/// </summary>
/// <returns></returns>
[NotNull]
public IEnumerator<T> GetEnumerator()
{
return m_PriorityToQueue.Values
@@ -239,8 +228,11 @@ namespace ICD.Common.Utils.Collections
/// </summary>
/// <param name="array"></param>
/// <param name="index"></param>
public void CopyTo(Array array, int index)
public void CopyTo([NotNull] Array array, int index)
{
if (array == null)
throw new ArgumentNullException("array");
foreach (T item in this)
array.SetValue(item, index++);
}
@@ -253,6 +245,7 @@ namespace ICD.Common.Utils.Collections
/// Gets an enumerator for the items.
/// </summary>
/// <returns></returns>
[NotNull]
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using ICD.Common.Properties;
using ICD.Common.Utils.EventArguments;
using ICD.Common.Utils.Extensions;
using ICD.Common.Utils.Timers;
@@ -32,6 +33,7 @@ namespace ICD.Common.Utils.Collections
bool ICollection.IsSynchronized { get { return true; } }
[NotNull]
object ICollection.SyncRoot { get { return this; } }
#endregion
@@ -72,7 +74,7 @@ namespace ICD.Common.Utils.Collections
/// Enqueues the given item.
/// </summary>
/// <param name="item"></param>
public void Enqueue(T item)
public void Enqueue([CanBeNull] T item)
{
m_QueueSection.Enter();
@@ -158,18 +160,23 @@ namespace ICD.Common.Utils.Collections
#region IEnumerable/ICollection
[NotNull]
public IEnumerator<T> GetEnumerator()
{
return m_QueueSection.Execute(() => m_Queue.ToList(m_Queue.Count).GetEnumerator());
}
[NotNull]
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
void ICollection.CopyTo(Array array, int index)
void ICollection.CopyTo([NotNull] Array array, int index)
{
if (array == null)
throw new ArgumentNullException("array");
m_QueueSection.Enter();
try