static void Main(string[] args)
        {
            /*
            BitVector32 answers = new BitVector32(-1);
            */
            // 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());

            Console.ReadKey();
        }
 public DesignerHost(DesignSurface surface)
 {
     this._surface = surface;
     this._state = new BitVector32();
     this._designers = new Hashtable();
     this._events = new EventHandlerList();
     DesignSurfaceServiceContainer service = this.GetService(typeof(DesignSurfaceServiceContainer)) as DesignSurfaceServiceContainer;
     if (service != null)
     {
         foreach (Type type in DefaultServices)
         {
             service.AddFixedService(type, this);
         }
     }
     else
     {
         IServiceContainer container2 = this.GetService(typeof(IServiceContainer)) as IServiceContainer;
         if (container2 != null)
         {
             foreach (Type type2 in DefaultServices)
             {
                 container2.AddService(type2, this);
             }
         }
     }
 }
		public void Indexers ()
		{
			BitVector32 b = new BitVector32 (7);
			Assertion.Assert ("#1", b [0]);
			Assertion.Assert ("#2", b [1]);
			Assertion.Assert ("#3", b [2]);
			Assertion.Assert ("#4", b [4]);
			Assertion.Assert ("#5", !b [8]);
			Assertion.Assert ("#6", !b [16]);
			b [8] = true;
			Assertion.Assert ("#7", b [4]);
			Assertion.Assert ("#8", b [8]);
			Assertion.Assert ("#9", !b [16]);
			b [8] = false;
			Assertion.Assert ("#10", b [4]);
			Assertion.Assert ("#11", !b [8]);
			Assertion.Assert ("#12", !b [16]);

			BitVector32.Section s = BitVector32.CreateSection (31);
			s = BitVector32.CreateSection (64, s);
			// Print (s);
			
			// b = new BitVector32 (0x777777);
			BitVector32 b1 = new BitVector32 (0xffff77);
			BitVector32 b2 = new BitVector32 (b1 [s]);
			//Console.WriteLine (b1.ToString ());
			//Console.WriteLine (b2.ToString ());
			Assertion.AssertEquals ("#14", 123, b1 [s]);
			
			// b1 [s] = 15;
			//Console.WriteLine (b1.ToString ());
		}
Beispiel #4
0
        public void Test01()
        {
            BitVector32 bv32;
            BitVector32 bv32Temp;       // extra BitVector32 - for comparison

            // [] BitVector is constructed as expected
            //-----------------------------------------------------------------

            bv32 = new BitVector32();
            if (bv32.Data != 0)
            {
                Assert.False(true, string.Format("Error, Data = {0} after default ctor", bv32.Data));
            }

            string result = bv32.ToString();
            if (result.IndexOf("BitVector32") == -1)
            {  // "BitVector32" is not a part of ToString()
                Assert.False(true, "Error: ToString() doesn't contain \"BitVector32\"");
            }

            bool item = bv32[1];
            if (item)
            {
                Assert.False(true, string.Format("Error: Item(0) returned {0} instead of {1}", item, false));
            }

            bv32Temp = new BitVector32();
            if (!bv32.Equals(bv32Temp))
            {
                Assert.False(true, string.Format("Error: two default vectors are not equal"));
            }
        }
        public Tuple<ushort, double>[] GetAverages(ushort[] data)
        {
            Dictionary<ushort, SensorData> sensors = new Dictionary<ushort, SensorData>();

            foreach (var d in data)
            {
                BitVector32 item = new BitVector32(d);
                BitVector32.Section checksum = BitVector32.CreateSection(1);
                BitVector32.Section sensorData = BitVector32.CreateSection(2067, checksum);
                BitVector32.Section sensorCode = BitVector32.CreateSection(7, sensorData);

                if (ChecksumOK(item[checksum], d >> 1))
                {
                    ushort code = (ushort)item[sensorCode];

                    if(!sensors.ContainsKey(code))
                    {
                        sensors.Add(code, new SensorData {Sum = 0, Count = 0});
                    }
                    sensors[code].Sum += item[sensorData];
                    sensors[code].Count++;
                }
            }
            Tuple<ushort, double>[] result = new Tuple<ushort, double>[sensors.Count];
            int index = 0;
            foreach (var sensor in sensors)
            {
                result[index++] = new Tuple<ushort,double>(sensor.Key, (double)sensor.Value.Sum / sensor.Value.Count);
            }
            return result;
        }
