System.Predicate.Invoke(V)

Here are the examples of the csharp api System.Predicate.Invoke(V) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

19 Source : ImmutableExtensions.cs
with Apache License 2.0
from cs-util-com

public static Func<V> SelectListEntry<T, V>(this IDataStore<T> self, Func<T, ImmutableList<V>> getList, Predicate<V> match) {
            ImmutableList<V> latestList = getList(self.GetState());
            V found = latestList.Find(match);
            int latestPos = latestList.IndexOf(found);
            self.AddStateChangeListener(getList, (changedList) => { latestList = changedList; });
            return () => {
                if (latestList.Count > latestPos) { // First check at the latest known position:
                    V eleAtLastPos = latestList[latestPos];
                    if (match(eleAtLastPos)) { return eleAtLastPos; }
                }
                found = latestList.Find(match);
                latestPos = latestList.IndexOf(found);
                return found;
            };
        }

19 Source : CollectionExtensions.cs
with MIT License
from framebunker

public static int FastRemoveAll<V> ([NotNull] this List<V> source, [NotNull] Predicate<V> test, int startAt = 0)
		{
			int finalCount = source.Count;

			if (finalCount < 1)
			{
				return 0;
			}

			if (finalCount < 2)
			{
				if (!test (source[0]))
				{
					return 0;
				}

				source.Clear ();
				return 1;
			}

			for (int index = startAt; index < finalCount;)
			{
				if (!test (source[index]))
				{
					++index;
					continue;
				}

				if (index < --finalCount)
				{
					source[index] = source[finalCount];
				}
			}

			int diff = source.Count - finalCount;
			if (diff > 0)
			{
				source.RemoveRange (finalCount, diff);
			}

			return diff;
		}

19 Source : Collections.cs
with Apache License 2.0
from tr8dr

public static V FindOne<V> (IEnumerable<V> src, Predicate<V> predicate)
		{
			foreach (var v in src)
				if (predicate (v)) return v;
			
			return default(V);
		}

19 Source : Collections.cs
with Apache License 2.0
from tr8dr

public static IList<V> FindAll<V> (IEnumerable<V> src, Predicate<V> predicate)
		{
			var list = new List<V>();
			foreach (var v in src)
				if (predicate (v)) list.Add(v);
			
			return list;
		}