public void TryGetValue() { var world = CollectionHelpers.PrepareWorld(); var list = new ME.ECS.Collections.IntrusiveDictionary <int, Data>(); list.Add(1, new Data() { a = 10 }); list.Add(2, new Data() { a = 20 }); list.Add(3, new Data() { a = 30 }); list.Add(4, new Data() { a = 40 }); UnityEngine.Debug.Assert(list.TryGetValue(2, out var value)); UnityEngine.Debug.Assert(value.a == 20); UnityEngine.Debug.Assert(list.TryGetValue(5, out var valueNotExist) == false); UnityEngine.Debug.Assert(valueNotExist.a == 0); CollectionHelpers.CompleteWorld(world); }
public void Add() { var world = CollectionHelpers.PrepareWorld(); var list = new ME.ECS.Collections.IntrusiveDictionary <int, Data>(); list.Add(1, new Data() { a = 10 }); list.Add(2, new Data() { a = 20 }); list.Add(3, new Data() { a = 30 }); list.Add(4, new Data() { a = 40 }); list.Add(4, new Data() { a = 40 }); list.Add(4, new Data() { a = 40 }); UnityEngine.Debug.Assert(list.Count == 4); CollectionHelpers.CompleteWorld(world); }
public void Contains() { var world = Helpers.PrepareWorld(); var list = new ME.ECS.Collections.IntrusiveDictionary <int, Data>(); list.Add(1, new Data() { a = 10 }); list.Add(2, new Data() { a = 20 }); list.Add(3, new Data() { a = 30 }); list.Add(4, new Data() { a = 40 }); UnityEngine.Debug.Assert(list.ContainsKey(2) == true); UnityEngine.Debug.Assert(list.ContainsKey(5) == false); Helpers.CompleteWorld(world); }
public void ForEach() { var world = CollectionHelpers.PrepareWorld(); var e1 = new Data() { a = 10 }; var e2 = new Data() { a = 20 }; var e3 = new Data() { a = 30 }; var e4 = new Data() { a = 40 }; var list = new ME.ECS.Collections.IntrusiveDictionary <int, Data>(); list.Add(1, e1); list.Add(2, e2); list.Add(3, e3); list.Add(4, e4); var listArr = new System.Collections.Generic.List <Data>(); foreach (var item in list) { listArr.Add(item.value); } UnityEngine.Debug.Assert(listArr.Contains(e1)); UnityEngine.Debug.Assert(listArr.Contains(e2)); UnityEngine.Debug.Assert(listArr.Contains(e3)); UnityEngine.Debug.Assert(listArr.Contains(e4)); CollectionHelpers.CompleteWorld(world); }
public void Remove() { var world = Helpers.PrepareWorld(); var list = new ME.ECS.Collections.IntrusiveDictionary <int, Data>(); list.Add(1, new Data() { a = 10 }); list.Add(2, new Data() { a = 20 }); list.Add(3, new Data() { a = 30 }); list.Add(4, new Data() { a = 40 }); list.Add(4, new Data() { a = 40 }); list.Add(4, new Data() { a = 40 }); UnityEngine.Debug.Assert(list.Count == 4); UnityEngine.Debug.Assert(list.RemoveKey(2)); UnityEngine.Debug.Assert(list.RemoveKey(100) == false); UnityEngine.Debug.Assert(list.Count == 3); Helpers.CompleteWorld(world); }