using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace System
{
public class SafeDictionary<T1, T2>
{
private Dictionary<T1, T2> DictBase;
public SafeDictionary(int capacity)
{
DictBase = new Dictionary<T1, T2>(capacity);
}
public SafeDictionary()
{
DictBase = new Dictionary<T1, T2>();
}
public Dictionary<T1, T2> Base
{
get
{
return DictBase;
}
}
public int Count
{
get
{
return DictBase.Count;
}
}
public bool Add(T1 key, T2 value)
{
if (!DictBase.ContainsKey(key))
{
DictBase.Add(key, value);
return true;
}
return false;
}
public void Remove(T1 key)
{
DictBase.Remove(key);
}
public bool ContainsKey(T1 key)
{
return DictBase.ContainsKey(key);
}
public bool ContainsValue(T2 value)
{
return DictBase.ContainsValue(value);
}
public void Clear()
{
DictBase.Clear();
}
public T2 this[T1 key]
{
get
{
if (ContainsKey(key))
return DictBase[key];
else return default(T2);
}
}
public Dictionary<T1, T2>.ValueCollection Values
{
get
{
if (DictBase == null)
DictBase = new Dictionary<T1, T2>();
return DictBase.Values;
}
}
public bool TryGetValue(T1 key, out T2 value)
{
return DictBase.TryGetValue(key, out value);
}
I have Argument Null Exception at that code in this portion
PHP Code:
public bool ContainsKey(T1 key)
{
return DictBase.ContainsKey(key);
}
Code 2
Are they just same function of code 1?
PHP Code:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace System.Collections.Generic
{
public class ThreadSafeDictionary<T1, T2>
{
private Dictionary<T1, T2> SafeDictionaryBase;
public T2[] Values = new T2[0];
public ThreadSafeDictionary(int capacity)
{
SafeDictionaryBase = new Dictionary<T1, T2>(capacity * 10);
}
public int Count
{
get
{
return SafeDictionaryBase.Count;
}
}
public Dictionary<T1, T2> Base
{
get
{
return SafeDictionaryBase;
}
}
public void Add(T1 key, T2 value)
{
if (SafeDictionaryBase.ContainsKey(key) == false)
{
lock (SafeDictionaryBase)
SafeDictionaryBase.Add(key, value);
safeUpdate();
}
}
public void Remove(T1 key)
{
lock (SafeDictionaryBase)
SafeDictionaryBase.Remove(key);
safeUpdate();
}
public T2 this[T1 key]
{
get
{
if (ContainsKey(key))
return SafeDictionaryBase[key];
else return default(T2);
}
}
public bool TryGetValue(T1 key, out T2 value)
{
return SafeDictionaryBase.TryGetValue(key, out value);
}
public bool ContainsKey(T1 key)
{
return SafeDictionaryBase.ContainsKey(key);
}
public bool ContainsValue(T2 value)
{
return SafeDictionaryBase.ContainsValue(value);
}
At the root, yes. But with methods so they can still use the method [names] "Remove" and "Add" instead of the native TryRemove and TryAdd. Less confusing to newbies.
At the root, yes. But with methods so they can still use the method [names] "Remove" and "Add" instead of the native TryRemove and TryAdd. Less confusing to newbies.
Yup, but does not make a difference really, I just did it, because of less typing lool.
Yup, but does not make a difference really, I just did it, because of less typing lool.
You'd be surprised at the amount of people who post on forums asking how to add and remove things from a ConcurrentDictionary. As if IntelliSense didn't tell them as soon as they type the period...
People still use ushort as a map id? If you went and looked at the latest GameMap.dat (or a patch since they added the arena), you'd quickly notice that its an int.
People still use ushort as a map id? If you went and looked at the latest GameMap.dat (or a patch since they added the arena), you'd quickly notice that its an int.
No point using the extra two bytes of memory space if you're never going to use it. Two bytes may seem small, but getting into the habit of things like that are how servers end up being inefficient.
People still use ushort as a map id? If you went and looked at the latest GameMap.dat (or a patch since they added the arena), you'd quickly notice that its an int.
[lil explanation] 04/15/2012 - CO2 Programming - 9 Replies well simply i need someone to explain more about this for me
void AccessAll(Control.ControlCollection cc)
{
foreach (Control c in CC)
{
if (c is CheckBox)
{
CheckBox ch = c as CheckBox;
ch.Checked = true;
}
Need some explanation >.< 08/15/2011 - Silkroad Online - 4 Replies It's about Ramadan Event..I'm collecting Alibaba seals but the questaion is when does the event finishes? i'm confused coz I went to sro site & it say
August 2, 2011 ~ August 16, 2011 (2 weeks)..& some where down it says
AliBaba Seal reward: August 23 ~ August 30, 2011 (1 week) :confused:
Need some explanation here.. 09/06/2010 - EO PServer Hosting - 9 Replies Hi all..my server got a few problem now..
and i dont know what is the problem..
Acc server run good..also msg server run good..
and NPC server run good...But after a few minute.Msg server stop working.
i have looking at error log..this what i have found..
14:52:30 ERROR: ¡ïASSERT(!"Error action type!")¡ï in e:\tq_digital\ħÓò\reliable\src\MsgServer\MapGroup Kernel\GameAction.cpp, 1300
14:52:30 ERROR: ¡ïCHECKF(pType)¡ï in...
Need an explanation please^^ 02/04/2009 - Kal Online - 13 Replies Hello people. Long time ago I wrote a little memory scanner. A program like the normal Cheat Engines but its just a console window^^ Well when I wrote it I tried it with Kal and got what I expected: I couldnt access Kals Memory area cause of HS/KOCP or whatever. Well today I tried it again (dont even know why I tried) and well... suddenly it works. I found the max HP adress, the speed adress. And I even can change it with my little noob CE^^ No-Mana G3 speed works perfectly. Well my question,...