using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace QC.QMine.QMineInterface;

public static class Extensions
{
	public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
	{
		if (enumerable == null)
		{
			return;
		}
		foreach (T item in enumerable)
		{
			action?.Invoke(item);
		}
	}

	public static void RemoveAll<T>(this ObservableCollection<T> observableCollection, Predicate<T> match)
	{
		List<T> list = observableCollection.ToList().FindAll(match);
		list.ForEach(delegate(T matchItem)
		{
			observableCollection.Remove(matchItem);
		});
	}

	public static void AddRange<T>(this SortedSet<T> sortedSet, IEnumerable<T> collection)
	{
		collection.ForEach(delegate(T col)
		{
			sortedSet.Add(col);
		});
	}
}
