あなたがC#を使いたいと仮定すると、私は次のようなものから始めます:
// General interface to filter out whatever you want, given a list:
public interface IFilterElements<T>
{
IEnumerable<T> Filter(IEnumerable<T> elementList);
}
// An example imlementation - add more of these as required:
class FilterElementsThatAreEven<T> : IFilterElements<T>
{
public IEnumerable<T> Filter(IEnumerable<T> elementList)
{
// Some implementation to return a sorted set / list
}
}
呼び出しメソッドで、次のようなことを行うことができます。
// List to filter
IEnumerable<int> myListOfInts = new int[]{1, 2, 3, 4, 5, 6};
// Instantiation of the implementation - also where you specify the
// type of data to filter (could be of class "MagicLemur" instead of int)
IFilterElements<int> myIntFilter = new FilterElementsThatAreEven<int>();
var filteredList = myIntFilter.FilterElementsThatAreEven();