本文整理汇总了C#中BitArray.Not方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.Not方法的具体用法?C# BitArray.Not怎么用?C# BitArray.Not使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitArray
的用法示例。
在下文中一共展示了BitArray.Not方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Not
public static void Not(int length)
{
BitArray bitArray = new BitArray(length, false);
if (length > 0)
{
bitArray[0] = true;
bitArray[1] = true;
bitArray[length - 2] = true;
bitArray[length - 1] = true;
}
BitArray bitArrayNot = bitArray.Not();
Assert.Equal(bitArray.Length, bitArrayNot.Length);
Assert.Same(bitArray, bitArrayNot);
for (int i = 0; i < bitArray.Length; i++)
{
if (i <= 1 || i >= length - 2)
{
Assert.False(bitArrayNot[i]);
}
else
{
Assert.True(bitArrayNot[i]);
}
}
}
示例2: GetNeededTrenches
public static IEnumerable<Point> GetNeededTrenches(Pump pump)
{
var digworthy = GetDiggableAndUnDug();
var starts = new HashSet<Point>(pump.GetPoints());
var goals = Bb.GlaciersSet.Where(g => Bb.tileLookup[g].WaterAmount > 5);
var impassable = new BitArray(Bb.OurSpawns).Or(Bb.TheirSpawns).Or(Bb.OurPumps).Or(Bb.TheirPumps);
var path = Pather.AStar(starts, p => goals.Contains(p), impassable.Not(), (c, n) => digworthy.Get(n) ? 1 : 0, p => 0);
return path.Where(p => digworthy.Get(p));
}
示例3: GetOurSpawnable
public static BitArray GetOurSpawnable()
{
// (spawns + pumps-not-under-seige) - units - spawning
var spawns = Bb.OurSpawnSet.ToBitArray();
var pumps = Bb.OurPumpSet.Where(p => p.station.SiegeAmount == 0).SelectMany(p => p.GetPoints()).ToBitArray();
var units = new BitArray(Bb.OurUnits).Or(Bb.TheirUnits);
var spawning = new BitArray(Bb.IsSpawning);
return spawns.Or(pumps).And(units.Not()).And(spawning.Not());
}
示例4: Not
public static void Not(bool[] data)
{
BitArray bitArray = new BitArray(data);
BitArray bitArrayNot = bitArray.Not();
Assert.Equal(bitArray.Length, bitArrayNot.Length);
Assert.Same(bitArray, bitArrayNot);
for (int i = 0; i < bitArray.Length; i++)
{
Assert.Equal(!data[i], bitArrayNot[i]);
}
}
示例5: runTest
public virtual bool runTest()
{
System.Console.Error.WriteLine( "BitArray- Co1553Not runTest started." );
int iCountErrors = 0;
int iCountTestcases = 0;
BitArray ba2 = null;
BitArray ba4 = null;
System.Console.Out.WriteLine( "Standard cases (1,1) (1,0) (0,0)." );
ba2 = new BitArray( 6 ,false );
ba2.Set( 0 ,true );
ba2.Set( 1 ,true );
ba4 = ba2.Not();
++iCountTestcases;
if ( ba2 != ba4 )
{
++iCountErrors;
System.Console.Error.WriteLine( "Co1553Not Error E_545wi!" );
}
for ( int aa=0 ;aa<ba2.Length ;aa++ )
{
if ( aa <= 1 )
{
if ( ba2.Get( aa ) )
{
++iCountErrors;
System.Console.Error.WriteLine( "Co1553Not Error E_837rt!" );
}
}
else
{
if ( ! ba2.Get( aa ) )
{
++iCountErrors;
System.Console.Error.WriteLine( "Co1553Not Error E_859yb!" );
}
}
}
System.Console.Out.WriteLine( "Size stress cases." );
ba2 = new BitArray( 0x1000F ,false );
ba2.Set( 0 ,true );
ba2.Set( 1 ,true );
ba2.Set( 0x10000 ,true );
ba2.Set( 0x10001 ,true );
ba4 = ba2.Not();
++iCountTestcases;
if ( ba4.Get(1) )
{
++iCountErrors;
System.Console.Error.WriteLine( "Co1553Not Error E_067xs!" );
}
++iCountTestcases;
if ( ! ba4.Get(2) )
{
++iCountErrors;
System.Console.Error.WriteLine( "Co1553Not Error E_244tm!" );
}
for ( int aa=0x10000 ;aa<ba2.Length ;aa++ )
{
if ( aa <= 0x10001 )
{
if ( ba2.Get( aa ) )
{
++iCountErrors;
System.Console.Error.Write( "Co1553Not Error E_073wq! aa==" );
System.Console.Error.WriteLine( aa );
break;
}
}
else
{
if ( ! ba2.Get( aa ) )
{
++iCountErrors;
System.Console.Error.Write( "Co1553Not Error E_246ko! aa==" );
System.Console.Error.WriteLine( aa );
break;
}
}
}
if ( iCountErrors == 0 )
{
System.Console.Error.Write( "BitArray- Co1553Not: paSs. iCountTestcases==" );
System.Console.Error.WriteLine( iCountTestcases );
return true;
}
else
{
System.Console.Error.Write( "Co1553Not iCountErrors==" );
System.Console.Error.WriteLine( iCountErrors );
System.Console.Error.WriteLine( "BitArray- Co1553Not: FAiL!" );
return false;
}
}