public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success) { System.Collections.Queue queue = (System.Collections.Queue)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value; try { queue.TrimToSize(); returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined); success = true; } //catch (KeyNotFoundException) //{ // success = false; // stackframe.throwAneException(token, arraylist.ToString() + "没有链接到脚本"); //} catch (ArgumentException a) { success = false; stackframe.throwAneException(token,a.Message); } catch (IndexOutOfRangeException i) { success = false; stackframe.throwAneException(token,i.Message); } }
static public int TrimToSize(IntPtr l) { try { System.Collections.Queue self = (System.Collections.Queue)checkSelf(l); self.TrimToSize(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static int TrimToSize(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); System.Collections.Queue obj = (System.Collections.Queue)ToLua.CheckObject(L, 1, typeof(System.Collections.Queue)); obj.TrimToSize(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public override void TrimToSize() { lock (root) { _q.TrimToSize(); } }
public void TrimToSize_Enqueue_Dequeue () { Queue queue = new Queue (32, 1.0F); for (int i = 0; i < 31; i++) queue.Enqueue (i); queue.TrimToSize (); queue.Enqueue (411); Assert.AreEqual (32, queue.Count, "Count-1"); Assert.AreEqual (0, queue.Dequeue (), "0"); }
public void TrimToSize_Dequeue_Enqueue () { Queue queue = new Queue (32, 1.0F); for (int i = 0; i < 31; i++) queue.Enqueue (i); queue.TrimToSize (); Assert.AreEqual (0, queue.Dequeue (), "0"); queue.Enqueue (411); Assert.AreEqual (31, queue.Count, "Count-1"); for (int i = 1; i < 31; i++) { Assert.AreEqual (i, queue.Peek (), "Peek" + i.ToString ()); Assert.AreEqual (i, queue.Dequeue (), "Dequeue" + i.ToString ()); } Assert.AreEqual (1, queue.Count, "Count-2"); Assert.AreEqual (411, queue.Dequeue (), "411"); }
public override void TrimToSize() { lock (queue) { queue.TrimToSize(); } }
internal static void SetConfigValue(string key, int itemmax) { XmlDocument xmlDoc = new XmlDocument( ); xmlDoc.Load(Application.ExecutablePath + ".config"); //最多可以保存9个 Queue qu = new Queue(itemmax); foreach (XmlElement xe in xmlDoc.SelectNodes("/configuration/mathWord")) { qu.Enqueue(xe.InnerText); } if (qu.Count > 9) { qu.Dequeue( ); qu.TrimToSize( ); } //去除重复的. if (!qu.Contains(key)) qu.Enqueue(key); XmlNode root = xmlDoc.SelectSingleNode("configuration"); //主要是了保证不重复 root.RemoveAll( ); foreach (string str in qu) { XmlElement xElem = xmlDoc.CreateElement("mathWord"); xElem.InnerText = str; root.AppendChild(xElem); } xmlDoc.Save(Application.ExecutablePath + ".config"); }
private void getContents(string origFileName, string genFileName) { //compare the two files xmlFileRdr = new XmlTextReader(origFileName); origContentsQ = new Queue(); int testNo = 0; //get the contents of the orignal file while (xmlFileRdr.Read()) { switch (xmlFileRdr.NodeType) { case XmlNodeType.Element: { switch (xmlFileRdr.Name) { case "Inject": { testNo++; //information about fault, limit, or test type = Convert.ToInt16(xmlFileRdr.GetAttribute("Type").ToString()); name = xmlFileRdr.GetAttribute("Name").ToString(); enabled = Convert.ToInt16(xmlFileRdr.GetAttribute("Enabled").ToString()); //create a new test case TestCase newCase = new TestCase("", enabled, name, type, testNo); origContentsQ.Enqueue(newCase); break; } case "TestFile": { //start of the test file Console.Out.WriteLine(); Console.Out.WriteLine("Purpose of this test is to [" + xmlFileRdr.GetAttribute("Purpose") + "]"); Console.Out.WriteLine("-----------------------------------------------------------------------"); Console.Out.WriteLine(); break; } } break; } } } xmlFileRdr.Close(); origContentsQ.TrimToSize(); //get the contents of the generated file xmlFileRdr = new XmlTextReader(genFileName); genContentsQ = new Queue(); while (xmlFileRdr.Read()) { switch (xmlFileRdr.NodeType) { case XmlNodeType.Element: { switch (xmlFileRdr.Name) { case "Inject": { testNo++; //information about fault, limit, or test type = Convert.ToInt16(xmlFileRdr.GetAttribute("Type").ToString()); name = xmlFileRdr.GetAttribute("Name").ToString(); enabled = Convert.ToInt16(xmlFileRdr.GetAttribute("Enabled").ToString()); //create a new test case TestCase newCase = new TestCase("", enabled, name, type, testNo); genContentsQ.Enqueue(newCase); break; } } break; } } } //close the file and make sure the queue is as small as it can be xmlFileRdr.Close(); genContentsQ.TrimToSize(); //compare the two contents of the file compare(); }
private Bitmap MergingAllImage() { Bitmap LastBitmap = new Bitmap(this.bitmap.Width, this.bitmap.Height); using (Graphics grp = Graphics.FromImage(LastBitmap)) { var DefaultBackgroundBrushes = Brushes.Black; if (App.Default.IsBlackShadow) { DefaultBackgroundBrushes = Brushes.White; } grp.FillRectangle( DefaultBackgroundBrushes, 0, 0, this.bitmap.Width, this.bitmap.Height); } Rectangle _Rectangle = new Rectangle(0, 0, LastBitmap.Width, LastBitmap.Height); Queue TempQueue = new Queue(); LastBitmap.GaussianBlur(ref _Rectangle, App.Default.ShadowBlurRadio); if(ImgQueue.Count > 0) { var canvas = Graphics.FromImage(LastBitmap); while(ImgQueue.Count > 0) { Bitmap tmpImg=(Bitmap)ImgQueue.Dequeue(); if (App.Default.IsBlackShadow) { tmpImg.MakeTransparent(Color.White); } else { tmpImg.MakeTransparent(Color.Black); } tmpImg.GaussianBlur(ref _Rectangle,App.Default.ShadowBlurRadio); if (ImgQueue.Count < ImgQueueLitmitation) { TempQueue.Enqueue(tmpImg); } ColorMatrix cm = new ColorMatrix(); cm.Matrix33 = App.Default.ShadowAlpha; ImageAttributes _ImageAttributes = new ImageAttributes(); _ImageAttributes.SetColorMatrix(cm); canvas.InterpolationMode = InterpolationMode.HighQualityBicubic; canvas.DrawImage(tmpImg, new Rectangle(0, 0, this.panelView.Size.Width, this.panelView.Size.Height), 0, 0, this.panelView.Size.Width, this.panelView.Size.Height,GraphicsUnit.Pixel,_ImageAttributes); canvas.Save(); } ImgQueue = TempQueue; ImgQueue.TrimToSize(); } return LastBitmap; }