本文整理汇总了C#中Lucene.Net.Util.OpenBitSet.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# OpenBitSet.Equals方法的具体用法?C# OpenBitSet.Equals怎么用?C# OpenBitSet.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Util.OpenBitSet
的用法示例。
在下文中一共展示了OpenBitSet.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoRandomSets
//.........这里部分代码省略.........
{
aa = (System.Collections.BitArray)a.Clone();
}
for (int j = fromIndex; j < toIndex; j++) aa.Set(j, false);
bb = (OpenBitSet)b.Clone(); bb.Clear(fromIndex, toIndex);
DoNextSetBit(aa, bb); // a problem here is from clear() or nextSetBit
fromIndex = rand.Next(sz + 80);
toIndex = fromIndex + rand.Next((sz >> 1) + 1);
// {{dougsale-2.4.0}}:
// The following commented-out, compound statement's 'for loop' implicitly grows the Java BitSet 'aa'
// when 'a.Count < j+1' and 'fromIndex < toIndex'
//aa = (BitArray)a.Clone(); for (int j = fromIndex; j < toIndex; j++) aa.Set(j, false);
// So, if necessary, lets explicitly grow 'aa' now
if (a.Count < toIndex && fromIndex < toIndex)
{
aa = new System.Collections.BitArray(toIndex);
for (int k = 0; k < a.Count; k++)
aa.Set(k, a.Get(k));
}
else
{
aa = (System.Collections.BitArray)a.Clone();
}
for (int j = fromIndex; j < toIndex; j++) aa.Set(j, true);
bb = (OpenBitSet)b.Clone(); bb.Set(fromIndex, toIndex);
DoNextSetBit(aa, bb); // a problem here is from set() or nextSetBit
if (a0 != null)
{
Assert.AreEqual(a.Equals(a0), b.Equals(b0));
Assert.AreEqual(SupportClass.BitSetSupport.Cardinality(a), b.Cardinality());
// {{dougsale-2.4.0}}
//
// The Java code used java.util.BitSet, which grows as needed.
// When a bit, outside the dimension of the set is referenced,
// the set automatically grows to the necessary size. The
// new entries default to false.
//
// BitArray does not grow automatically and is not growable.
// Thus when BitArray instances of mismatched cardinality
// interact, we must first explicitly "grow" the smaller one.
//
// This growth is acheived by creating a new instance of the
// required size and copying the appropriate values.
//
//BitArray a_and = (BitArray)a.Clone(); a_and.And(a0);
//BitArray a_or = (BitArray)a.Clone(); a_or.Or(a0);
//BitArray a_xor = (BitArray)a.Clone(); a_xor.Xor(a0);
//BitArray a_andn = (BitArray)a.Clone(); for (int j = 0; j < a_andn.Count; j++) if (a0.Get(j)) a_andn.Set(j, false);
System.Collections.BitArray a_and;
System.Collections.BitArray a_or;
System.Collections.BitArray a_xor;
System.Collections.BitArray a_andn;
if (a.Count < a0.Count)
{
// the Java code would have implicitly resized 'a_and', 'a_or', 'a_xor', and 'a_andn'
// in this case, so we explicitly create a resized stand-in for 'a' here, allowing for
示例2: TestEquals
public virtual void TestEquals()
{
rand = NewRandom();
OpenBitSet b1 = new OpenBitSet(1111);
OpenBitSet b2 = new OpenBitSet(2222);
Assert.IsTrue(b1.Equals(b2));
Assert.IsTrue(b2.Equals(b1));
b1.Set(10);
Assert.IsFalse(b1.Equals(b2));
Assert.IsFalse(b2.Equals(b1));
b2.Set(10);
Assert.IsTrue(b1.Equals(b2));
Assert.IsTrue(b2.Equals(b1));
b2.Set(2221);
Assert.IsFalse(b1.Equals(b2));
Assert.IsFalse(b2.Equals(b1));
b1.Set(2221);
Assert.IsTrue(b1.Equals(b2));
Assert.IsTrue(b2.Equals(b1));
// try different type of object
Assert.IsFalse(b1.Equals(new System.Object()));
}