コード例 #1
0
        public void ForEach()
        {
            var world = CollectionHelpers.PrepareWorld();

            var e1 = new Data("data1");
            var e2 = new Data("data2");
            var e3 = new Data("data3");
            var e4 = new Data("data4");
            var e5 = new Data("data5");

            var list = new ME.ECS.Collections.IntrusiveHashSetGeneric <Data>();

            list.Add(e1);
            list.Add(e2);
            list.Add(e3);
            list.Add(e4);
            list.Add(e5);

            UnityEngine.Debug.Assert(list.Count == 5);

            var listArr = new System.Collections.Generic.List <Data>();

            foreach (var item in list)
            {
                listArr.Add(item);
            }

            UnityEngine.Debug.Assert(listArr.Contains(e1));
            UnityEngine.Debug.Assert(listArr.Contains(e2));
            UnityEngine.Debug.Assert(listArr.Contains(e3));
            UnityEngine.Debug.Assert(listArr.Contains(e4));
            UnityEngine.Debug.Assert(listArr.Contains(e5));

            CollectionHelpers.CompleteWorld(world);
        }
コード例 #2
0
        public void Remove()
        {
            var world = CollectionHelpers.PrepareWorld();

            var first = new Data("data1");
            var e     = new Data("data3");
            var last  = new Data("data5");

            var list = new ME.ECS.Collections.IntrusiveHashSetGeneric <Data>();

            list.Add(first);
            list.Add(new Data("data2"));
            list.Add(e);
            list.Add(new Data("data4"));
            list.Add(last);

            list.Remove(e);
            UnityEngine.Debug.Assert(list.Count == 4);

            list.Remove(first);
            UnityEngine.Debug.Assert(list.Count == 3);

            list.Remove(last);
            UnityEngine.Debug.Assert(list.Count == 2);

            CollectionHelpers.CompleteWorld(world);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void Add()
        {
            var world = CollectionHelpers.PrepareWorld();

            var list = new ME.ECS.Collections.IntrusiveHashSetGeneric <Data>();

            list.Add(new Data("data1"));
            list.Add(new Data("data2"));
            list.Add(new Data("data3"));
            list.Add(new Data("data4"));
            list.Add(new Data("data5"));

            UnityEngine.Debug.Assert(list.Count == 5);

            CollectionHelpers.CompleteWorld(world);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        public void Contains()
        {
            var world = CollectionHelpers.PrepareWorld();

            var first = new Data("data1");
            var e     = new Data("data3");
            var notE  = new Data("data3.1");
            var last  = new Data("data5");

            var list = new ME.ECS.Collections.IntrusiveHashSetGeneric <Data>();

            list.Add(first);
            list.Add(new Data("data2"));
            list.Add(e);
            list.Add(new Data("data4"));
            list.Add(last);

            UnityEngine.Debug.Assert(list.Contains(e) == true);
            UnityEngine.Debug.Assert(list.Contains(notE) == false);

            CollectionHelpers.CompleteWorld(world);
        }
コード例 #8
0
        public void Indexer()
        {
            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[5] = new Data()
            {
                a = 40
            };
            list[5] = new Data()
            {
                a = 50
            };

            UnityEngine.Debug.Assert(list.Count == 5);

            UnityEngine.Debug.Assert(list.ContainsKey(2) == true);
            UnityEngine.Debug.Assert(list.ContainsKey(5) == true);

            CollectionHelpers.CompleteWorld(world);
        }