1
0
mirror of https://github.com/chylex/Brotli-Builder.git synced 2024-11-24 22:42:50 +01:00
Brotli-Builder/BrotliLib/Collections/Huffman/HuffmanNode.Leaf.cs

31 lines
990 B
C#

using System.Collections.Generic;
using BrotliLib.Serialization;
using BrotliLib.Serialization.Reader;
namespace BrotliLib.Collections.Huffman{
partial class HuffmanNode<T>{
/// <summary>
/// Leaf node that contains a <see cref="value"/> of type <c>T</c>.
/// </summary>
public sealed class Leaf : HuffmanNode<T>{
private readonly T value;
public Leaf(T value){
this.value = value;
}
public override T LookupValue(IBitReader bits){
return value;
}
protected override IEnumerable<KeyValuePair<T, BitStream>> ListValues(BitStream prefix){
yield return new KeyValuePair<T, BitStream>(value, prefix);
}
protected override IEnumerable<KeyValuePair<T, BitPath>> ListValues(BitPath prefix){
yield return new KeyValuePair<T, BitPath>(value, prefix);
}
}
}
}