本文整理汇总了C#中Match.Fix方法的典型用法代码示例。如果您正苦于以下问题:C# Match.Fix方法的具体用法?C# Match.Fix怎么用?C# Match.Fix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match.Fix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompressHC
/// <summary>
/// Compress <code>bytes[off:off+len]</code> into <code>out</code>. Compared to
/// <seealso cref="LZ4#compress(byte[], int, int, DataOutput, HashTable)"/>, this method
/// is slower and uses more memory (~ 256KB per thread) but should provide
/// better compression ratios (especially on large inputs) because it chooses
/// the best match among up to 256 candidates and then performs trade-offs to
/// fix overlapping matches. <code>ht</code> shouldn't be shared across threads
/// but can safely be reused.
/// </summary>
public static void CompressHC(sbyte[] src, int srcOff, int srcLen, DataOutput @out, HCHashTable ht)
{
int srcEnd = srcOff + srcLen;
int matchLimit = srcEnd - LAST_LITERALS;
int mfLimit = matchLimit - MIN_MATCH;
int sOff = srcOff;
int anchor = sOff++;
ht.Reset(srcOff);
Match match0 = new Match();
Match match1 = new Match();
Match match2 = new Match();
Match match3 = new Match();
while (sOff <= mfLimit)
{
if (!ht.InsertAndFindBestMatch(src, sOff, matchLimit, match1))
{
++sOff;
continue;
}
// saved, in case we would skip too much
CopyTo(match1, match0);
while (true)
{
Debug.Assert(match1.Start >= anchor);
if (match1.End() >= mfLimit || !ht.InsertAndFindWiderMatch(src, match1.End() - 2, match1.Start + 1, matchLimit, match1.Len, match2))
{
// no better match
EncodeSequence(src, anchor, [email protected], match1.Start, match1.Len, @out);
anchor = sOff = match1.End();
goto mainContinue;
}
if (match0.Start < match1.Start)
{
if (match2.Start < match1.Start + match0.Len) // empirical
{
CopyTo(match0, match1);
}
}
Debug.Assert(match2.Start > match1.Start);
if (match2.Start - match1.Start < 3) // First Match too small : removed
{
CopyTo(match2, match1);
goto search2Continue;
}
while (true)
{
if (match2.Start - match1.Start < OPTIMAL_ML)
{
int newMatchLen = match1.Len;
if (newMatchLen > OPTIMAL_ML)
{
newMatchLen = OPTIMAL_ML;
}
if (match1.Start + newMatchLen > match2.End() - MIN_MATCH)
{
newMatchLen = match2.Start - match1.Start + match2.Len - MIN_MATCH;
}
int correction = newMatchLen - (match2.Start - match1.Start);
if (correction > 0)
{
match2.Fix(correction);
}
}
if (match2.Start + match2.Len >= mfLimit || !ht.InsertAndFindWiderMatch(src, match2.End() - 3, match2.Start, matchLimit, match2.Len, match3))
{
// no better match -> 2 sequences to encode
if (match2.Start < match1.End())
{
match1.Len = match2.Start - match1.Start;
}
// encode seq 1
EncodeSequence(src, anchor, [email protected], match1.Start, match1.Len, @out);
anchor = sOff = match1.End();
// encode seq 2
EncodeSequence(src, anchor, [email protected], match2.Start, match2.Len, @out);
anchor = sOff = match2.End();
goto mainContinue;
}
if (match3.Start < match1.End() + 3) // Not enough space for match 2 : remove it
{
if (match3.Start >= match1.End()) // // can write Seq1 immediately ==> Seq2 is removed, so Seq3 becomes Seq1
//.........这里部分代码省略.........