当前位置: 首页>>代码示例>>C#>>正文


C# BitArray类代码示例

本文整理汇总了C#中BitArray的典型用法代码示例。如果您正苦于以下问题:C# BitArray类的具体用法?C# BitArray怎么用?C# BitArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BitArray类属于命名空间,在下文中一共展示了BitArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: And_EmptyArray

 public static void And_EmptyArray()
 {
     BitArray bitArray1 = new BitArray(0);
     BitArray bitArray2 = new BitArray(0);
     
     Assert.Equal(0, bitArray1.And(bitArray2).Length);
 }
开发者ID:SGuyGe,项目名称:corefx,代码行数:7,代码来源:BitArray_OperatorsTests.cs

示例2: UpdateScreen

 public void UpdateScreen(BitArray bitData)
 {
     for (int i = 0; i < pixelsObjects.Count; i++)
     {
         pixelsObjects[i].SetActive(bitData[i]);
     }
 }
开发者ID:jarkkopa,项目名称:Chip8Unity,代码行数:7,代码来源:DisplayBlocks.cs

示例3: Start

	// Use this for initialization
	void Start () {
		
		
		
		object[] obj = GameObject.FindSceneObjectsOfType(typeof (GameObject));		
		foreach (object o in obj)
		{
			GameObject g = (GameObject) o;
			if(g.GetComponent<PhotoEye>()!=null)
			{
				if(g.GetComponent<PhotoEye>().IO_name_photoeye==IO_name_photoeye_trigger)
				{
					g.GetComponent<PhotoEye>().ConnectATR(gameObject);
				}
			}
		}
		encoding = new System.Text.ASCIIEncoding();		
		
		max_emu_to_plc_io = 1600; // 200 bytes
		emu_to_plc_bits = new BitArray(max_emu_to_plc_io);
		
		
		
		
		Logger.WriteLine("[INFO]","STARTUP AtrsCom on port " + ATR_PORT + " linked to photoeye " + IO_name_photoeye_trigger,"",true);
		Debug.Log("STARTUP AtrsCom on port " + ATR_PORT + " linked to photoeye " + IO_name_photoeye_trigger+".\r\n");
		ready = true;
		
		listenerThread = new Thread(new ThreadStart(DoListen));
        listenerThread.Start();
		
		
	}
开发者ID:wiechars,项目名称:Emulation,代码行数:34,代码来源:AtrsCom.cs

示例4: Read

 public static string Read()
 {
     String xd;
     using(StreamReader reader = new StreamReader("Output.txt"))
     {
         xd = reader.ReadToEnd();
     }
     string[] c = xd.Split(' ');
     List<byte> outputs = new List<byte>();
     foreach(string x in c)
     {
         char[] d = x.ToCharArray();
         BitArray Out = new BitArray(8);
         if (d.Length != 8)
         {
             continue;
         }
         for(int i = 0; i < 8; i++)
         {
             Out[i] = d[i] == 'x';
         }
         outputs.Add(ConvertToByte(Out));
     }
     return Encoding.ASCII.GetString(outputs.ToArray());
 }
开发者ID:thedanieldude1,项目名称:DanielCode,代码行数:25,代码来源:Program.cs

示例5: Main

 static void Main()
 {
     BitArray bits = new BitArray(8);
     bits[0] = 1;
     bits[7] = 1;
     System.Console.WriteLine(bits);
 }
开发者ID:Aleksandyr,项目名称:Software-University,代码行数:7,代码来源:Program.cs

示例6: Decode

	public static string Decode (Texture2D image){
		
		//Get the pixels for the image...
		Color[] imagePixels = image.GetPixels();
		
		//Go Through the First 32 Pixels and create a 4 byte array. 
		//This array should give us the message's length.	
		BitArray newBits = new BitArray(32);
		for (int i=0;i<32;i++){
			if(imagePixels[i].a == 1){
				newBits[i] = true;
			}
			else {
				newBits[i] = false;
			}
		}
		
		int total = System.BitConverter.ToInt32(ToByteArray(newBits), 0);
		BitArray messageBits = new BitArray(total);
		for (int j=32;j<total + 32;j++){
				if(imagePixels[j].a == 1){
					messageBits[j-32] = true;
				}
				else {
					messageBits[j-32] = false;
				}
		}
		
		return System.Text.Encoding.ASCII.GetString(ToByteArray(messageBits));
		
	}
开发者ID:rishabhjoshi,项目名称:Steganography-1,代码行数:31,代码来源:Steganography.cs

示例7: renderCurrentState

    private void renderCurrentState()
    {
        int i;
        BitArray stacks = new BitArray( brain.getKnownObjects().Count );

        foreach ( iThinkFact fact in brain.curState.getFactList() )
        {
            if ( fact.getName().Equals( "onTable" ) )
            {
                i = findNextFreeStack( stacks );
                fact.getObj( 0 ).transform.position = new Vector3( (float)( 1.5 - i * 1.5 ), 0, 0 );
                stacks.Set( i - 1, true );
            }
        }

        foreach ( iThinkFact fact in brain.curState.getFactList() )
        {
            if ( fact.getName().Equals( "on" ) )
            {
                fact.getObj( 0 ).transform.position = fact.getObj( 1 ).transform.position;
                fact.getObj( 0 ).transform.Translate( 0, (float)1.5, 0 );
            }

            else if ( fact.getName().Equals( "holding" ) )
            {
                fact.getObj( 0 ).transform.position = new Vector3( -15, 5, 0 );
            }
        }
    }