Beispiel #6
0
        public static BitArray AsBitArray(this OBFingerprint fp)
        {
            BitArray b = new BitArray(3);
            BitVector32 v = new BitVector32(3);

            return null;
        }
Beispiel #7
0
		public void Indexers ()
		{
			BitVector32 b = new BitVector32 (7);
			Assert.IsTrue (b [0], "#1");
			Assert.IsTrue (b [1], "#2");
			Assert.IsTrue (b [2], "#3");
			Assert.IsTrue (b [4], "#4");
			Assert.IsTrue (!b [8], "#5");
			Assert.IsTrue (!b [16], "#6");
			b [8] = true;
			Assert.IsTrue (b [4], "#7");
			Assert.IsTrue (b [8], "#8");
			Assert.IsTrue (!b [16], "#9");
			b [8] = false;
			Assert.IsTrue (b [4], "#10");
			Assert.IsTrue (!b [8], "#11");
			Assert.IsTrue (!b [16], "#12");

			BitVector32.Section s = BitVector32.CreateSection (31);
			s = BitVector32.CreateSection (64, s);
			// Print (s);
			
			// b = new BitVector32 (0x777777);
			BitVector32 b1 = new BitVector32 (0xffff77);
			BitVector32 b2 = new BitVector32 (b1 [s]);
			//Console.WriteLine (b1.ToString ());
			//Console.WriteLine (b2.ToString ());
			Assert.AreEqual (123, b1 [s], "#14");
			
			// b1 [s] = 15;
			//Console.WriteLine (b1.ToString ());
		}
 public FrameworkPropertyMetadata(object defaultValue, FrameworkPropertyMetadataOptions options,
                                  PropertyInvalidatedCallback propertyInvalidatedCallback,
                                  GetValueOverride getValueOverride, SetValueOverride setValueOverride)
   : base(defaultValue, propertyInvalidatedCallback, getValueOverride, setValueOverride)
 {
   _options = new BitVector32((int)options);
 }
		public static void Serialize(SerializationWriter writer, Color color)
		{
			BitVector32 flags = new BitVector32();

			if (color.IsKnownColor)
				flags[ColorIsKnown] = true;
			else if (color.IsNamedColor)
				flags[ColorHasName] = true;
			else if (!color.IsEmpty)
			{
				flags[ColorHasValue] = true;
				flags[ColorHasRed] = color.R != 0;
				flags[ColorHasGreen] = color.G != 0;
				flags[ColorHasBlue] = color.B != 0;
				flags[ColorHasAlpha] = color.A != 0;
			}
			writer.WriteOptimized(flags);

			if (color.IsKnownColor)
				writer.WriteOptimized((int) color.ToKnownColor());
			else if (color.IsNamedColor)
				writer.WriteOptimized(color.Name);
			else if (!color.IsEmpty)
			{
				byte component;
				if ( (component = color.R) != 0) writer.Write(component);	
				if ( (component = color.G) != 0) writer.Write(component);	
				if ( (component = color.B) != 0) writer.Write(component);	
				if ( (component = color.A) != 0) writer.Write(component);	
			}
		}
Beispiel #10
0
 public Mask(Layer layer, Rectangle rect, byte color, BitVector32 flags)
 {
     Layer = layer;
     Rect = rect;
     BackgroundColor = color;
     this.flags = flags;
 }
Beispiel #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Mask"/> class.
        /// </summary>
        /// <param name="reader">The reader to use to initialize the instance.</param>
        /// <param name="layer">The layer this mask belongs to.</param>
        internal Mask(BinaryReverseReader reader, Layer layer)
        {
            Layer = layer;
            uint num1 = reader.ReadUInt32();
            if (num1 <= 0U)
            {
                return;
            }

            long position = reader.BaseStream.Position;
            rect = new Rect();
            rect.y = reader.ReadInt32();
            rect.x = reader.ReadInt32();
            rect.height = reader.ReadInt32() - rect.y;
            rect.width = reader.ReadInt32() - rect.x;
            DefaultColor = reader.ReadByte();
            flags = new BitVector32(reader.ReadByte());
            if ((int)num1 == 36)
            {
                reader.ReadByte();  // bit vector
                reader.ReadByte();  // ???
                reader.ReadInt32(); // rect Y
                reader.ReadInt32(); // rect X
                reader.ReadInt32(); // rect total height (actual height = this - Y)
                reader.ReadInt32(); // rect total width (actual width = this - Y)
            }

            reader.BaseStream.Position = position + num1;
        }
 public VectorByte(params bool[] flags)
 {
     bitVector = new BitVector32();
     for (byte i = 0; i < Math.Min(flags.Length, 8); i++)
     {
         bitVector[i] = flags[i];
     }
 }
Beispiel #13
0
 //BitVector32Test
 public static void BitVector32Test()
 {
     var bits = new BitVector32();
     int bit1 = BitVector32.CreateMask();
     int bit2 = BitVector32.CreateMask(bit1);
     int bit3 = BitVector32.CreateMask(bit2);
     bits[3] = true;
     Console.WriteLine(bits);
 }
Beispiel #14
0
 public ProjectItem(string caption)
 {
     if ((caption == null) || (caption.Length == 0))
     {
         throw new ArgumentNullException("caption");
     }
     this._caption = caption;
     this._state = new BitVector32(0);
 }
Beispiel #15
0
 internal CommCapabilities()
 {
     this.wPacketLength = (ushort) Marshal.SizeOf(this);
     this.dwProvSpec1 = CPS.COMMPROP_INITIALIZED;
     this.dwProvCapabilities = new BitVector32(0);
     this.dwSettableParams = new BitVector32(0);
     this.dwSettableBaud = new BitVector32(0);
     this.dwSettableStopParityData = new BitVector32(0);
 }
Beispiel #16
0
 public DCB()
 {
     this.DCBlength = (uint) Marshal.SizeOf(this);
     this.Control = new BitVector32(0);
     this.sect1 = BitVector32.CreateSection(15);
     this.DTRsect = BitVector32.CreateSection(3, this.sect1);
     this.sect2 = BitVector32.CreateSection(0x3f, this.DTRsect);
     this.RTSsect = BitVector32.CreateSection(3, this.sect2);
 }
 public FilteredStatusAppender(IStatusAppender baseAppender, bool appendErrors, bool appendWarnings, bool appendInfos)
     : base(baseAppender)
 {
     flags = new BitVector32();
     flags[APPEND_WARNINGS] = appendWarnings;
     flags[APPEND_ERRORS] = appendErrors;
     flags[APPEND_INFOS] = appendInfos;
     this.baseAppender = baseAppender;
 }
        void UpdatePercentage(ProgressInfo rpProgress, BitVector32 rpBits)
        {
            var rPercent = 0.0;
            rPercent += Math.Min(rpBits[r_Sections[0]] / (double)36, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[1]] / (double)6, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[2]] / (double)24, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[3]] / (double)12, 1.0);

            rpProgress.Percentage = rPercent;
        }
        public int CalculateState(short price, short sellPoint)
        {
            if (price < 0)
                throw new ArgumentOutOfRangeException("price");

            var bitVector = new BitVector32(0);
            bitVector[_priceSection] = price;
            bitVector[_sellPointSection] = sellPoint;
            return bitVector.Data;
        }
Beispiel #20
0
 private void OneBits()
 {
     for (int row = 0; row < 9; row++)
     {
         for (int col = 0; col < 9; col++)
         {
             bGrid[row][col] = new BitVector32(0x1ff);
         }
     }
 }
Beispiel #21
0
		///<summary></summary>
		public Interval(int combinedValue) {
			BitVector32 bitVector=new BitVector32(combinedValue);
			BitVector32.Section sectionDays=BitVector32.CreateSection(255);
			BitVector32.Section sectionWeeks=BitVector32.CreateSection(255,sectionDays);
			BitVector32.Section sectionMonths=BitVector32.CreateSection(255,sectionWeeks);
			BitVector32.Section sectionYears=BitVector32.CreateSection(255,sectionMonths);
			Days=bitVector[sectionDays];
			Weeks=bitVector[sectionWeeks];
			Months=bitVector[sectionMonths];
			Years=bitVector[sectionYears];
		}
Beispiel #22
0
 public Explorer(SudokerGrid grid)
 {
     sGrid = grid;
     iGrid = grid.Items;
     bGrid = new BitVector32[9][];
     for (int row = 0; row < 9; row++)
     {
         bGrid[row] = new BitVector32[9];
     }
     OneBits();
 }
 public ListViewItem()
 {
     this.position = new Point(-1, -1);
     this.lastIndex = -1;
     this.ID = -1;
     this.state = new BitVector32();
     this.toolTipText = string.Empty;
     this.StateSelected = false;
     this.UseItemStyleForSubItems = true;
     this.SavedStateImageIndex = -1;
 }
        internal void UpdatePercentage(ProgressInfo rpProgress, BitVector32 rpBits)
        {
            var rPercent = .0;

            rPercent += Math.Min(rpBits[r_Sections[0]] / 36.0, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[1]] / 6.0, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[2]] / 24.0, 1.0);
            rPercent += Math.Min(rpBits[r_Sections[3]] / 12.0, 1.0);

            rpProgress.Percentage = rPercent * .25;
        }
 public ToolStripDropDownMenu()
 {
     this.maxItemSize = Size.Empty;
     this.checkRectangle = Rectangle.Empty;
     this.imageRectangle = Rectangle.Empty;
     this.arrowRectangle = Rectangle.Empty;
     this.textRectangle = Rectangle.Empty;
     this.imageMarginBounds = Rectangle.Empty;
     this.tabWidth = -1;
     this.indexOfFirstDisplayedItem = -1;
     this.state = new BitVector32();
 }
 internal ToolStripDropDownMenu(ToolStripItem ownerItem, bool isAutoGenerated) : base(ownerItem, isAutoGenerated)
 {
     this.maxItemSize = Size.Empty;
     this.checkRectangle = Rectangle.Empty;
     this.imageRectangle = Rectangle.Empty;
     this.arrowRectangle = Rectangle.Empty;
     this.textRectangle = Rectangle.Empty;
     this.imageMarginBounds = Rectangle.Empty;
     this.tabWidth = -1;
     this.indexOfFirstDisplayedItem = -1;
     this.state = new BitVector32();
 }
Beispiel #27
0
        public void Test01()
        {
            BitVector32 bv32;
            BitVector32 bv32_1;       // extra BitVector32 - for comparison
            int data = 0;

            // [] two BitVectors that are the same - expected true
            //-----------------------------------------------------------------

            bv32 = new BitVector32();
            bv32_1 = new BitVector32();
            if (!bv32.Equals(bv32_1))
            {
                Assert.False(true, string.Format("Error, two default structs are not equal"));
            }


            // generate random data value
            data = -55;
            System.Random random = new System.Random(data);
            data = random.Next(System.Int32.MinValue, System.Int32.MaxValue);

            bv32 = new BitVector32(data);
            bv32_1 = new BitVector32(data);
            if (!bv32.Equals(bv32_1))
            {
                Assert.False(true, string.Format("Error, two vectores with random data are not equal"));
            }

            if (bv32.Equals(null))
            {
                Assert.False(true, string.Format("Error, vector and null are equal"));
            }

            bv32 = new BitVector32(data);
            if (data < Int32.MaxValue)
                data++;
            else
                data--;
            bv32_1 = new BitVector32(data);
            if (bv32.Equals(bv32_1))
            {
                Assert.False(true, string.Format("Error, two different vectors are equal"));
            }

            bv32 = new BitVector32(data);
            if (bv32.Equals(data))
            {
                Assert.False(true, string.Format("Error, vector and non-vector-object are equal"));
            }
        }
        protected override void Process(ProgressInfo rpProgress, BattleInfo rpBattle, RawBattleResult rpResult)
        {
            var rBits = new BitVector32(rpProgress.Progress);

            if (rpResult.Rank >= BattleRank.S)
                rBits[r_Sections[1]] = Math.Min(rBits[r_Sections[1]] + 1, 6);
            if (rpBattle.IsBossBattle)
                rBits[r_Sections[2]] = Math.Min(rBits[r_Sections[2]] + 1, 24);
            if (rpBattle.IsBossBattle && rpResult.Rank >= BattleRank.B)
                rBits[r_Sections[3]] = Math.Min(rBits[r_Sections[3]] + 1, 12);

            rpProgress.Progress = rBits.Data;
            UpdatePercentage(rpProgress, rBits);
        }
 internal ToolStripPanelRow(System.Windows.Forms.ToolStripPanel parent, bool visible)
 {
     this.bounds = Rectangle.Empty;
     this.state = new BitVector32();
     this.propertyStore = new PropertyStore();
     this.parent = parent;
     this.state[stateVisible] = visible;
     this.state[(stateDisposing | stateLocked) | stateInitialized] = false;
     using (new LayoutTransaction(parent, this, null))
     {
         this.Margin = this.DefaultMargin;
         CommonProperties.SetAutoSize(this, true);
     }
 }
 public ToolStripRendererSwitcher(Control owner)
 {
     this.currentRendererType = typeof(System.Type);
     this.state = new BitVector32();
     this.defaultRenderMode = ToolStripRenderMode.ManagerRenderMode;
     this.state[stateUseDefaultRenderer] = true;
     this.state[stateAttachedRendererChanged] = false;
     owner.Disposed += new EventHandler(this.OnControlDisposed);
     owner.VisibleChanged += new EventHandler(this.OnControlVisibleChanged);
     if (owner.Visible)
     {
         this.OnControlVisibleChanged(owner, EventArgs.Empty);
     }
 }
    //初始化属性
    protected void initAttribute()
    {
        try
        {
            m_strategyName  = serializedObject.FindProperty("dataTransmitStrategyName");
            m_parameter     = serializedObject.FindProperty("dataTransmitStrategyParameter");
            m_observedState = serializedObject.FindProperty("observedState_backup");
            m_clusterView   = serializedObject.FindProperty("_viewInstance");

            parameter    = m_parameter.stringValue;
            strategyName = m_strategyName.stringValue;
            states       = new System.Collections.Specialized.BitVector32(m_observedState.intValue);
            dtsEnum      = name2DtsEnum(strategyName);
        }
        catch (System.NullReferenceException)
        {
            //Debug.LogWarning(e.Message);
        }
    }
    //绘制自定义监控属性功能面板
    protected void DrawAttributeField()
    {
        GUIStyle style = new GUIStyle();

        style.alignment = TextAnchor.MiddleCenter;
        EditorGUILayout.LabelField(new GUIContent("Observed Attributes", FduEditorGUI.getAttributeIcon()), style);
        EditorGUILayout.BeginHorizontal();

        if (Application.isPlaying)
        {
            states = new System.Collections.Specialized.BitVector32(((FduMultiAttributeObserverBase)target).getObservedIntData());
        }

        string [] attrList = getAttributeList();
        if (attrList == null)
        {
            return;
        }
        for (int i = 1; i < attrList.Length; ++i)
        {
            if (!Application.isPlaying)
            {
                states[FduGlobalConfig.BIT_MASK[i]] = EditorGUILayout.Toggle(attrList[i], states[FduGlobalConfig.BIT_MASK[i]]);
            }
            else
            {
                EditorGUILayout.Toggle(attrList[i], states[FduGlobalConfig.BIT_MASK[i]]);
            }

            if (i % 2 == 0)
            {
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
            }
        }
        EditorGUILayout.EndHorizontal();
    }
Beispiel #33
0
 public BitVector32(BitVector32 value)
 {
     throw new NotImplementedException();
 }
Beispiel #34
0
 /// <include file='doc\BitVector32.uex' path='docs/doc[@for="BitVector32.BitVector321"]/*' />
 /// <devdoc>
 /// <para>Initializes a new instance of the BitVector32 structure with the information in the specified
 ///    value.</para>
 /// </devdoc>
 public BitVector32(BitVector32 value)
 {
     this.data = value.data;
 }
Beispiel #35
0
 public override string ToString()
 {
     return(BitVector32.ToString(this));
 }
Beispiel #36
0
 /// <devdoc>
 /// <para>Initializes a new instance of the BitVector32 structure with the information in the specified
 ///    value.</para>
 /// </devdoc>
 public BitVector32(BitVector32 value)
 {
     _data = value._data;
 }
Beispiel #37
0
        public static void Main()
        {
            Cons.WriteLine($"Chapter 10 - Collections...");

            //Play._Time(1);
            //Play._Time(2);

            //Collection Initializers
            var intList = new List <int>()
            {
                1, 2, 3, 4, 5
            };

            //Racers
            Racer GHill = new Racer(2, "Graham", "Hill", "UK", 10);
            Racer DHill = new Racer(7, "Dameon", "Hill", "UK", 14);

            var racers = new List <Racer>(10)
            {
                GHill, DHill
            };

            Cons.WriteLine($"{racers.Count} racers so far.");

            racers.Add(new Racer(24, "Michael", "Schumacher", "Germany", 91));
            racers.Insert(0, new Racer(22, "Ayrton", "Senna", "Brazil", 41));

            //Accessing elements
            var a1 = racers[0];

            Cons.WriteLine("Print list with a foreach loop.........................................");
            foreach (var r in racers)
            {
                Cons.WriteLine(r.ToString("N", null));
            }

            //Delagates again!
            Cons.WriteLine("Now using a delegate.........................................");
            racers.ForEach(Cons.WriteLine);
            Cons.WriteLine("Now using lambda to format.........................................");
            racers.ForEach(r => Cons.WriteLine($"{r:w}"));

            Racer R1 = new Racer(22, "Ayrton", "Senna", "Brazil", 41);

            if (!racers.Remove(R1))
            {
                Cons.WriteLine($"Racer {R1.Id} not found to remove.");
            }

            R1 = DHill;
            if (!racers.Remove(R1))
            {
                Cons.WriteLine($"Racer {DHill.Id} not found to remove.");
            }

            racers.Add(R1);
            //Using Find Predicate
            //int i2 = racers.FindIndex(new FindCountry("Finland").FindCountryPredicate);   This works but has a bugget, not my code!
            int i3 = racers.FindIndex(r => r.Country == "UK"); //Sane as line above and more likely to be used...

            i3 = racers.FindLastIndex(r => r.Country == "UK"); //Sane as line above and more likely to be used...

            var R2       = racers.FindLast(r => r.LastName == "Louder");
            var someWins = racers.FindAll(r => r.Wins < 20);

            someWins.Sort();

            var bigWiners = racers.FindAll(r => r.Wins > 20);

            bigWiners.Sort();

            racers.Sort(new RacerComp(RacerComp.CompareType.LastName));

            racers.Sort(new RacerComp(RacerComp.CompareType.Country));

            //Sort using delagte and Lambda expression.
            racers.Sort((r1, r2) => r2.Wins.CompareTo(r1.Wins));
            racers.Reverse();

            //Type Conversion...
            var rPeople = racers.ConvertAll <Person>(r => new Person(r.FirstName + ',' + r.LastName));

            //Read-Only Collections
            var roRacers = racers.AsReadOnly();

            //Queues
            var dm = new DocsManager();

            ProcessDocs.Start(dm);
            //Create docs and add too dm
            for (int i = 0; i < 100; i++)
            {
                var doc = new Doc("Doc" + i.ToString(), "AID" + new Random().Next(20).ToString());
                dm.AddDoc(doc);
                Console.WriteLine($"Added Document: {doc.Title} by {doc.Auther} to queue.");
                Thread.Sleep(new Random().Next(20));
            }

            Thread.Sleep(2000);
            ProcessDocs.Stop();

            //Stacks Quick one...
            var lets = new Stack <char>();

            lets.Push('A');
            lets.Push('B');
            lets.Push('C');

            foreach (var l in lets)
            {
                Cons.Write(l);
            }
            Cons.WriteLine();

            while (lets.Count > 0)
            {
                Cons.Write(lets.Pop());
            }
            Cons.WriteLine($"Next...");

            //Linked Lists...
            var pDM = new PDocManager();

            pDM.AddPDoc(new PDoc("Adoc", "AAAdams", 4));
            pDM.AddPDoc(new PDoc("Bdoc", "BBabs", 8));
            pDM.AddPDoc(new PDoc("Cdoc", "CCock", 4));
            pDM.AddPDoc(new PDoc("Ddoc", "AAAdams", 8));
            pDM.AddPDoc(new PDoc("Edoc", "CCock", 8));

            pDM.DisplayAllNodes();

            //Simple Sorted List
            var boots = new SortedList <int, string>();

            boots.Add(18, "Knee High");
            boots.Add(27, "Thigh Length");
            boots[12] = "Calfe";
            boots[6]  = "Ankle";

            foreach (var b in boots)
            {
                Cons.WriteLine($"{b.Key}, {b.Value}");
            }

            boots[27] = "Thigh High";

            foreach (var b in boots)
            {
                Cons.WriteLine($"{b.Key}, {b.Value}");
            }

            //What Next....for DCoates
            var employees = new Dictionary <EmployeeId, DicEmployee>();

            var idCat = new EmployeeId("A000001");
            var eCat  = new DicEmployee(idCat, "Cat", 100000.00m);

            employees.Add(idCat, eCat);

            var idAnt = new EmployeeId("A012345");
            var eAnt  = new DicEmployee(idAnt, "Ant", 23000.00m);

            employees.Add(idAnt, eAnt);

            var idBee = new EmployeeId("B000001");
            var eBee  = new DicEmployee(idBee, "Bee", 40000.00m);

            employees.Add(idBee, eBee);

            var idDog = new EmployeeId("A000002");
            var eDog  = new DicEmployee(idDog, "Dog", 10000.00m);

            employees.Add(idDog, eDog);

            foreach (var e in employees)
            {
                Cons.WriteLine(e.ToString());
            }

            while (true)
            {
                Cons.Write("Enter am Empolyee Id: (X to exit)>");
                var uIn = Cons.ReadLine();
                if (uIn.ToLower() == "x")
                {
                    break;
                }

                EmployeeId eId;
                try
                {
                    eId = new EmployeeId(uIn);

                    DicEmployee dEmp;
                    if (!employees.TryGetValue(eId, out dEmp))
                    {
                        Cons.WriteLine($"Employee with {eId} does not exist.");
                    }
                    else
                    {
                        Cons.WriteLine(dEmp);
                    }
                }
                catch (EmployeeIdException ee)
                {
                    Cons.WriteLine(ee.Message);
                }
            }

            //Lookups from System.core
            //Use the racers list from above

            var lookupRacers = racers.ToLookup(r => r.Country);

            foreach (var r in lookupRacers["UK"])
            {
                Cons.WriteLine($"name:{r.LastName}, {r.FirstName}");
            }
            //Nice but not sorted!

            //Sorted Dics....
            //Simple Sorted List
            var sdBoots = new SortedDictionary <int, string> {
                { 18, "Knee High" }, { 27, "Thigh Length" }
            };

            sdBoots[12] = "Calfe";
            sdBoots[6]  = "Ankle";

            foreach (var b in sdBoots)
            {
                Cons.WriteLine($"{b.Key}, {b.Value}");
            }

            //Sets...
            var allTeams = new HashSet <string>()
            {
                "Ferrari", "Lotus", "McLaren", "Honda", "BRM", "Aston Martin", "Red Bull", "Force India", "Sauber", "Williams"
            };
            var coTeams = new HashSet <string>()
            {
                "Ferrari", "Lotus", "McLaren", "Honda"
            };
            var oldTeams = new HashSet <string>()
            {
                "Ferrari", "Lotus", "BRM", "Aston Martin"
            };
            var newTeams = new HashSet <string>()
            {
                "Red Bull", "Force India", "Sauber"
            };

            var res = coTeams.Add("Williams");

            res = coTeams.Add("Williams");

            res = coTeams.IsSubsetOf(allTeams);
            res = allTeams.IsSupersetOf(coTeams);
            res = oldTeams.Overlaps(coTeams);
            res = newTeams.Overlaps(coTeams);

            var allTeams2 = new SortedSet <string>(coTeams);

            allTeams2.UnionWith(oldTeams);
            allTeams2.UnionWith(newTeams);

            res = allTeams2.SetEquals(allTeams);

            var tTeams = new SortedSet <string>(allTeams);

            tTeams.SymmetricExceptWith(oldTeams);
            var yTeams = new SortedSet <string>(allTeams);
            var yI     = new SortedSet <string>(yTeams.Intersect(oldTeams));

            //Observable Collections
            Cons.Clear();
            Cons.WriteLine("Observable Collections....");
            var data = new ObservableCollection <string>();

            data.CollectionChanged += Data_CollectionChanged;
            data.Add("First");
            data.Add("Second");
            data.Insert(1, "Three");
            data.Remove("Three");

            //Bits and bobs....
            Cons.WriteLine("Bits and Bobs....");
            var bitsA = new Col.BitArray(8);

            bitsA.SetAll(true);
            bitsA.Set(1, false);
            DisplayBits(bitsA);

            Cons.WriteLine();
            bitsA.Not();
            DisplayBits(bitsA);

            byte[] aI    = { 22 };
            var    bitsB = new Col.BitArray(aI);

            DisplayBits(bitsB);

            bitsA.Or(bitsB);
            DisplayBits(bitsA);

            //BitVector32 Struct
            var vBits = new Col.Specialized.BitVector32();
            int m1    = BitVector32.CreateMask();
            int m2    = BitVector32.CreateMask(m1);
            int m3    = BitVector32.CreateMask(m2);
            int m4    = BitVector32.CreateMask(m3);
            int m5    = BitVector32.CreateMask(128);

            vBits[m1] = true;
            vBits[m3] = true;
            vBits[m4] = true;
            vBits[m5] = true;

            Cons.WriteLine(vBits);

            int rec      = 0x88abcde;
            var vBitRSet = new BitVector32(rec);

            Cons.WriteLine(vBitRSet);

            //Immutable Collections
            ImmutabeThings.ImmutableTing1();

            Cons.ReadKey();
        }
Beispiel #38
0
 public static string ToString(BitVector32 value)
 {
     throw new NotImplementedException();
 }