本文整理汇总了C#中Fingerprint类的典型用法代码示例。如果您正苦于以下问题:C# Fingerprint类的具体用法?C# Fingerprint怎么用?C# Fingerprint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Fingerprint类属于命名空间,在下文中一共展示了Fingerprint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestClear
public void TestClear()
{
// Length > 32
Fingerprint fp = new Fingerprint(65);
for (int i = 0; i < 65; ++i)
{
fp.Touch(i);
Assert.True(fp.Get(i));
}
fp.Clear();
for (int i = 0; i < 65; ++i)
{
Assert.False(fp.Get(i));
}
// Length <= 32
var fp2 = new Fingerprint(6);
for (int i = 0; i < 6; ++i)
{
fp2.Touch(i);
Assert.True(fp2.Get(i));
}
fp.Clear();
for (int i = 0; i < 6; ++i)
{
Assert.False(fp.Get(i));
}
}
示例2: TestCreation
public void TestCreation()
{
var fp = new Fingerprint(7);
var window = new Capo<bool>(fp, 0);
Assert.AreEqual(7, window.Length);
window = new Capo<bool>(fp, 3);
Assert.AreEqual(4, window.Length);
// Invalid offset initialization attempt never throws
Assert.DoesNotThrow(() => { window = new Capo<bool>(fp, 7); });
}
示例3: GetHashCode
public override int GetHashCode(Fingerprint fingerprint)
{
var hash = new Hash(base.GetHashCode(fingerprint));
if (fingerprint.Length <= tag.Offset)
{
return hash.Code;
}
var touched = new Capo<bool>(fingerprint, tag.Offset);
if (touched[0])
{
hash.Update(message_);
}
return hash.Code;
}
示例4: TestComparison
public void TestComparison()
{
Fingerprint fp1 = new Fingerprint(65);
Fingerprint fp2 = new Fingerprint(65);
Fingerprint fp3 = new Fingerprint(64);
Fingerprint fp4 = new Fingerprint(66);
// Length first
Assert.Less(fp3.CompareTo(fp1), 0);
Assert.Greater(fp1.CompareTo(fp3), 0);
fp3.Touch(2);
Assert.Less(fp3.CompareTo(fp1), 0);
Assert.Greater(fp1.CompareTo(fp3), 0);
Assert.Greater(fp4.CompareTo(fp2), 0);
Assert.Less(fp2.CompareTo(fp4), 0);
fp2.Touch(64);
Assert.Greater(fp4.CompareTo(fp2), 0);
Assert.Less(fp2.CompareTo(fp4), 0);
fp2.Wipe(64);
// Bits second
Assert.AreEqual(0, fp1.CompareTo(fp2));
fp1.Touch(31);
Assert.Greater(fp1.CompareTo(fp2), 0);
Assert.Less(fp2.CompareTo(fp1), 0);
fp2.Touch(32);
Assert.Less(fp1.CompareTo(fp2), 0);
Assert.Greater(fp2.CompareTo(fp1), 0);
fp1.Touch(32);
Assert.Greater(fp1.CompareTo(fp2), 0);
Assert.Less(fp2.CompareTo(fp1), 0);
fp2.Touch(31);
Assert.AreEqual(0, fp1.CompareTo(fp2));
Assert.AreEqual(0, fp2.CompareTo(fp1));
fp2.Touch(64);
Assert.Less(fp1.CompareTo(fp2), 0);
Assert.Greater(fp2.CompareTo(fp1), 0);
}
示例5: TestCapoing
public void TestCapoing()
{
var fp = new Fingerprint(8);
fp.Touch(2);
fp.Touch(4);
var window = new Capo<bool>(fp, 3);
Assert.False(window[0]);
Assert.True(window[1]);
Assert.False(window[2]);
fp.Wipe(4);
Assert.False(window[1]);
// Out-of-range indexing never throws
Assert.False(window[-8]);
Assert.False(window[8]);
}
示例6: TestAccessors
public void TestAccessors()
{
var fp = new Fingerprint(33);
Assert.Throws(typeof(IndexOutOfRangeException),
() => { fp.Get(-1); });
Assert.Throws(typeof(IndexOutOfRangeException),
() => { fp.Get(33); });
Assert.False(fp.Get(31));
fp.Touch(31);
Assert.True(fp.Get(31));
fp.Wipe(31);
Assert.False(fp.Get(31));
Assert.False(fp.Get(32));
fp.Touch(32);
Assert.True(fp.Get(32));
fp.Wipe(32);
Assert.False(fp.Get(32));
}
示例7: TestEquivalence
public void TestEquivalence()
{
Fingerprint fp1 = new Fingerprint(65);
Fingerprint fp2 = new Fingerprint(65);
Fingerprint fp3 = new Fingerprint(64);
Fingerprint fp4 = new Fingerprint(66);
// Reference first
Assert.True(fp1.Equivalent(fp1));
Assert.True(fp2.Equivalent(fp2));
Assert.True(fp3.Equivalent(fp3));
Assert.True(fp4.Equivalent(fp4));
// Length second
Assert.True(fp3.Equivalent(fp1));
Assert.False(fp1.Equivalent(fp3));
Assert.False(fp4.Equivalent(fp2));
Assert.True(fp2.Equivalent(fp4));
// Bits third
Assert.True(fp1.Equivalent(fp2));
Assert.True(fp2.Equivalent(fp1));
fp1.Touch(32);
Assert.False(fp1.Equivalent(fp2));
Assert.True(fp2.Equivalent(fp1));
fp2.Touch(32);
Assert.True(fp1.Equivalent(fp2));
Assert.True(fp2.Equivalent(fp1));
fp2.Touch(31);
Assert.True(fp1.Equivalent(fp2));
Assert.False(fp2.Equivalent(fp1));
fp4.Touch(31);
fp4.Touch(32);
fp4.Touch(33);
Assert.True(fp2.Equivalent(fp4));
Assert.False(fp4.Equivalent(fp2));
}
示例8: TestEquality
public void TestEquality()
{
Fingerprint fp1 = new Fingerprint(65);
Fingerprint fp2 = new Fingerprint(65);
Fingerprint fp3 = new Fingerprint(64);
Fingerprint fp4 = new Fingerprint(66);
// Reference first
Assert.True(fp1.Equals(fp1));
Assert.True(fp2.Equals(fp2));
Assert.True(fp3.Equals(fp3));
Assert.True(fp4.Equals(fp4));
// Type second
Assert.False(fp1.Equals(new Object()));
// Length third
Assert.False(fp3.Equals(fp1));
Assert.False(fp1.Equals(fp3));
Assert.False(fp4.Equals(fp2));
Assert.False(fp2.Equals(fp4));
// Bits forth
Assert.True(fp1.Equals(fp2));
Assert.True(fp2.Equals(fp1));
fp1.Touch(32);
Assert.False(fp1.Equals(fp2));
Assert.False(fp2.Equals(fp1));
fp2.Touch(32);
Assert.True(fp1.Equals(fp2));
Assert.True(fp2.Equals(fp1));
// Length <= 32
var fp5 = new Fingerprint(7);
var fp6 = new Fingerprint(7);
fp5.Touch(0);
Assert.False(fp5.Equals(fp6));
fp6.Touch(0);
Assert.True(fp5.Equals(fp6));
}
示例9: SetFingerprint
/// <summary>
/// Sets the fingerprint of this cell as the specified one.
/// </summary>
internal void SetFingerprint(Fingerprint fingerprint)
{
this.fingerprint = fingerprint;
}
示例10: TestCreation
public void TestCreation()
{
var fp1 = new Fingerprint(1);
Assert.AreEqual(1, fp1.Length);
Assert.False(fp1.Get(0));
Fingerprint fp2 = new Fingerprint(33);
Assert.AreEqual(33, fp2.Length);
for (int i = 0; i < 33; ++i)
{
Assert.False(fp2.Get(i));
}
}
示例11: TestNegativeLength
public void TestNegativeLength()
{
Assert.Throws<ArgumentOutOfRangeException>(() => { var fp = new Fingerprint(-1); });
}
示例12: IsEquivalent
protected override bool IsEquivalent(Cell other, Fingerprint fingerprint)
{
if (!base.IsEquivalent(other, fingerprint))
{
return false;
}
return true;
}
示例13: GetFingerprint
// FIXME: return fingerprint of resource stream somehow
public override Fingerprint GetFingerprint (IBuildContext ctxt, Fingerprint cached) {
return GenericFingerprints.Null;
}
示例14: IsEquivalent
protected override bool IsEquivalent(Cell other, Fingerprint fingerprint)
{
if (!base.IsEquivalent(other, fingerprint))
{
return false;
}
HelloResp o = (HelloResp)other;
var touched = new Capo<bool>(fingerprint, tag.Offset);
if (touched[0])
{
if (result_ != o.result_)
{
return false;
}
}
return true;
}
示例15: Equivalent
/// <summary>
/// Determines whether the specified Cell object is equivalent to this
/// one based on the given fingerprint.
/// </summary>
public bool Equivalent(Cell other, Fingerprint fingerprint)
{
if (!other.IsKindOf(this))
{
return false;
}
if (!fingerprint.Equivalent(other.fingerprint))
{
return false;
}
return IsEquivalent(other, fingerprint);
}