开发者ID:bernarde-bgi,项目名称:ithink-unity3d,代码行数:29,代码来源:BlocksWorldAgent.cs

示例8: Main

        static void Main()
        {
            BitArray bits = new BitArray();

            //Random set of bits
            for (int i = 0; i < 64; i++)
            {
                Random random = new Random();
                StringBuilder getTime = new StringBuilder();
                
                int randomNumber = (int)DateTime.Now.Ticks;

                //Трябва ми време за да се получи добър random
                for (int j = 0; j < 100000; j++)
                {
                    Math.Sqrt(j + 1);
                }
                //Край на губенето на време

                if (randomNumber % 2 == 0)
                {
                    bits[i] = 1;
                }
            }

            Console.WriteLine(bits);

            //Print all Bits
            foreach (var item in bits)
            {
                Console.Write(item);
            }
            Console.WriteLine();
        }
开发者ID:nnaidenov,项目名称:TelerikAcademy,代码行数:34,代码来源:BitTest.cs

示例9: 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]);
                }
            }
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:26,代码来源:BitArray_OperatorsTests.cs

示例10: Main

    static void Main()
    {
        BitArray bits = new BitArray(100000);
        bits[99999] = 1;

        Console.WriteLine(bits.ToString());
    }
开发者ID:shnogeorgiev,项目名称:Software-University-Courses,代码行数:7,代码来源:BitArrayDemo.cs

示例11: Main

 static void Main()
 {
     BitArray num = new BitArray(8);
     num[0] = 1;
     num[7] = 1;
     Console.WriteLine(num);
 }
开发者ID:TzvetanIG,项目名称:OOP,代码行数:7,代码来源:TestBitArray.cs

示例12: Main

    static void Main()
    {
        int n = 10000000;
        int m = (int)Math.Sqrt(n);
        BitArray sieve = new BitArray(n);

        int i = 2;
        while (i <= m)
        {
            for (int j = 2 * i; j < n; j += i)
            {
                sieve[j] = true;
            }
            do
            {
                i++;
            }
            while (sieve[i] == true);
        }

        //print just the prime numbers up to 100
        for (int j = 2; j < 100; j++)
        {
            if (sieve[j] == false)
            {
                Console.WriteLine(j);
            }
        }
    }
开发者ID:andon-andonov,项目名称:TelerikAcademy,代码行数:29,代码来源:SieveOfEratosthenes.cs

示例13: GetBitsStuffed

    public BitArray GetBitsStuffed()
    {
        int nstuff = 0;
        bool last = false;
        BitArray ba = new BitArray();
        foreach (bool bit in GetBitsUnstuffed().Bits())
        {
            if (bit == last)
                nstuff++;
            else
            {
                nstuff = 1;
                last = bit;
            }

            if (nstuff > 5)
            {
                ba.AddBit(!last);
                nstuff = 1;
            }

            ba.AddBit(bit);
        }

        return ba;
    }
开发者ID:BuFran,项目名称:canshark,代码行数:26,代码来源:CanMessage.cs

示例14: loadSaveData

    public void loadSaveData(int id)
    {
        currentFlag.SetAll(false);

        //load file
        string filepath = string.Format("{0}/sav{1}", Application.persistentDataPath, id);
        Debug.Log(filepath);

        if (!File.Exists(filepath))
        {
            //show error
            return;
        }

        FileStream fs = File.Open(filepath, FileMode.Open);

        BinaryReader reader = new BinaryReader(fs);
        currentID = reader.ReadInt32();
        byte[] buf = reader.ReadBytes(10);
        currentFlag = new BitArray(buf);

        for (int i = (int)GameValueType.None; i < (int)GameValueType.Max; i++ )
        {
            values[(GameValueType)i] = reader.ReadInt32();
        }

        fs.Flush();
        fs.Close();

        startGame();
    }
开发者ID:ancongsheng,项目名称:vu_paradox,代码行数:31,代码来源:MainGame.cs

示例15: TestSequentialInv

        private static void TestSequentialInv(int count)
        {
            BitArray array = new BitArray(false, count);
            for (int x = 0; x < count; x++)
            {
                if (array.GetBit(x))
                    throw new Exception("each bit should be cleared");
            }

            array = new BitArray(true, count);
            for (int x = 0; x < count; x++)
            {
                if (!array.GetBit(x))
                    throw new Exception("each bit should be set");
            }
            for (int x = 0; x < count; x++)
            {
                array.ClearBit(x);
                if (array.GetBit(x))
                    throw new Exception("each bit should be cleared");
                array.SetBit(x);
                if (!array.GetBit(x))
                    throw new Exception("each bit should be cleared");
                array.ClearBit(x);

                if (array.FindSetBit() != (x == count - 1 ? -1 : x + 1))
                    throw new Exception();
            }
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:29,代码来源:BitArrayTest.cs


注:本文中的BitArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。