Esempio n. 1
0
        public static void Get_Mask_NoneSetTest()
        {
            BitVector32 none = new BitVector32();
            int         mask = 0;

            for (int count = 0; count < 32; count++)
            {
                mask = BitVector32.CreateMask(mask);
                Assert.False(none[mask]);
            }
            Assert.Equal(int.MinValue, mask);
        }
Esempio n. 2
0
        public static void Get_Mask_AllSetTest()
        {
            BitVector32 all  = new BitVector32(-1);
            int         mask = 0;

            for (int count = 0; count < 32; count++)
            {
                mask = BitVector32.CreateMask(mask);
                Assert.True(all[mask]);
            }
            Assert.Equal(int.MinValue, mask);
        }
Esempio n. 3
0
        static void Main()
        {
            //var vector = new BitVector32(0);

            //int firstBit = BitVector32.CreateMask();           // ... 0000 0001 B - 1D
            //int secondBit = BitVector32.CreateMask(firstBit);  // ... 0000 0010 B - 2D
            //int thirdBit = BitVector32.CreateMask(secondBit);  // ... 0000 0100 B - 4D
            //Console.WriteLine(firstBit + " " + secondBit + " " + thirdBit); // Test

            //vector[firstBit] = true;
            //vector[secondBit] = true;

            //Console.WriteLine("{0} должно быть 3", vector.Data);
            //Console.WriteLine(vector.ToString());

            //var newVector = new BitVector32(4);
            //Console.WriteLine(newVector);

            //bool bit1 = newVector[firstBit];
            //bool bit2 = newVector[secondBit];
            //bool bit3 = newVector[thirdBit];

            //Console.WriteLine("bit1 = {0}, bit2 = {1}, bit3 = {2}", bit1, bit2, bit3);

            BitVector32 vector    = new BitVector32(0);
            int         firstBit  = BitVector32.CreateMask();
            int         secondBit = BitVector32.CreateMask(firstBit);
            int         thirdBit  = BitVector32.CreateMask(secondBit);

            //int fouthBit = BitVector32.CreateMask(thirdBit);

            //Console.WriteLine(firstBit + " " + secondBit + " " + thirdBit + " " + fouthBit);
            Console.WriteLine(firstBit + " " + secondBit + " " + thirdBit);

            vector[firstBit]  = true;
            vector[secondBit] = false;

            Console.WriteLine("{0} it must be 3", vector.Data);
            Console.WriteLine(vector.ToString());

            var newVector = new BitVector32(4);

            Console.WriteLine(newVector);

            bool bit1 = newVector[firstBit];
            bool bit2 = newVector[secondBit];
            bool bit3 = newVector[thirdBit];

            Console.WriteLine("bit1 = {0}, bit2 = {1}, bit3 = {2}", bit1, bit2, bit3);

            // Delay.
            Console.ReadKey();
        }
Esempio n. 4
0
        public static (ImplicitClusterInfo, List <BitVector32>) LoadData(string inputFile)
        {
            //init masks to load up bit vectors
            masks    = new int[32];
            masks[0] = BitVector32.CreateMask();
            for (int i = 1; i < 32; i++)
            {
                masks[i] = BitVector32.CreateMask(masks[i - 1]);
            }

            return(DataReader.ReadData(inputFile, ImplicitClusterInfo.FromString, ParseBits));
        }
