1
0
mirror of https://github.com/chylex/Brotli-Builder.git synced 2024-12-23 01:42:46 +01:00
Brotli-Builder/BrotliLib/Brotli/Parameters/Heuristics/PickCodeHeuristics.cs

15 lines
710 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using BrotliLib.Collections;
namespace BrotliLib.Brotli.Parameters.Heuristics{
public static class PickCodeHeuristics<T> where T : class, IComparable<T>{
public delegate T Picker(List<T> picks, FrequencyList<T> previouslySeen);
public static Picker PickFirstOption { get; } = (picks, previouslySeen) => picks[0];
public static Picker PickPreviouslySeen { get; } = (picks, previouslySeen) => picks.FirstOrDefault(previouslySeen.Contains) ?? picks[0];
public static Picker PickMostFrequent { get; } = (picks, previouslySeen) => picks.OrderByDescending(pick => previouslySeen[pick]).First();
}
}