Exemplo n.º 1
0
        private void cleanupSubscriptions()
        {
            if (pendingRemovals == 0)
            {
                return;
            }

            subscriptions.RemoveWhere(t => !t._1.isSubscribed);
            pendingRemovals = 0;
        }
Exemplo n.º 2
0
        [Test] public void RemoveWhereNoneTest()
        {
            var l = new RandomList <int> {
                1, 3, 5, 7, 9
            };

            l.RemoveWhere(i => i % 2 == 0);
            Assert.AreEqual(F.list(1, 3, 5, 7, 9), l);
            Assert.AreEqual(5, l.Count);
        }
Exemplo n.º 3
0
        [Test] public void RemoveWhereAllTest()
        {
            var l = new RandomList <int> {
                2, 4, 6, 8, 10
            };

            l.RemoveWhere(i => i % 2 == 0);
            Assert.AreEqual(F.emptyList <int>(), l);
            Assert.AreEqual(0, l.Count);
        }
Exemplo n.º 4
0
 void triggerActions()
 {
     actions.RemoveWhere(t => t.ua((runAt, act) => {
         var shouldRun = timePassed >= runAt;
         if (shouldRun)
         {
             act();
         }
         return(shouldRun);
     }));
 }
Exemplo n.º 5
0
        [Test] public void RemoveWhereAlteringTest()
        {
            var l = new RandomList <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };

            l.RemoveWhere(i => i % 2 == 0);
            // { 1, 9, 3, 4, 5, 6, 7, 8 }
            // { 1, 9, 3, 8, 5, 6, 7 }
            // { 1, 9, 3, 7, 5, 6 }
            // { 1, 9, 3, 7, 5 }
            Assert.AreEqual(F.list(1, 9, 3, 7, 5), l);
            Assert.AreEqual(5, l.Count);
        }
Exemplo n.º 6
0
        void triggerActions()
        {
            // Actions might remove themselves as side effects, so we should first evaluate
            // all actions that should be run, then remove the ran actions if they are still
            // there.
            var toRun = actions.Where(t => t.ua((runAt, act, name) => {
                var shouldRun = timePassed >= runAt;
                return(shouldRun);
            })).ToList();

            foreach (var t in toRun)
            {
                t._2();
            }
            actions.RemoveWhere(toRun.Contains);
        }
Exemplo n.º 7
0
        [Test] public void RemoveWhereSequentialTest()
        {
            var l = new RandomList <int> {
                1, 2, 2, 2, 3, 4, 4, 4, 5
            };

            l.RemoveWhere(i => i % 2 == 0);
            // {1, 5, 2, 2, 3, 4, 4, 4}
            // {1, 5, 4, 2, 3, 4, 4}
            // {1, 5, 4, 2, 3, 4}
            // {1, 5, 4, 2, 3}
            // {1, 5, 3, 2}
            // {1, 5, 3}
            Assert.AreEqual(F.list(1, 5, 3), l);
            Assert.AreEqual(3, l.Count);
        }