mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
TempDictionarry removed
This commit is contained in:
parent
d199707fe1
commit
da4d55ec1a
5 changed files with 11 additions and 187 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Cosmos.HAL.Network;
|
using Cosmos.HAL.Network;
|
||||||
|
|
||||||
namespace Cosmos.System.Network.ARP
|
namespace Cosmos.System.Network.ARP
|
||||||
|
|
@ -18,7 +19,7 @@ namespace Cosmos.System.Network.ARP
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cache.
|
/// Cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static TempDictionary<uint, MACAddress> cache;
|
private static Dictionary<uint, MACAddress> cache;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ensure cache exists.
|
/// Ensure cache exists.
|
||||||
|
|
@ -28,7 +29,7 @@ namespace Cosmos.System.Network.ARP
|
||||||
{
|
{
|
||||||
if (cache == null)
|
if (cache == null)
|
||||||
{
|
{
|
||||||
cache = new TempDictionary<uint, MACAddress>();
|
cache = new Dictionary<uint, MACAddress>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Cosmos.System.Network.IPv4
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clients dictionary.
|
/// Clients dictionary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static TempDictionary<uint, ICMPClient> clients;
|
private static Dictionary<uint, ICMPClient> clients;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Destination address.
|
/// Destination address.
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Cosmos.System.Network.IPv4
|
||||||
/// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
|
/// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
|
||||||
static ICMPClient()
|
static ICMPClient()
|
||||||
{
|
{
|
||||||
clients = new TempDictionary<uint, ICMPClient>();
|
clients = new Dictionary<uint, ICMPClient>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Cosmos.System.Network.IPv4.UDP
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clients dictionary.
|
/// Clients dictionary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static TempDictionary<uint, UdpClient> clients;
|
private static Dictionary<uint, UdpClient> clients;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Local port.
|
/// Local port.
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Cosmos.System.Network.IPv4.UDP
|
||||||
/// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
|
/// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
|
||||||
static UdpClient()
|
static UdpClient()
|
||||||
{
|
{
|
||||||
clients = new TempDictionary<uint, UdpClient>();
|
clients = new Dictionary<uint, UdpClient>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,11 @@ namespace Cosmos.System.Network
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get address dictionary.
|
/// Get address dictionary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static TempDictionary<uint, NetworkDevice> AddressMap { get; private set; }
|
internal static Dictionary<uint, NetworkDevice> AddressMap { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get address dictionary.
|
/// Get address dictionary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static TempDictionary<uint, NetworkDevice> MACMap { get; private set; }
|
internal static Dictionary<uint, NetworkDevice> MACMap { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize the Network Stack to prepare it for operation.
|
/// Initialize the Network Stack to prepare it for operation.
|
||||||
|
|
@ -43,8 +43,8 @@ namespace Cosmos.System.Network
|
||||||
/// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
|
/// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
AddressMap = new TempDictionary<uint, NetworkDevice>();
|
AddressMap = new Dictionary<uint, NetworkDevice>();
|
||||||
MACMap = new TempDictionary<uint, NetworkDevice>();
|
MACMap = new Dictionary<uint, NetworkDevice>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,177 +0,0 @@
|
||||||
/*
|
|
||||||
* PROJECT: Aura Operating System Development
|
|
||||||
* CONTENT: An other dictionnary class
|
|
||||||
* PROGRAMMERS: Valentin Charbonnier <valentinbreiz@gmail.com>
|
|
||||||
* Port of Cosmos Code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Cosmos.System.Network
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// TempDictionary template class.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TValue">TempDictionary type name.</typeparam>
|
|
||||||
internal class TempDictionary<TKey, TValue>
|
|
||||||
{
|
|
||||||
private List<TKey> 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<TKey>(initialSize);
|
|
||||||
this.mValues = new List<TValue>(initialSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get TempDictionary{TValue} keys array.
|
|
||||||
/// </summary>
|
|
||||||
public TKey[] Keys
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.mKeys.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get TempDictionary{TValue} values array.
|
|
||||||
/// </summary>
|
|
||||||
public TValue[] Values
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.mValues.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <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
|
|
||||||
{
|
|
||||||
for (int i = 0; i < mKeys.Count; i++)
|
|
||||||
{
|
|
||||||
if (mKeys[i].Equals(key))
|
|
||||||
{
|
|
||||||
return mValues[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return default(TValue);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
for (int i = 0; i < mKeys.Count; i++)
|
|
||||||
{
|
|
||||||
if (mKeys[i].Equals(key))
|
|
||||||
{
|
|
||||||
mValues[i] = value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new ArgumentOutOfRangeException("key", "Key not found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <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(TKey key)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < mKeys.Count; i++)
|
|
||||||
{
|
|
||||||
if (mKeys[i].Equals(key))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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(TKey key, TValue val)
|
|
||||||
{
|
|
||||||
if (ContainsKey(key) == true)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("key", "Key already exists");
|
|
||||||
}
|
|
||||||
|
|
||||||
mKeys.Add(key);
|
|
||||||
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(TKey key)
|
|
||||||
{
|
|
||||||
int idx = mKeys.IndexOf(key);
|
|
||||||
if (idx != -1)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
throw new ArgumentOutOfRangeException("index", "No such index");
|
|
||||||
}
|
|
||||||
|
|
||||||
mKeys.RemoveAt(index);
|
|
||||||
mValues.RemoveAt(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Removes all elements from the TempDictionary{TValue}.
|
|
||||||
/// </summary>
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
mKeys.Clear();
|
|
||||||
mValues.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue