Exemplo n.º 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;
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
0
        public void Remove_Existing_Removes()
        {
            var existing = new Dummy();

            hashList.Add(existing);

            hashList.Remove(existing);

            Assert.IsEmpty(hashList);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 public bool RemoveContentTrigger(string content)
 {
     lock (_triggerContent)
     {
         return(!string.IsNullOrWhiteSpace(content) && _triggerContent.Remove(content.Trim().ToLowerInvariant()));
     }
 }
Exemplo n.º 6
0
 public bool RemoveCardTrigger(string cardId)
 {
     lock (_triggerCards)
     {
         return(!string.IsNullOrWhiteSpace(cardId) && _triggerCards.Remove(cardId.Trim().ToLowerInvariant()));
     }
 }
Exemplo n.º 7
0
 public bool RemoveResponse(LocalizedString response)
 {
     lock (_responses)
     {
         return(response != null && _responses.Remove(response));
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 9
0
 public bool RemoveResponse(LocalizedString response)
 {
     lock (_responses)
     {
         if (response == null)
         {
             return(false);
         }
         return(_responses.Remove(response));
     }
 }
Exemplo n.º 10
0
        public void Test_Contains_After_Remove()
        {
            var list = new HashList <int>
            {
                2
            };

            list.Remove(2);

            Assert.AreEqual(false, list.Contains(2), "#0");
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
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"));
        }
Exemplo n.º 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));
    }
Exemplo n.º 17
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));
    }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 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"));
        }
        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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        /// <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;
        }
Exemplo n.º 24
0
 internal void Remove(Arbiter arbiter)
 {
     lookUpKey.SetBodies(arbiter.body1, arbiter.body2);
     keysSortedList.Remove(lookUpKey);
     dictionaryKeys.Remove(lookUpKey);
 }