private void RemoveBallsInSequence(GameObject ballInSequence)
    {
        List <BListObject> ballsToRemove = FindBallsInSequence(ballInSequence);

        foreach (BListObject ball in ballsToRemove)
        {
            balls.Remove(ball);
            Destroy(ball.value);
        }
    }
        private void bDeleteButton_Click(object sender, RoutedEventArgs e)
        {
            BList.Remove((BackupTask)backupListBox.SelectedItem);

            backupListBox.ItemsSource      = null;
            backupListBox.ItemsSource      = BList;
            saveButton.Background          = Brushes.Blue;
            backupItemListView.ItemsSource = null;
        }
示例#3
0
        protected override bool RemoveFromBoth(BList <int> blist, List <int> list, int item)
        {
            int i = blist.IndexOf(item);

            if (i == -1)
            {
                return(false);
            }
            blist.Remove(item);
            list.RemoveAt(i);
            return(true);
        }
示例#4
0
            given_existing_blist_when_elements_are_removed_by_element_then_blist_iterator_should_return_correct_elements
            ()
        {
            var initial = new int[512].Select(_ => _random.Next()).ToArray();
            var expected = initial.Skip(32).ToArray();

            var blist = new BList<int>();

            foreach (var item in initial)
                blist.Add(item);

            for (int i = 0; i < 32; i++)
            {
                blist.Remove(initial[i]);
            }

            Assert.That(blist.Count, Is.EqualTo(480));

            CollectionAssert.AreEqual(expected, blist);
        }
示例#5
0
        public void TestStandardOperations()
        {
            List <int>  list  = new List <int>();
            BList <int> blist = NewList();

            // Ensure standard operations work for various list sizes
            int next = 0, item;

            for (int size = 5; size <= 125; size *= 5)
            {
                while (blist.Count < size)
                {
                    AddToBoth(blist, list, next += 2, -1);
                    Assert.AreEqual(list.Count, blist.Count);
                }

                ExpectList(blist, list, _r.Next(2) == 0);

                // Add one in the middle
                int at = blist.FindLowerBound(size);
                blist.Do(AListOperation.Add, size);
                list.Insert(at, size);

                // Remove in different ways
                item = _r.Next(size * 2);
                Assert.AreEqual(list.Remove(item), blist.Remove(item));
                item = _r.Next(size * 2);
                Assert.AreEqual(list.Remove(item), blist.Do(AListOperation.Remove, item) == -1);

                // IndexOf/Contains
                item = _r.Next(size * 2);
                Assert.AreEqual(list.IndexOf(item), blist.IndexOf(item));
                item = _r.Next(size * 2);
                Assert.AreEqual(list.Contains(item), blist.Contains(item));

                ExpectList(blist, list, _r.Next(2) == 0);

                if (_testExceptions)
                {
                    AssertThrows <KeyAlreadyExistsException>(() => blist.Do(AListOperation.AddOrThrow, blist.First));
                }

                // Replace an item with itself (with ints, this command can never
                // do anything, but we'll try it in for completeness). Also,
                // try no-op AddOrReplace and AddIfNotPresent operations to verify
                // that they do nothing.
                Assert.AreEqual(0, blist.Do(AListOperation.ReplaceIfPresent, _r.Next(size)));
                Assert.AreEqual(0, blist.Do(AListOperation.AddOrReplace, blist.Last));
                Assert.AreEqual(0, blist.Do(AListOperation.AddIfNotPresent, blist.First));

                // Also do an AddOrReplace and AddIfNotPresent operation with an
                // item that does not already exist.
                blist.Do(AListOperation.AddOrReplace, next + 3);                 // end of the list
                blist.Do(AListOperation.AddIfNotPresent, next + 1);
                blist.Do(AListOperation.Add, next + 1);
                list.Add(next + 1);
                list.Add(next + 1);
                list.Add(next + 3);

                ExpectList(blist, list, _r.Next(2) == 0);

                Assert.AreEqual(2, blist.RemoveAll(next + 1));
                Assert.IsTrue(list.Remove(next + 1));
                Assert.IsTrue(list.Remove(next + 1));
            }
        }