Esempio n. 5
0
        public BitVector32 CreateComponentBits(int entityId)
        {
            var componentBits = new BitVector32();
            var mask          = BitVector32.CreateMask();

            for (var componentId = 0; componentId < _componentMappers.Count; componentId++)
            {
                componentBits[mask] = _componentMappers[componentId]?.Has(entityId) ?? false;
                mask = BitVector32.CreateMask(mask);
            }

            return(componentBits);
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes static members of the <see cref="WebBrowserEx"/> class.
        /// </summary>
        /// <exception cref="T:System.NotSupportedException">
        /// The <see cref="T:System.Windows.Forms.WebBrowser"/> control is hosted inside Internet Explorer.
        /// </exception>
        static WebBrowserEx()
        {
            webBrowserStateNo3DOuterBorder   = BitVector32.CreateMask();
            webBrowserStateNo3DBorder        = BitVector32.CreateMask(webBrowserStateNo3DOuterBorder);
            webBrowserStateRegisterAsBrowser = BitVector32.CreateMask(webBrowserStateNo3DBorder);
            webBrowserStatePrivacyImpacted   = BitVector32.CreateMask(webBrowserStateRegisterAsBrowser);
            webBrowserStateResizable         = BitVector32.CreateMask(webBrowserStatePrivacyImpacted);

            encryptionLevelFieldInfo = typeof(global::System.Windows.Forms.WebBrowser).GetField("encryptionLevel", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            canGoBackInternalPropertyInfo    = typeof(global::System.Windows.Forms.WebBrowser).GetProperty("CanGoBackInternal", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            canGoForwardInternalPropertyInfo = typeof(global::System.Windows.Forms.WebBrowser).GetProperty("CanGoForwardInternal", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        }
Esempio n. 7
0
        public static void Get_Mask_SomeSetTest()
        {
            // Constructs data with every even bit set.
            int         data = Enumerable.Range(0, 16).Sum(x => 1 << (x * 2));
            BitVector32 some = new BitVector32(data);
            int         mask = 0;

            for (int index = 0; index < 32; index++)
            {
                mask = BitVector32.CreateMask(mask);
                Assert.Equal(index % 2 == 0, some[mask]);
            }
            Assert.Equal(int.MinValue, mask);
        }
Esempio n. 8
0
        private void set_dout()
        {
            char        i;
            int         dd;
            BitVector32 d = new BitVector32(0);
            // Creates masks to isolate each of the first 6 bit flags.
            int myBit1 = BitVector32.CreateMask();
            int myBit2 = BitVector32.CreateMask(myBit1);
            int myBit3 = BitVector32.CreateMask(myBit2);

            if (dout1.Checked)
            {
                d[myBit1] = true;
            }
            else
            {
                d[myBit1] = false;
            }
            if (dout2.Checked)
            {
                d[myBit2] = true;
            }
            else
            {
                d[myBit2] = false;
            }
            if (dout3.Checked)
            {
                d[myBit3] = true;
            }
            else
            {
                d[myBit3] = false;
            }
            dd = d.Data;
            i  = Convert.ToChar(dd);
            //MessageBox.Show( "result:"  + Convert.ToString(dd) + " = " + i);
            try
            {
                serialPort1.WriteLine("!0SO" + i); // set digital states
            }
            catch (Exception ex)
            {
                responsebox.Text = "error";
                RunBox.Checked   = false;
                timer1.Stop();
                failstop = true;
                MessageBox.Show("Set DOUT: " + ex.Message);
            }
        }
        static void Main(string[] args)
        {
            GlobalVar.M = 5;    //int.Parse(args[0]);
            GlobalVar.N = 5;    //int.Parse(args[1]);
            int fileNumber = 0; //int.Parse(args[2]);

            GlobalVar.maskArray    = new int[GlobalVar.M * (GlobalVar.N - 1)];
            GlobalVar.maskArray[0] = BitVector32.CreateMask();
            for (int i = 1; i < GlobalVar.M * (GlobalVar.N - 1); i++)
            {
                GlobalVar.maskArray[i] = BitVector32.CreateMask(GlobalVar.maskArray[i - 1]);
            }

            Dictionary <int, Dictionary <int, List <List <int> > > > HEBPiMap = new Dictionary <int, Dictionary <int, List <List <int> > > >();

            using (BinaryReader readFile = new BinaryReader(File.Open("newHEBPiSet_" + GlobalVar.M + ".bin", FileMode.Open)))
            {
                HEBPiMap = hebpMapFromBinaryFile(readFile);
            }


            for (int i = 0; i < GlobalVar.numberOfFiles; i++)
            {
                fileNumber = i;

                using (BinaryReader VEBPFileReader = new BinaryReader(File.Open(GlobalVar.M + "x" + GlobalVar.M + "Files\\" + fileNumber + ".bin", FileMode.Open)))
                {
                    using (BinaryWriter EBPFileWriter = new BinaryWriter(File.Open(GlobalVar.M + "x" + GlobalVar.M + "FilesOUT\\" + fileNumber + "_OUT.bin", FileMode.Create)))
                    {
                        long length = VEBPFileReader.BaseStream.Length;
                        while (VEBPFileReader.BaseStream.Position != length)
                        {
                            try
                            {
                                int VEBPInt = Convert.ToInt32(VEBPFileReader.ReadUInt32());
                                HEBPEnumeration(VEBPInt, ref HEBPiMap, EBPFileWriter);
                            }
                            catch (System.OverflowException)
                            {
                                Console.WriteLine("Overflow in uint-to-int conversion.");
                            }
                        }
                    }
                }
            }
            Console.WriteLine("number of EBPs: " + GlobalVar.numbOfElements);
            Console.WriteLine("press enter key to finish...");
            Console.ReadKey();
        }
Esempio n. 10
0
        public object[] GetArguments(ProcedureSignature procedure, IList <Argument> arguments)
        {
            // Get list of supplied argument values and whether they were set
            var numParameters  = procedure.Parameters.Count;
            var argumentValues = new object [numParameters];
            var argumentSet    = new BitVector32(0);

            foreach (var argument in arguments)
            {
                argumentValues [argument.Position]        = argument.Value;
                argumentSet [1 << (int)argument.Position] = true;
            }

            var mask = BitVector32.CreateMask();

            for (int i = 0; i < numParameters; i++)
            {
                var value     = argumentValues [i];
                var parameter = procedure.Parameters [i];
                var type      = parameter.Type;
                if (!argumentSet [mask])
                {
                    // If the argument is not set, set it to the default value
                    if (!parameter.HasDefaultValue)
                    {
                        throw new RPCException(procedure, "Argument not specified for parameter " + parameter.Name + " in " + procedure.FullyQualifiedName + ". ");
                    }
                    argumentValues [i] = parameter.DefaultValue;
                }
                else if (value != null && !type.IsInstanceOfType(value))
                {
                    // Check the type of the non-null argument value
                    throw new RPCException(
                              procedure,
                              "Incorrect argument type for parameter " + parameter.Name + " in " + procedure.FullyQualifiedName + ". " +
                              "Expected an argument of type " + type + ", got " + value.GetType());
                }
                else if (value == null && !TypeUtils.IsAClassType(type))
                {
                    // Check the type of the null argument value
                    throw new RPCException(
                              procedure,
                              "Incorrect argument type for parameter " + parameter.Name + " in " + procedure.FullyQualifiedName + ". " +
                              "Expected an argument of type " + type + ", got null");
                }
                mask = BitVector32.CreateMask(mask);
            }
            return(argumentValues);
        }
Esempio n. 11
0
    // While fixing the above failures, this test (from corefx) failed.
    public static void Set_Mask_AllTest()
    {
        BitVector32 flip = new BitVector32();
        int         mask = 0;

        for (int bit = 1; bit < 32 + 1; bit++)
        {
            mask = BitVector32.CreateMask(mask);
            BitVector32 single = new BitVector32();
            single[mask] = true;

            // The bug was exposed by passing the result of a shift in RCX on x64/ux.
            CheckValue(1 << (bit - 1), single.Data);
        }
    }
 static ActiveXHelper()
 {
     ActiveXHelper.SinkAttached               = BitVector32.CreateMask();
     ActiveXHelper.ManualUpdate               = BitVector32.CreateMask(ActiveXHelper.SinkAttached);
     ActiveXHelper.SetClientSiteFirst         = BitVector32.CreateMask(ActiveXHelper.ManualUpdate);
     ActiveXHelper.AddedSelectionHandler      = BitVector32.CreateMask(ActiveXHelper.SetClientSiteFirst);
     ActiveXHelper.SiteProcessedInputKey      = BitVector32.CreateMask(ActiveXHelper.AddedSelectionHandler);
     ActiveXHelper.InTransition               = BitVector32.CreateMask(ActiveXHelper.SiteProcessedInputKey);
     ActiveXHelper.ProcessingKeyUp            = BitVector32.CreateMask(ActiveXHelper.InTransition);
     ActiveXHelper.IsMaskEdit                 = BitVector32.CreateMask(ActiveXHelper.ProcessingKeyUp);
     ActiveXHelper.RecomputeContainingControl = BitVector32.CreateMask(ActiveXHelper.IsMaskEdit);
     ActiveXHelper.logPixelsX                 = -1;
     ActiveXHelper.logPixelsY                 = -1;
     ActiveXHelper.REGMSG_MSG                 = SafeNativeMethods.RegisterWindowMessage(ApplicationShim.WindowMessagesVersion + "_subclassCheck");
 }
Esempio n. 13
0
        static void Main(string[] args)
        {
            BitVector32 bv = new BitVector32(0);   // all flags set to false

            // create masks to isolate each of the first five bit flags
            int myBit1 = BitVector32.CreateMask(0);
            int myBit2 = BitVector32.CreateMask(myBit1);
            int myBit3 = BitVector32.CreateMask(myBit2);
            int myBit4 = BitVector32.CreateMask(myBit3);
            int myBit5 = BitVector32.CreateMask(myBit4);

            Console.WriteLine(bv.ToString());    // ToString() shows bit pattern

            // set alternating bits to true
            bv[myBit1] = true;
            bv[myBit3] = true;
            bv[myBit5] = true;

            Console.WriteLine(bv.ToString());

            BitVector32 bv2 = new BitVector32(255);   // all flags set to binary representation of 255

            Console.WriteLine(bv2.ToString());

            BitVector32 bv3 = new BitVector32(0);   // all flags set to false

            // create sections with max values 6,3,1 and 12
            BitVector32.Section mySect1 = BitVector32.CreateSection(6);
            BitVector32.Section mySect2 = BitVector32.CreateSection(3, mySect1);
            BitVector32.Section mySect3 = BitVector32.CreateSection(1, mySect2);
            BitVector32.Section mySect4 = BitVector32.CreateSection(12, mySect3);

            Console.WriteLine("mySect1 - offset:{0}, mask:{1}", mySect1.Offset, Convert.ToString(mySect1.Mask, 2));
            Console.WriteLine("mySect2 - offset:{0}, mask:{1}", mySect2.Offset, Convert.ToString(mySect2.Mask, 2));
            Console.WriteLine("mySect3 - offset:{0}, mask:{1}", mySect3.Offset, Convert.ToString(mySect3.Mask, 2));
            Console.WriteLine("mySect4 - offset:{0}, mask:{1}", mySect4.Offset, Convert.ToString(mySect4.Mask, 2));

            bv3[mySect1] = 5;
            bv3[mySect2] = 3;
            bv3[mySect3] = 1;
            bv3[mySect4] = 9;

            Console.WriteLine(bv3.ToString());

            int bv3Data = bv3.Data;

            Console.WriteLine("value of bv3: {0}", bv3Data);
        }
Esempio n. 14
0
        static FilterSet()
        {
            var builder      = ImmutableDictionary.CreateBuilder <string, FilterWithMask>();
            var previousMask = 0;

            NamespaceFilter         = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Namespaces, 'n', WellKnownTags.Namespace);
            ClassFilter             = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Classes, 'c', WellKnownTags.Class);
            ModuleFilter            = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Modules, 'u', WellKnownTags.Module);
            StructureFilter         = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Structures, 's', WellKnownTags.Structure);
            InterfaceFilter         = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Interfaces, 'i', WellKnownTags.Interface);
            EnumFilter              = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Enums, 'e', WellKnownTags.Enum);
            DelegateFilter          = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Delegates, 'd', WellKnownTags.Delegate);
            ConstantFilter          = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Constants, 'o', WellKnownTags.Constant);
            FieldFilter             = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Fields, 'f', WellKnownTags.Field);
            EventFilter             = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Events, 'v', WellKnownTags.Event);
            PropertyFilter          = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Properties, 'p', WellKnownTags.Property);
            MethodFilter            = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Methods, 'm', WellKnownTags.Method);
            ExtensionMethodFilter   = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Extension_methods, 'x', WellKnownTags.ExtensionMethod);
            LocalAndParameterFilter = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Locals_and_parameters, 'l', WellKnownTags.Local, WellKnownTags.Parameter);
            KeywordFilter           = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Keywords, 'k', WellKnownTags.Keyword);
            SnippetFilter           = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Snippets, 't', WellKnownTags.Snippet);
            TargetTypedFilter       = CreateCompletionFilterAndAddToBuilder(FeaturesResources.Target_type_matches, 'j', WellKnownTags.TargetTypeMatch);

            s_filterMap = builder.ToImmutable();

            s_expanderMask = BitVector32.CreateMask(previousMask);

            var addImageId = Shared.Extensions.GlyphExtensions.GetImageCatalogImageId(KnownImageIds.ExpandScope);

            Expander = new CompletionExpander(
                EditorFeaturesResources.Expander_display_text,
                accessKey: "a",
                new ImageElement(addImageId, EditorFeaturesResources.Expander_image_element));

            CompletionFilter CreateCompletionFilterAndAddToBuilder(string displayText, char accessKey, params string[] tags)
            {
                var filter = CreateCompletionFilter(displayText, tags, accessKey);

                previousMask = BitVector32.CreateMask(previousMask);

                foreach (var tag in tags)
                {
                    builder.Add(tag, new FilterWithMask(filter, previousMask));
                }

                return(filter);
            }
        }
