Done TempDictionary api docs

This commit is contained in:
Elia Sulimanov 2020-06-16 08:53:40 +03:00
parent b64584fc92
commit 5364356a18

View file

@ -3,22 +3,42 @@ using System.Collections.Generic;
namespace Cosmos.System.Network
{
/// <summary>
/// TempDictionary template class.
/// </summary>
/// <typeparam name="TValue">TempDictionary type name.</typeparam>
internal class TempDictionary<TValue>
{
private List<UInt32> mKeys;
private List<TValue> mValues;
/// <summary>
/// Get the number of elements in the list.
/// </summary>
public int Count { get; private set; }
/// <summary>
/// Create new inctanse of the <see cref="TempDictionary{TValue}"/> class.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
public TempDictionary()
:this(2)
{ }
/// <summary>
/// Create new inctanse of the <see cref="TempDictionary{TValue}"/> class, with a specified initial size.
/// </summary>
/// <param name="initialSize">Initial size.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown if initialSize is less than 0.</exception>
public TempDictionary(int initialSize)
{
this.mKeys = new List<UInt32>(initialSize);
this.mValues = new List<TValue>(initialSize);
}
/// <summary>
/// Get TempDictionary{TValue} keys array.
/// </summary>
public UInt32[] Keys
{
get
@ -26,6 +46,10 @@ namespace Cosmos.System.Network
return this.mKeys.ToArray();
}
}
/// <summary>
/// Get TempDictionary{TValue} values array.
/// </summary>
public TValue[] Values
{
get
@ -34,6 +58,12 @@ namespace Cosmos.System.Network
}
}
/// <summary>
/// Get and set the element with the specified key.
/// </summary>
/// <param name="key">Key of an element.</param>
/// <returns>TValue value.</returns>
/// <exception cref="ArgumentOutOfRangeException">(set) Thrown if no element with the specified key is found.</exception>
public TValue this[UInt32 key]
{
get
@ -63,6 +93,11 @@ namespace Cosmos.System.Network
}
}
/// <summary>
/// Check if the key exists in the TempDictionary{TValue}.
/// </summary>
/// <param name="key">Key to check if exists.</param>
/// <returns>bool value.</returns>
public bool ContainsKey(UInt32 key)
{
for (int i = 0; i < mKeys.Count; i++)
@ -76,6 +111,12 @@ namespace Cosmos.System.Network
return false;
}
/// <summary>
/// Adds an object at the end of the TempDictionary{TValue}.
/// </summary>
/// <param name="key">Object key.</param>
/// <param name="val">Object value.</param>
/// <exception cref="ArgumentException">Thrown if key already exists.</exception>
public void Add(UInt32 key, TValue val)
{
if (ContainsKey(key) == true)
@ -87,6 +128,11 @@ namespace Cosmos.System.Network
mValues.Add(val);
}
/// <summary>
/// Removes the element with the specified key of the TempDictionary{TValue}.
/// </summary>
/// <param name="key">Key of the item to remove.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
public void Remove(UInt32 key)
{
int idx = mKeys.IndexOf(key);
@ -95,6 +141,12 @@ namespace Cosmos.System.Network
this.Remove(idx);
}
}
/// <summary>
/// Removes the element at the specified index of the TempDictionary{TValue}.
/// </summary>
/// <param name="index">Index of the item to remove.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown if no such index exists in the TempDictionary.</exception>
public void Remove(int index)
{
if (index > mKeys.Count - 1)
@ -106,6 +158,9 @@ namespace Cosmos.System.Network
mValues.RemoveAt(index);
}
/// <summary>
/// Removes all elements from the TempDictionary{TValue}.
/// </summary>
public void Clear()
{
mKeys.Clear();