source: 2014/24/EemeliK/Zombieland/Jypeli/Physics2DDotNet/ListExtension.cs @ 5974

Revision 5974, 893 bytes checked in by empaheik, 5 years ago (diff)
Line 
1#if WINDOWS_PHONE || XBOX
2
3using System;
4using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7
8namespace Physics2DDotNet
9{
10    /// <summary>
11    /// In Windows Phone, the generic list has no RemoveAll method,
12    /// which is widely used in the physics library. This
13    /// class adds the missing method to the List class.
14    /// </summary>
15    internal static class ListExtension
16    {
17        public static int RemoveAll<T>(this List<T> list, Predicate<T> match)
18        {
19            int count = 0;
20            int i = 0;
21
22            while (i < list.Count)
23            {
24                if (match(list[i]))
25                {
26                    list.RemoveAt(i);
27                    count++;
28                    continue;
29                }
30
31                i++;
32            }
33
34            return count;
35        }
36    }
37}
38
39#endif
Note: See TracBrowser for help on using the repository browser.