Esempio n. 15
0
            public void CreateMask()
            {
                Assert.AreEqual(1, BitVector32.CreateMask());
                Assert.AreEqual(1, BitVector32.CreateMask(0));
                Assert.AreEqual(2, BitVector32.CreateMask(1));
                Assert.AreEqual(32, BitVector32.CreateMask(16));
                var overflow = -2;

                Assert.AreEqual((uint)overflow, BitVector32.CreateMask(int.MaxValue));
                // ReSharper disable once ConvertToConstant.Local
                var overflow2 = -4;

                Assert.AreEqual((uint)overflow2, BitVector32.CreateMask((uint)overflow));
                // ReSharper disable once ConvertToConstant.Local
                overflow = int.MinValue + 1;
                Assert.AreEqual(2, BitVector32.CreateMask((uint)overflow));
            }
Esempio n. 16
0
        static void Main()
        {
            // create a mask using the CreateMask method
            var bits1 = new BitVector32();
            int bit1  = BitVector32.CreateMask();
            int bit2  = BitVector32.CreateMask(bit1);
            int bit3  = BitVector32.CreateMask(bit2);
            int bit4  = BitVector32.CreateMask(bit3);
            int bit5  = BitVector32.CreateMask(bit4);

            bits1[bit1] = true;
            bits1[bit2] = false;
            bits1[bit3] = true;
            bits1[bit4] = true;
            bits1[bit5] = true;
            WriteLine(bits1);

            // create a mask using an indexer
            bits1[0xabcdef] = true;
            WriteLine(bits1);

            int received = 0x79abcdef;

            BitVector32 bits2 = new BitVector32(received);

            WriteLine(bits2);

            // sections: FF EEE DDD CCCC BBBBBBBB
            // AAAAAAAAAAAA
            BitVector32.Section sectionA = BitVector32.CreateSection(0xfff);
            BitVector32.Section sectionB = BitVector32.CreateSection(0xff, sectionA);
            BitVector32.Section sectionC = BitVector32.CreateSection(0xf, sectionB);
            BitVector32.Section sectionD = BitVector32.CreateSection(0x7, sectionC);
            BitVector32.Section sectionE = BitVector32.CreateSection(0x7, sectionD);
            BitVector32.Section sectionF = BitVector32.CreateSection(0x3, sectionE);

            WriteLine($"Section A: {IntToBinaryString(bits2[sectionA], true)}");
            WriteLine($"Section B: {IntToBinaryString(bits2[sectionB], true)}");
            WriteLine($"Section C: {IntToBinaryString(bits2[sectionC], true)}");
            WriteLine($"Section D: {IntToBinaryString(bits2[sectionD], true)}");
            WriteLine($"Section E: {IntToBinaryString(bits2[sectionE], true)}");
            WriteLine($"Section F: {IntToBinaryString(bits2[sectionF], true)}");


            ReadLine();
        }
