mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-09 09:42:13 +00:00
Done TempDictionary api docs
This commit is contained in:
parent
b64584fc92
commit
5364356a18
1 changed files with 55 additions and 0 deletions
|
|
@ -3,22 +3,42 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Cosmos.System.Network
|
namespace Cosmos.System.Network
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// TempDictionary template class.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TValue">TempDictionary type name.</typeparam>
|
||||||
internal class TempDictionary<TValue>
|
internal class TempDictionary<TValue>
|
||||||
{
|
{
|
||||||
private List<UInt32> mKeys;
|
private List<UInt32> mKeys;
|
||||||
private List<TValue> mValues;
|
private List<TValue> mValues;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the number of elements in the list.
|
||||||
|
/// </summary>
|
||||||
public int Count { get; private set; }
|
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()
|
public TempDictionary()
|
||||||
:this(2)
|
: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)
|
public TempDictionary(int initialSize)
|
||||||
{
|
{
|
||||||
this.mKeys = new List<UInt32>(initialSize);
|
this.mKeys = new List<UInt32>(initialSize);
|
||||||
this.mValues = new List<TValue>(initialSize);
|
this.mValues = new List<TValue>(initialSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get TempDictionary{TValue} keys array.
|
||||||
|
/// </summary>
|
||||||
public UInt32[] Keys
|
public UInt32[] Keys
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -26,6 +46,10 @@ namespace Cosmos.System.Network
|
||||||
return this.mKeys.ToArray();
|
return this.mKeys.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get TempDictionary{TValue} values array.
|
||||||
|
/// </summary>
|
||||||
public TValue[] Values
|
public TValue[] Values
|
||||||
{
|
{
|
||||||
get
|
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]
|
public TValue this[UInt32 key]
|
||||||
{
|
{
|
||||||
get
|
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)
|
public bool ContainsKey(UInt32 key)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mKeys.Count; i++)
|
for (int i = 0; i < mKeys.Count; i++)
|
||||||
|
|
@ -76,6 +111,12 @@ namespace Cosmos.System.Network
|
||||||
return false;
|
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)
|
public void Add(UInt32 key, TValue val)
|
||||||
{
|
{
|
||||||
if (ContainsKey(key) == true)
|
if (ContainsKey(key) == true)
|
||||||
|
|
@ -87,6 +128,11 @@ namespace Cosmos.System.Network
|
||||||
mValues.Add(val);
|
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)
|
public void Remove(UInt32 key)
|
||||||
{
|
{
|
||||||
int idx = mKeys.IndexOf(key);
|
int idx = mKeys.IndexOf(key);
|
||||||
|
|
@ -95,6 +141,12 @@ namespace Cosmos.System.Network
|
||||||
this.Remove(idx);
|
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)
|
public void Remove(int index)
|
||||||
{
|
{
|
||||||
if (index > mKeys.Count - 1)
|
if (index > mKeys.Count - 1)
|
||||||
|
|
@ -106,6 +158,9 @@ namespace Cosmos.System.Network
|
||||||
mValues.RemoveAt(index);
|
mValues.RemoveAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes all elements from the TempDictionary{TValue}.
|
||||||
|
/// </summary>
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
mKeys.Clear();
|
mKeys.Clear();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue