mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2024-11-25 07:42:56 +01:00
15 lines
710 B
C#
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();
|
|
}
|
|
}
|