public void Try() { NativeDictionary <int, int> nativeDictionary = new NativeDictionary <int, int>(50, Allocator.Temp, (i, j) => i == j); nativeDictionary.Add(1, 3); nativeDictionary.Add(2, 4); int result; nativeDictionary.Get(1, out result); Debug.Log(result); nativeDictionary.Get(2, out result); Debug.Log(result); nativeDictionary.Get(3, out result); Debug.Log(result); nativeDictionary.Dispose(); }
public int AddOrSet(String key, String value) { try { if (String.IsNullOrEmpty(key)) { return(-1); } if (NativeDictionary.ContainsKey(key)) { NativeDictionary[key] = value; } else { NativeDictionary.Add(key, value); } return(Count - 1); } catch (Exception ex) { ILog.LogError(ex); } return(-1); }
public void NativeSortedSetAdd() { for (int i = 0; i < COUNT; i++) { ndict.Add(i, i * i); } for (int i = 0; i < COUNT; i++) { ndict.Remove(i); } }
void RunTest() { NativeDictionary <int, int, IntEqual> dict = new NativeDictionary <int, int, IntEqual>(5, Allocator.Temp, new IntEqual()); for (int i = 0; i < 50; ++i) { dict.Add(i, i + 5); } for (int i = 0; i < 10; ++i) { dict.Remove(i); } Debug.Log(dict.Length); for (int i = 0; i < 50; ++i) { int value; if (dict.Get(i, out value)) { Debug.Log(value); } } }