Esempio n. 17
0
        public void BitVector32Test()
        {
            var bv1 = new BitVector32();

            //CreateMask为参数时默认返回1,有参数时返回参数左移一位后的结果
            //用于创建访问特定位的掩码
            var bit1 = BitVector32.CreateMask();
            var bit2 = BitVector32.CreateMask(bit1);
            var bit3 = BitVector32.CreateMask(bit2);
            var bit4 = BitVector32.CreateMask(bit3);
            var bit5 = BitVector32.CreateMask(bit4);

            //[]中的参数为掩码,
            //若等于true则将掩码和bv中32位二进制进行或操作
            //若等于false则将掩码和bv中32位二进制进行与操作
            bv1[bit1] = true;
            bv1[bit2] = false;
            bv1[bit3] = true;
            bv1[bit4] = true;
            bv1[bit5] = true;

            //将 0000 0000 0000 0000 0001 1101 和 1010 1011 1100 1101 1110 1111进行或操作
            bv1[0xabcdef] = true;
            Console.WriteLine(bv1);

            var received = 0x79abcdef;
            var bv2      = new BitVector32(received);

            Console.WriteLine(bv2);

            //CreateSection用于创建
            var sectionA = BitVector32.CreateSection(0xfff);
            var sectionB = BitVector32.CreateSection(0xff, sectionA);
            var sectionC = BitVector32.CreateSection(0xf, sectionB);
            var sectionD = BitVector32.CreateSection(0x7, sectionC);
            var sectionE = BitVector32.CreateSection(0x7, sectionD);
            var sectionF = BitVector32.CreateSection(0x3, sectionE);

            Console.WriteLine($"SectionA:{IntToBinaryString(bv2[sectionA])}");
            Console.WriteLine($"SectionB:{IntToBinaryString(bv2[sectionB])}");
            Console.WriteLine($"SectionC:{IntToBinaryString(bv2[sectionC])}");
            Console.WriteLine($"SectionD:{IntToBinaryString(bv2[sectionD])}");
            Console.WriteLine($"SectionE:{IntToBinaryString(bv2[sectionE])}");
            Console.WriteLine($"SectionF:{IntToBinaryString(bv2[sectionF])}");
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            int bit1 = BitVector32.CreateMask();
            int bit2 = BitVector32.CreateMask(bit1);
            int bit3 = BitVector32.CreateMask(bit2);
            int bit4 = BitVector32.CreateMask(bit3);
            int bit5 = BitVector32.CreateMask(bit4);

            Console.WriteLine(bit1);
            Console.WriteLine(bit2);
            Console.WriteLine(bit3);
            Console.WriteLine(bit4);
            Console.WriteLine(bit5);

            Console.WriteLine(BitVector32.CreateMask(64));

            Console.ReadKey();
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            var bita1 = new BitVector32();
            int bit1  = BitVector32.CreateMask();
            int bit2  = BitVector32.CreateMask(bit1);
            int bit3  = BitVector32.CreateMask(bit2);
            int bit4  = BitVector32.CreateMask(bit3);
            int bit5  = BitVector32.CreateMask(bit4);

            bita1[bit1] = true;
            bita1[bit2] = false;
            bita1[bit3] = true;
            bita1[bit4] = true;
            bita1[bit5] = true;
            Console.WriteLine(bita1);
            bita1[0xabcdef] = true;
            Console.WriteLine(bita1);
            Console.ReadKey();
        }
Esempio n. 20
0
        public TownRegion()
        {
            //
            // TODO: Add constructor logic here
            //
            race                  = 0;
            weather               = 255;
            midiList              = 0;
            mayorSerial           = 0xFFFFFFFF;
            taxedResource         = 0x0EED;
            taxedAmount           = 0;
            goldReserved          = 0;
            guardsPurchased       = 0;
            resourceCollected     = 0;
            visualAppearance      = WorldType.Spring;
            health                = 30000;
            timeToElectionClose   = 0;
            timeToNextPoll        = 0;
            timeSinceGuardsPaid   = 0;
            timeSinceTaxedMembers = 0;
            worldNumber           = 0;
            jsScript              = 0xFFFF;
            chanceFindBigOre      = 0;
            numGuards             = 10;

            priv        = new System.Collections.Specialized.BitVector32(0);
            bitMasks[0] = BitVector32.CreateMask();
            for (int i = 1; i < 8; ++i)
            {
                bitMasks[i] = BitVector32.CreateMask(bitMasks[i - 1]);
            }

            guards         = new ArrayList();                                           // array of strings
            orePreferences = new ArrayList();                                           // array of orePref
            townMember     = new ArrayList();                                           // array of townPers
            alliedTowns    = new ArrayList();                                           // array of byte
            locations      = new ArrayList();                                           // array of locations
            goodList       = new Hashtable();                                           // map of SI32, GoodData_st

            name       = "the Wilderness";
            guardList  = "guard";
            guardowner = "the Gods themselves";
        }
