コード例 #1
0
        private void SortAxis(List <SweepPoint> axis)
        {
            for (int j = 1; j < axis.Count; j++)
            {
                SweepPoint keyelement = axis[j];
                FP         key        = keyelement.Value;

                int i = j - 1;

                while (i >= 0 && axis[i].Value > key)
                {
                    SweepPoint swapper = axis[i];

                    if (keyelement.Begin && !swapper.Begin)
                    {
                        if (CheckBoundingBoxes(swapper.Body, keyelement.Body))
                        {
                            lock (fullOverlaps) fullOverlaps.Add(new OverlapPair(swapper.Body, keyelement.Body));
                        }
                    }

                    if (!keyelement.Begin && swapper.Begin)
                    {
                        lock (fullOverlaps) fullOverlaps.Remove(new OverlapPair(swapper.Body, keyelement.Body));
                    }

                    axis[i + 1] = swapper;
                    i           = i - 1;
                }
                axis[i + 1] = keyelement;
            }
        }
コード例 #2
0
        public void VersionCheck_Remove()
        {
            var list = new HashList <int>
            {
                5
            };
            IEnumerator enumerator = list.GetEnumerator();

            // version number is not incremented if item does not exist in list
            list.Remove(7);
            enumerator.MoveNext();
            list.Remove(5);

            try
            {
                enumerator.MoveNext();
                Assert.Fail("#1");
            }
            catch (InvalidOperationException)
            {
            }

            try
            {
                enumerator.Reset();
                Assert.Fail("#2");
            }
            catch (InvalidOperationException)
            {
            }

            enumerator = list.GetEnumerator();
            enumerator.MoveNext();
        }
コード例 #3
0
        public void Remove_Existing_Removes()
        {
            var existing = new Dummy();

            hashList.Add(existing);

            hashList.Remove(existing);

            Assert.IsEmpty(hashList);
        }
コード例 #4
0
        public void RemoveTest()
        {
            var count  = _list1.Count;
            var result = _list1.Remove(22);

            Assert.IsTrue(result);
            Assert.AreEqual(count - 1, _list1.Count);

            Assert.AreEqual(-1, _list1.IndexOf(22));

            result = _list1.Remove(0);
            Assert.IsFalse(result);
        }
コード例 #5
0
ファイル: Taunt.cs プロジェクト: nhubbard/cards-over-lan
 public bool RemoveContentTrigger(string content)
 {
     lock (_triggerContent)
     {
         return(!string.IsNullOrWhiteSpace(content) && _triggerContent.Remove(content.Trim().ToLowerInvariant()));
     }
 }
コード例 #6
0
ファイル: Taunt.cs プロジェクト: nhubbard/cards-over-lan
 public bool RemoveCardTrigger(string cardId)
 {
     lock (_triggerCards)
     {
         return(!string.IsNullOrWhiteSpace(cardId) && _triggerCards.Remove(cardId.Trim().ToLowerInvariant()));
     }
 }
コード例 #7
0
ファイル: Taunt.cs プロジェクト: nhubbard/cards-over-lan
 public bool RemoveResponse(LocalizedString response)
 {
     lock (_responses)
     {
         return(response != null && _responses.Remove(response));
     }
 }
コード例 #8
0
        /// <summary>
        /// Elimina un elemento de la lista principal y de la de HASH
        /// </summary>
        /// <param name="oid"></param>
        public void Remove(long oid)
        {
            C obj = this.GetItem(oid);

            if (obj != null)
            {
                Remove(obj);
                HashList.Remove(obj);
            }
        }
コード例 #9
0
 public bool RemoveResponse(LocalizedString response)
 {
     lock (_responses)
     {
         if (response == null)
         {
             return(false);
         }
         return(_responses.Remove(response));
     }
 }
コード例 #10
0
        public void Test_Contains_After_Remove()
        {
            var list = new HashList <int>
            {
                2
            };

            list.Remove(2);

            Assert.AreEqual(false, list.Contains(2), "#0");
        }
コード例 #11
0
ファイル: HashListExamples.cs プロジェクト: krs43/ngenerics
        public void RemoveKeyValueExample()
        {
            var whatAnimalEatHashList = new HashList <string, string>
            {
                { "dog", "dog food" },
                { "dog", "bones" }
            };

            Assert.AreEqual(2, whatAnimalEatHashList["dog"].Count);
            whatAnimalEatHashList.Remove("dog", "bones");
            Assert.AreEqual(1, whatAnimalEatHashList["dog"].Count);
        }
コード例 #12
0
        void RemoveAlert(TDBaseAlertData alert)
        {
            BaseAlertItem tempAlert = ActiveItems.Find((x) => { return(x.ID == alert.ID); });

            if (tempAlert == null)
            {
                return;
            }
            tempAlert.Show(false);
            ActiveItems.Remove(tempAlert);
            AlertDatasSet.Remove(alert);
        }
コード例 #13
0
        void Remove(BaseLogData data)
        {
            BaseLogItem tempLogItem = ActiveItems.Find((x) => { return(x.ID == data.ID); });

            if (tempLogItem == null)
            {
                return;
            }
            tempLogItem.Show(false);
            ActiveItems.Remove(tempLogItem);
            DatasSet.Remove(data);
        }
コード例 #14
0
ファイル: HashListTest.cs プロジェクト: jungs1330/ZProjects
        public void TestRemove()
        {
            HashList <int, string> h = new HashList <int, string>();

            h.Add(2, "a");

            Assert.AreEqual(h.ValueCount, 1);
            Assert.AreEqual(h.KeyCount, 1);

            h.Add(4, new List <string>(new string[] { "2", "3", "4", "5" }));

            Assert.AreEqual(h.ValueCount, 5);
            Assert.AreEqual(h.KeyCount, 2);

            Assert.AreEqual(h.Remove(2), true);
            Assert.AreEqual(h.KeyCount, 1);
            Assert.AreEqual(h.ValueCount, 4);

            Assert.AreEqual(h.Remove(2), false);
            Assert.AreEqual(h.KeyCount, 1);
            Assert.AreEqual(h.ValueCount, 4);

            Assert.AreEqual(h.Remove("2"), true);

            Assert.AreEqual(h.KeyCount, 1);
            Assert.AreEqual(h.ValueCount, 3);

            Assert.AreEqual(h.Remove(3, "2"), false);

            Assert.AreEqual(h.KeyCount, 1);
            Assert.AreEqual(h.ValueCount, 3);

            Assert.AreEqual(h.Remove(4, "2"), false);

            Assert.AreEqual(h.KeyCount, 1);
            Assert.AreEqual(h.ValueCount, 3);

            Assert.AreEqual(h.Remove(4, "5"), true);

            Assert.AreEqual(h.KeyCount, 1);
            Assert.AreEqual(h.ValueCount, 2);

            h.Add(4, "4");

            Assert.AreEqual(h.KeyCount, 1);
            Assert.AreEqual(h.ValueCount, 3);

            h.RemoveAll("4");

            Assert.AreEqual(h.KeyCount, 1);
            Assert.AreEqual(h.ValueCount, 1);
        }
コード例 #15
0
ファイル: HashListExamples.cs プロジェクト: krs43/ngenerics
        public void RemoveExample()
        {
            var whatAnimalEatHashList = new HashList <string, string>
            {
                { "cat", "milk" },
                { "cat", "fish" },
                { "dog", "dog food" },
                { "dog", "bones" },
                { "tiger", "people" }
            };

            // HashList contains "dog"
            Assert.IsTrue(whatAnimalEatHashList.ContainsKey("dog"));

            // Remove "dog"
            whatAnimalEatHashList.Remove("dog");

            // HashList does not contain "dog"
            Assert.IsFalse(whatAnimalEatHashList.ContainsKey("dog"));
        }
コード例 #16
0
    // Use this for initialization
    void Start()
    {
        list = new List <HashList <int> >();
        for (int i = 0; i < 1000; i++)
        {
            var hash = new HashList <int>(15000);
            for (int j = 0; j < 10000; j++)
            {
                hash.Add(Random.Range(int.MinValue, int.MaxValue));
            }
        }

        var set = new HashList <int>();

        Debug.Log("Add 1 " + set.Add(1));
        Debug.Log("Add 1 " + set.Add(1));
        set.Add(30000);
        set.Add(444);
        Debug.Log("Add 5555 " + set.Add(5555));
        set.Add(500000);
        set.Add(364892679);

        set.Remove(444);
        Debug.Log("Set contains 444 = " + set.Contains(444));
        Debug.Log("Size = " + set.Count);

        foreach (var i in set)
        {
            Debug.Log("Set contains " + i + " = " + set.Contains(i));
        }


        Debug.Log("Set contains 11 = " + set.Contains(11));
        Debug.Log("Set contains 23 = " + set.Contains(23));
        Debug.Log("Set contains 16 = " + set.Contains(16));
        Debug.Log("Set contains 32 = " + set.Contains(32));
        Debug.Log("Set contains 33 = " + set.Contains(33));
    }
コード例 #17
0
ファイル: GarbageTest.cs プロジェクト: vildninja/voxel
    // Use this for initialization
    void Start ()
    {
        list = new List<HashList<int>>();
        for (int i = 0; i < 1000; i++)
        {
            var hash = new HashList<int>(15000);
            for (int j = 0; j < 10000; j++)
            {
                hash.Add(Random.Range(int.MinValue, int.MaxValue));
            }
        }

        var set = new HashList<int>();
        Debug.Log("Add 1 " + set.Add(1));
        Debug.Log("Add 1 " + set.Add(1));
        set.Add(30000);
        set.Add(444);
        Debug.Log("Add 5555 " + set.Add(5555));
        set.Add(500000);
        set.Add(364892679);

        set.Remove(444);
        Debug.Log("Set contains 444 = " + set.Contains(444));
        Debug.Log("Size = " + set.Count);

        foreach (var i in set)
        {
            Debug.Log("Set contains " + i + " = " + set.Contains(i));
        }


        Debug.Log("Set contains 11 = " + set.Contains(11));
        Debug.Log("Set contains 23 = " + set.Contains(23));
        Debug.Log("Set contains 16 = " + set.Contains(16));
        Debug.Log("Set contains 32 = " + set.Contains(32));
        Debug.Log("Set contains 33 = " + set.Contains(33));
    }
コード例 #18
0
ファイル: Remove.cs プロジェクト: havok/ngenerics
        public void Simple()
        {
            var hashList = new HashList<int, string> {{2, "a"}};

            Assert.AreEqual(hashList.ValueCount, 1);
            Assert.AreEqual(hashList.KeyCount, 1);

            hashList.Add(4, new List<string>(new[] { "2", "3", "4", "5" }));

            Assert.AreEqual(hashList.ValueCount, 5);
            Assert.AreEqual(hashList.KeyCount, 2);

            Assert.IsTrue(hashList.Remove(2));
            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 4);

            Assert.IsFalse(hashList.Remove(2));
            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 4);

            Assert.IsTrue(hashList.RemoveValue("2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsFalse(hashList.Remove(3, "2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsFalse(hashList.Remove(4, "2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsTrue(hashList.Remove(4, "5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);

            hashList.Add(4, "4");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            hashList.RemoveAll("4");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 1);

            Assert.IsFalse(hashList.Remove(10));

            hashList.Add(4, "5");
            hashList.Add(4, "6");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsTrue(hashList.RemoveValue("5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);

            Assert.IsFalse(hashList.RemoveValue("5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);
        }
コード例 #19
0
        public void RemoveExample()
        {
            var whatAnimalEatHashList = new HashList<string, string>
                                            {
                                                {"cat", "milk"},
                                                {"cat", "fish"},
                                                {"dog", "dog food"},
                                                {"dog", "bones"},
                                                {"tiger", "people"}
                                            };

            // HashList contains "dog"
            Assert.IsTrue(whatAnimalEatHashList.ContainsKey("dog"));

            // Remove "dog"
            whatAnimalEatHashList.Remove("dog");

            // HashList does not contain "dog"
            Assert.IsFalse(whatAnimalEatHashList.ContainsKey("dog"));
        }
コード例 #20
0
        private bool RemoveBody(RigidBody body, bool removeMassPoints)
        {
            // Its very important to clean up, after removing a body
            if (!removeMassPoints && body.IsParticle)
            {
                return(false);
            }

            // remove the body from the world list
            if (!rigidBodies.Remove(body))
            {
                return(false);
            }

            // Remove all connected constraints and arbiters
            for (int index = 0, length = body.arbiters.Count; index < length; index++)
            {
                Arbiter arbiter = body.arbiters[index];

                arbiterMap.Remove(arbiter);

                events.RaiseBodiesEndCollide(arbiter.body1, arbiter.body2);

                cacheOverPairContact.SetBodies(arbiter.body1, arbiter.body2);
                initialCollisions.Remove(cacheOverPairContact);
            }

            for (int index = 0, length = body.arbitersTrigger.Count; index < length; index++)
            {
                Arbiter arbiter = body.arbitersTrigger[index];
                arbiterTriggerMap.Remove(arbiter);

                if (arbiter.body1.isColliderOnly)
                {
                    events.RaiseTriggerEndCollide(arbiter.body1, arbiter.body2);
                }
                else
                {
                    events.RaiseTriggerEndCollide(arbiter.body2, arbiter.body1);
                }

                cacheOverPairContact.SetBodies(arbiter.body1, arbiter.body2);
                initialTriggers.Remove(cacheOverPairContact);
            }

            for (int index = 0, length = body.constraints.Count; index < length; index++)
            {
                Constraint constraint = body.constraints[index];

                constraints.Remove(constraint);
                events.RaiseRemovedConstraint(constraint);
            }

            // remove the body from the collision system
            CollisionSystem.RemoveEntity(body);

            // remove the body from the island manager
            islands.RemoveBody(body);

            events.RaiseRemovedRigidBody(body);

            return(true);
        }
コード例 #21
0
 public void RemoveKeyValueExample()
 {
     var whatAnimalEatHashList = new HashList<string, string>
                                     {
                                         {"dog", "dog food"},
                                         {"dog", "bones"}
                                     };
     Assert.AreEqual(2, whatAnimalEatHashList["dog"].Count);
     whatAnimalEatHashList.Remove("dog", "bones");
     Assert.AreEqual(1, whatAnimalEatHashList["dog"].Count);
 }
コード例 #22
0
ファイル: Remove.cs プロジェクト: raveeram/ngenerics
        public void Simple()
        {
            var hashList = new HashList <int, string> {
                { 2, "a" }
            };

            Assert.AreEqual(hashList.ValueCount, 1);
            Assert.AreEqual(hashList.KeyCount, 1);

            hashList.Add(4, new List <string>(new[] { "2", "3", "4", "5" }));

            Assert.AreEqual(hashList.ValueCount, 5);
            Assert.AreEqual(hashList.KeyCount, 2);

            Assert.IsTrue(hashList.Remove(2));
            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 4);

            Assert.IsFalse(hashList.Remove(2));
            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 4);

            Assert.IsTrue(hashList.RemoveValue("2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsFalse(hashList.Remove(3, "2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsFalse(hashList.Remove(4, "2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsTrue(hashList.Remove(4, "5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);

            hashList.Add(4, "4");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            hashList.RemoveAll("4");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 1);

            Assert.IsFalse(hashList.Remove(10));

            hashList.Add(4, "5");
            hashList.Add(4, "6");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);


            Assert.IsTrue(hashList.RemoveValue("5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);

            Assert.IsFalse(hashList.RemoveValue("5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);
        }
コード例 #23
0
ファイル: AStar.cs プロジェクト: simonwittber/uniextensions
        /// <summary>
        /// Calculate the route from start to end.
        /// </summary>
        /// <param name="start">Start.</param>
        /// <param name="end">End.</param>
        public void Route(T start, T end, List <T> route)
        {
            route.Clear();
            if (start == null || end == null)
            {
                return;
            }

            for (int i = 0, nodesLength = nodes.Length; i < nodesLength; i++)
            {
                var s = nodes[i];
                g[s]      = 0f;
                parent[s] = null;
                inPath[s] = false;
            }
            openset.Clear();
            closedset.Clear();
            path.Clear();

            var current = start;

            openset.Add(current);
            while (openset.Count > 0)
            {
                current = openset[0];
                for (var i = 1; i < openset.Count; i++)
                {
                    var d = g[current].CompareTo(g[openset[i]]);
                    if (d < 0)
                    {
                        current = openset[i];
                    }
                }
                //openset.Sort ((a,b) => g [a].CompareTo (g [b]));
                current = openset[0];
                if (current == end)
                {
                    while (parent[current] != null)
                    {
                        path.Enqueue(current);
                        inPath[current] = true;
                        current         = parent[current];
                        if (path.Count >= nodes.Length)
                        {
                            return;
                        }
                    }
                    inPath[current] = true;
                    path.Enqueue(current);
                    while (path.Count > 0)
                    {
                        route.Add(path.Dequeue());
                    }
                    return;
                }
                openset.Remove(current);
                closedset.Add(current);
                var connectedNodes = current.GetConnectedNodes();
                for (int i = 0, connectedNodesCount = connectedNodes.Count; i < connectedNodesCount; i++)
                {
                    var node = connectedNodes[i];
                    if (closedset.Contains(node))
                    {
                        continue;
                    }
                    if (openset.Contains(node))
                    {
                        var new_g = g[current] + current.CalculateMoveCost(node);
                        if (g[node] > new_g)
                        {
                            g[node]      = new_g;
                            parent[node] = current;
                        }
                    }
                    else
                    {
                        g[node]      = g[current] + current.CalculateMoveCost(node);
                        parent[node] = current;
                        openset.Add(node);
                    }
                }
            }
            return;
        }
コード例 #24
0
 internal void Remove(Arbiter arbiter)
 {
     lookUpKey.SetBodies(arbiter.body1, arbiter.body2);
     keysSortedList.Remove(lookUpKey);
     dictionaryKeys.Remove(lookUpKey);
 }