Esempio n. 21
0
        static void Main()
        {
            // create a mask using the CreateMask method
            var bits1 = new BitVector32();
            int bit1  = BitVector32.CreateMask();
            int bit2  = BitVector32.CreateMask(bit1);
            int bit3  = BitVector32.CreateMask(bit2);
            int bit4  = BitVector32.CreateMask(bit3);
            int bit5  = BitVector32.CreateMask(bit4);

            bits1[bit1] = true;
            bits1[bit2] = false;
            bits1[bit3] = true;
            bits1[bit4] = true;
            bits1[bit5] = true;
            Console.WriteLine(bits1);

            // create a mask using an indexer
            bits1[0xab_cdef] = true;
Esempio n. 22
0
    public digital_data(int din)
    {
        BitVector32 digitalout_b = new BitVector32(din);
        // Creates masks to isolate each of the first 6 bit flags.
        int myBit1 = BitVector32.CreateMask();
        int myBit2 = BitVector32.CreateMask(myBit1);
        int myBit3 = BitVector32.CreateMask(myBit2);
        int myBit4 = BitVector32.CreateMask(myBit3);
        int myBit5 = BitVector32.CreateMask(myBit4);
        int myBit6 = BitVector32.CreateMask(myBit5);

        //digitalout_b = din;
        dout1 = digitalout_b[myBit1];
        dout2 = digitalout_b[myBit2];
        dout3 = digitalout_b[myBit3];
        din1  = digitalout_b[myBit4];
        din2  = digitalout_b[myBit5];
        din3  = digitalout_b[myBit6];
    }
Esempio n. 23
0
        public static void Run()
        {
            //使用默认构造函数创建一个BitVactor32结构,默认每一位都是false。
            var bits1 = new BitVector32();
            //调用CreateMask()方法创建用来访问第一位的一个掩码,bit1被设置为1
            int bit1 = BitVector32.CreateMask();
            //再次调用CreateMask()方法,并将一个掩码作为参数进行传递,返回第二位掩码
            int bit2 = BitVector32.CreateMask(bit1);
            int bit3 = BitVector32.CreateMask(bit2);
            int bit4 = BitVector32.CreateMask(bit3);
            int bit5 = BitVector32.CreateMask(bit4);

            //使用掩码和索引器访问位矢量中的位,并设置值
            bits1[bit1] = true;
            bits1[bit2] = false;
            bits1[bit3] = true;
            bits1[bit4] = true;
            bits1[bit5] = true;
            Console.WriteLine(bits1);
            bits1[0xabcdef] = true;
            Console.WriteLine(bits1);

            int received = 0x79abcdef;
            //直接传入十六进制数来创建掩码
            BitVector32 bits2 = new BitVector32(received);

            Console.WriteLine(bits2);

            //分割片段
            BitVector32.Section sectionA = BitVector32.CreateSection(0xfff);
            BitVector32.Section sectionB = BitVector32.CreateSection(0xff, sectionA);
            BitVector32.Section sectionC = BitVector32.CreateSection(0xf, sectionB);
            BitVector32.Section sectionD = BitVector32.CreateSection(0x7, sectionC);
            BitVector32.Section sectionE = BitVector32.CreateSection(0x7, sectionD);
            BitVector32.Section sectionF = BitVector32.CreateSection(0x3, sectionE);
            Console.WriteLine("Section A:" + IntToBinaryString(bits2[sectionA], true));
            Console.WriteLine("Section B:" + IntToBinaryString(bits2[sectionB], true));
            Console.WriteLine("Section C:" + IntToBinaryString(bits2[sectionC], true));
            Console.WriteLine("Section D:" + IntToBinaryString(bits2[sectionD], true));
            Console.WriteLine("Section E:" + IntToBinaryString(bits2[sectionE], true));
            Console.WriteLine("Section F:" + IntToBinaryString(bits2[sectionF], true));
        }
Esempio n. 24
0
        public static void Set_Mask_UnsetAllTest()
        {
            BitVector32 flip = new BitVector32(-1);
            int         mask = 0;

            for (int bit = 1; bit < 32 + 1; bit++)
            {
                mask = BitVector32.CreateMask(mask);

                BitVector32 single = new BitVector32(1 << (bit - 1));
                Assert.True(single[mask]);
                single[mask] = false;
                Assert.False(single[mask]);
                Assert.Equal(0, single.Data);

                flip[mask] = false;
            }
            Assert.Equal(0, flip.Data);
            Assert.Equal(int.MinValue, mask);
        }
Esempio n. 25
0
        static void BitVectorDemo()
        {
            var bits1 = new BitVector32();
            int bit1  = BitVector32.CreateMask();
            int bit2  = BitVector32.CreateMask(bit1);
            int bit3  = BitVector32.CreateMask(bit2);
            int bit4  = BitVector32.CreateMask(bit3);
            int bit5  = BitVector32.CreateMask(bit4);

            bits1[bit1] = true;
            bits1[bit2] = false;
            bits1[bit3] = true;
            bits1[bit4] = true;
            Console.WriteLine(bits1);

            bits1[0xabcdef] = true;
            Console.WriteLine(bits1);


            int received = 0x79abcdef;

            var bits2 = new BitVector32(received);

            Console.WriteLine(bits2);
            // sections: FF EEE DDD CCCC BBBBBBBB AAAAAAAAAAAA
            BitVector32.Section sectionA = BitVector32.CreateSection(0xfff);
            BitVector32.Section sectionB = BitVector32.CreateSection(0xff, sectionA);
            BitVector32.Section sectionC = BitVector32.CreateSection(0xf, sectionB);
            BitVector32.Section sectionD = BitVector32.CreateSection(0x7, sectionC);
            BitVector32.Section sectionE = BitVector32.CreateSection(0x7, sectionD);
            BitVector32.Section sectionF = BitVector32.CreateSection(0x3, sectionE);



            Console.WriteLine("Section A: " + IntToBinaryString(bits2[sectionA], true));
            Console.WriteLine("Section B: " + IntToBinaryString(bits2[sectionB], true));
            Console.WriteLine("Section C: " + IntToBinaryString(bits2[sectionC], true));
            Console.WriteLine("Section D: " + IntToBinaryString(bits2[sectionD], true));
            Console.WriteLine("Section E: " + IntToBinaryString(bits2[sectionE], true));
            Console.WriteLine("Section F: " + IntToBinaryString(bits2[sectionF], true));
        }
Esempio n. 26
0
        static void Main(string[] args)
        {
            BitVector32 vector1 = new BitVector32(0);

            // Маски для первых пяти битов
            int bit1 = BitVector32.CreateMask();
            int bit2 = BitVector32.CreateMask(bit1);
            int bit3 = BitVector32.CreateMask(bit2);
            int bit4 = BitVector32.CreateMask(bit3);
            int bit5 = BitVector32.CreateMask(bit4);

            // Получаем BitVector32{00000000000000000000000000000000}
            Console.WriteLine(vector1.ToString());
            vector1[bit1] = true;             // установить 1 бит
            // Получаем BitVector32{00000000000000000000000000000001}
            Console.WriteLine(vector1.ToString());
            vector1[bit3] = true;             // установить 3 бит
            // Получаем BitVector32{00000000000000000000000000000101}
            Console.WriteLine(vector1.ToString());
            vector1[bit5] = true;             // установить 5 бит
            // Получаем BitVector32{00000000000000000000000000010101}
            Console.WriteLine(vector1.ToString());

            BitVector32 vector2 = new BitVector32(0);

            // Создаем 4 секции. Первая имеет максимум значений 6, т.е занимает 4 бита.
            // Вторая - максимум 3 (т.е. два бита), затем 1 бит, затем 4 бита.
            BitVector32.Section sect1 = BitVector32.CreateSection(6);
            BitVector32.Section sect2 = BitVector32.CreateSection(3, sect1);
            BitVector32.Section sect3 = BitVector32.CreateSection(1, sect2);
            BitVector32.Section sect4 = BitVector32.CreateSection(15, sect3);

            vector2[sect2] = 3;
            // Получим BitVector32{00000000000000000000000000011000}
            Console.WriteLine(vector2.ToString());
            vector2[sect4] = 1;
            // Получим BitVector32{00000000000000000000000001011000}
            Console.WriteLine(vector2.ToString());

            Console.ReadLine();
        }
Esempio n. 27
0
    public static void Main()
    {
        // Creates and initializes a BitVector32 with all bit flags set to FALSE.
        BitVector32 myBV = new BitVector32(0);

        // Creates masks to isolate each of the first five bit flags.
        int myBit1 = BitVector32.CreateMask();
        int myBit2 = BitVector32.CreateMask(myBit1);
        int myBit3 = BitVector32.CreateMask(myBit2);
        int myBit4 = BitVector32.CreateMask(myBit3);
        int myBit5 = BitVector32.CreateMask(myBit4);

        // Sets the alternating bits to TRUE.
        Console.WriteLine("Setting alternating bits to TRUE:");
        Console.WriteLine("   Initial:         {0}", myBV.ToString());
        myBV[myBit1] = true;
        Console.WriteLine("   myBit1 = TRUE:   {0}", myBV.ToString());
        myBV[myBit3] = true;
        Console.WriteLine("   myBit3 = TRUE:   {0}", myBV.ToString());
        myBV[myBit5] = true;
        Console.WriteLine("   myBit5 = TRUE:   {0}", myBV.ToString());
    }
Esempio n. 28
0
        public static void Main()
        {
            var bits1 = new BitVector32();

            //bits1[0xabcdef] = true;
            Console.WriteLine(bits1);

            int bit1 = BitVector32.CreateMask();
            int bit2 = BitVector32.CreateMask(bit1);
            int bit3 = BitVector32.CreateMask(bit2);
            int bit4 = BitVector32.CreateMask(bit3);

            BitVector32.Section bTemp = BitVector32.CreateSection(0xf);  //这里用于占位
            BitVector32.Section bit5  = BitVector32.CreateSection(0xf, bTemp);

            bits1[bit1]  = true;
            bits1[bit2]  = false;
            bits1[bit3]  = true;
            bits1[bit4]  = true;
            bits1[0xF00] = true;

            Console.WriteLine(bits1);
        }
Esempio n. 29
0
            static DCB()
            {
                // Create Boolean Mask
                int previousMask;

                fBinary           = BitVector32.CreateMask();
                fParity           = BitVector32.CreateMask(fBinary);
                fOutxCtsFlow      = BitVector32.CreateMask(fParity);
                fOutxDsrFlow      = BitVector32.CreateMask(fOutxCtsFlow);
                previousMask      = BitVector32.CreateMask(fOutxDsrFlow);
                previousMask      = BitVector32.CreateMask(previousMask);
                fDsrSensitivity   = BitVector32.CreateMask(previousMask);
                fTXContinueOnXoff = BitVector32.CreateMask(fDsrSensitivity);
                fOutX             = BitVector32.CreateMask(fTXContinueOnXoff);
                fInX          = BitVector32.CreateMask(fOutX);
                fErrorChar    = BitVector32.CreateMask(fInX);
                fNull         = BitVector32.CreateMask(fErrorChar);
                previousMask  = BitVector32.CreateMask(fNull);
                previousMask  = BitVector32.CreateMask(previousMask);
                fAbortOnError = BitVector32.CreateMask(previousMask);

                // Create section Mask
                BitVector32.Section previousSection;
                previousSection = BitVector32.CreateSection(1);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                fDtrControl     = BitVector32.CreateSection(2, previousSection);
                previousSection = BitVector32.CreateSection(1, fDtrControl);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                fRtsControl     = BitVector32.CreateSection(3, previousSection);
                previousSection = BitVector32.CreateSection(1, fRtsControl);
            }
Esempio n. 30
0
        public BitVector32Example()
        {
            var vector = new BitVector32(0);

            int firstBit  = BitVector32.CreateMask();          // ... 0000 0001
            int secondBit = BitVector32.CreateMask(firstBit);  // ... 0000 0010
            int thirdBit  = BitVector32.CreateMask(secondBit); // ... 0000 0100

            Console.WriteLine($"{firstBit} {secondBit} {thirdBit}");

            Console.WriteLine(vector.Data);

            var newVector = new BitVector32(4);

            Console.WriteLine(newVector);

            bool bit1 = newVector[firstBit];
            bool bit2 = newVector[secondBit];
            bool bit3 = newVector[thirdBit];

            Console.WriteLine($"{bit1} {bit2} {bit3}");

            Console.ReadLine();
        }