protected void SerializeDirtyFieldsSnapshot() { if (IsServer) { //server keeps snapshots for the rewind ability ulong timestep = Networker.Time.Timestep; //need to locally produce store the snapshot SnapShot snapshot = new SnapShot() { tick = (long)timestep, position = _position, rotation = _rotation, velocity = _velocity, Health = _Health }; lock (_Snapshots) { _Snapshots.AddLast(snapshot); if (_Snapshots.Count > 5) { Debug.LogFormat("SerializeDirtyFieldsSnapshot: {0} {1} {2} {3}", _Snapshots.Count, _Snapshots.First.Value.tick, timestep, _Snapshots.Last.Value.tick); } } } }
/// <summary> /// Adds an item to the queue in priority order /// </summary> /// <param name="item">The item to place in the queue</param> public void Enqueue(T item) { // if the list is empty, just add the item if (_items.Count == 0) { _items.AddLast(item); } else { // find the proper insert point var current = _items.First; // while we're not at the end of the list and the current value // is larger than the value being inserted... while (current != null && current.Value.CompareTo(item) > 0) { current = current.Next; } if (current == null) { // we made it to the end of the list _items.AddLast(item); } else { // the current item is <= the one being added // so add the item before it. _items.AddBefore(current, item); } } }
public void Enqueue(T value) { if (_list.Count == 0) { _list.AddLast(value); } else { System.Collections.Generic.LinkedListNode <T> temp = _list.First; while (temp != null && temp.Value.CompareTo(value) > 0) { temp = temp.Next; } if (temp == null) { _list.AddLast(value); } else { _list.AddBefore(temp, value); } } }
public void Enqueue(T item) { if (_items.Count == 0) { _items.AddLast(item); } else { var current = _items.First; while (current != null && current.Value.CompareTo(item) > 0) { current = current.Next; } if (current == null) { _items.AddLast(item); } else { _items.AddBefore(current, item); } } }
static void Main(string[] args) { System.Collections.Generic.LinkedList <int> list = new System.Collections.Generic.LinkedList <int>(); list.AddFirst(1); list.AddLast(2); list.AddLast(3); list.AddLast(4); list.AddLast(5); var result = list.FindKthFromLastRecursive(2); }
EnqueuePackageRepositoryToVisit( System.Collections.Generic.LinkedList <System.Tuple <string, PackageDefinition> > reposToVisit, string repoPath, PackageDefinition sourcePackageDefinition) { // need to always pre-load the search paths (reposToVisit) with the repo that the master package resides in if (null != sourcePackageDefinition) { // visited already? ignore if (Graph.Instance.PackageRepositories.Contains(repoPath)) { return; } // visited parent already? ignore if (Graph.Instance.PackageRepositories.Any(item => repoPath.StartsWith(item))) { return; } } // already planned to visit? ignore if (reposToVisit.Any(item => item.Item1 == repoPath)) { return; } // new path is a parent path of a repo waiting to be viewed? replace all children with the parent (as it's a recursive search) if (reposToVisit.Any(item => item.Item1.StartsWith(repoPath))) { foreach (var repo in reposToVisit.Where(item => item.Item1.StartsWith(repoPath)).ToList()) { reposToVisit.Remove(repo); } } reposToVisit.AddLast(System.Tuple.Create <string, PackageDefinition>(repoPath, sourcePackageDefinition)); }
public static void Demo() { Console.WriteLine("LinkedList......"); string[] words = { "the", "actor", "jumped", "over", "the", "director" }; System.Collections.Generic.LinkedList <string> sentence = new System.Collections.Generic.LinkedList <string>(words); Display(sentence, "The linked list values:"); sentence.AddFirst("today"); Display(sentence, "Test 1: Add 'today' to beginning of the list:"); System.Collections.Generic.LinkedListNode <string> mark1 = sentence.First; sentence.RemoveFirst(); sentence.AddLast(mark1); Display(sentence, "Test 2: Move first node to be last node:"); sentence.RemoveLast(); sentence.AddLast("yesterday"); Display(sentence, "Test 3: Change the last node to 'yesterday':"); mark1 = sentence.Last; sentence.RemoveLast(); sentence.AddFirst(mark1); Display(sentence, "Test 4: Move last node to be first node:"); sentence.RemoveFirst(); System.Collections.Generic.LinkedListNode <string> current = sentence.FindLast("the"); IndicateNode(current, "Test 5: Indicate last occurence of 'the':"); sentence.AddAfter(current, "old"); sentence.AddAfter(current, "lazy"); IndicateNode(current, "Test 6: Add 'lazy' and 'old' after 'the':"); current = sentence.Find("actor"); IndicateNode(current, "Test 7: Indicate the 'actor' node:"); sentence.AddBefore(current, "quick"); sentence.AddBefore(current, "skinny"); IndicateNode(current, "Test 8: Add 'quick' and 'skinny' before 'actor':"); Console.WriteLine("End of LinkedList"); }
private void NewLine() { buffer.AddLast(lastLine.ToString()); if (buffer.Count > bufferSize) { buffer.RemoveFirst(); } lastLine.Clear(); }
/** 更新。 */ public static void Main(string a_label = nameof(Test_21)) { UnityEngine.Debug.Log("----- " + a_label + " -----"); try{ System.Collections.Generic.LinkedList <int> t_item_from = new System.Collections.Generic.LinkedList <int>(); { t_item_from.AddLast(1); t_item_from.AddLast(2); t_item_from.AddLast(3); } //オブジェクト ==> JSONITEM。 #if (FEE_JSON) Fee.JsonItem.JsonItem t_jsonitem = Fee.JsonItem.Convert.ObjectToJsonItem <System.Collections.Generic.LinkedList <int> >(t_item_from); #endif //JSONITEM ==> JSON文字列。 #if (FEE_JSON) string t_jsonstring = t_jsonitem.ConvertToJsonString(); #else string t_jsonstring = UnityEngine.JsonUtility.ToJson(t_item_from); #endif //JSON文字列 ==> オブジェクト。 #if (FEE_JSON) System.Collections.Generic.LinkedList <int> t_item_to = Fee.JsonItem.Convert.JsonStringToObject <System.Collections.Generic.LinkedList <int> >(t_jsonstring); #else System.Collections.Generic.LinkedList <int> t_item_to = UnityEngine.JsonUtility.FromJson <System.Collections.Generic.LinkedList <int> >(t_jsonstring); #endif //ログ。 UnityEngine.Debug.Log(a_label + " : " + t_jsonstring); //チェック。 if (Check(t_item_from, t_item_to) == false) { UnityEngine.Debug.LogError("mismatch"); } }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(a_label + " : exception : " + t_exception.Message); } }
public void StandartLinkedList() { var l = 256 * 16 * 256; var ll = new System.Collections.Generic.LinkedList <Char>(); for (int i = 0; i < l; i++) { ll.AddLast('a'); } }
private void FillCache() { while (input.IncrementToken()) { cache.AddLast(CaptureState()); } // capture final state input.End(); finalState = CaptureState(); }
public void BulkInsert() { System.Collections.Generic.LinkedList<SqlEntity1> list = new System.Collections.Generic.LinkedList<SqlEntity1>(); for (int i = 0; i < 100; i++) list.AddLast(new SqlEntity1() { Message = "Bulk insert " + i }); SqlDatabase.Default.Insert<SqlEntity1>(list); }
private void InOrderTraversal(BinaryTreeNode binaryTreeNode, ref System.Collections.Generic.LinkedList <int> doublyLinkedList) { if (binaryTreeNode == null) { return; } InOrderTraversal(binaryTreeNode.Left, ref doublyLinkedList); doublyLinkedList.AddLast(binaryTreeNode.Value); InOrderTraversal(binaryTreeNode.Right, ref doublyLinkedList); }
internal static bool ruby_thread_abort = false; //TODO: Not done yet - back ground logic!! //needs a default group //----------------------------------------------------------------- internal Thread() : base(Ruby.Runtime.Init.rb_cThread) { if (thread_list == null) { //create the thread_list and add the main thread thread_list = new System.Collections.Generic.LinkedList<Thread>(); thread_list.AddLast(Eval.main_thread); } thGroup = Eval.thgroup_default; }
/// <summary> /// Queues a task to the scheduler. /// </summary> /// <param name="task">Task.</param> protected sealed override void QueueTask(System.Threading.Tasks.Task task) { // Add the task to the list of tasks to be processed. If there aren't enough // delegates currently queued or running to process tasks, schedule another. lock (_tasks) { _tasks.AddLast(task); if (_delegatesQueuedOrRunning < _maxDegreeOfParallelism) { ++_delegatesQueuedOrRunning; NotifyThreadPoolOfPendingWork(); } } }
public static string[] GetAllTextInSlide(DocumentFormat.OpenXml.Packaging.SlidePart slidePart) { // Verify that the slide part exists. if (slidePart == null) { throw new System.ArgumentNullException("slidePart"); } // Create a new linked list of strings. System.Collections.Generic.LinkedList <string> texts = new System.Collections.Generic.LinkedList <string>(); // If the slide exists... if (slidePart.Slide != null) { // Iterate through all the paragraphs in the slide. foreach (DocumentFormat.OpenXml.Drawing.Paragraph paragraph in slidePart.Slide.Descendants <DocumentFormat.OpenXml.Drawing.Paragraph>()) { // Create a new string builder. System.Text.StringBuilder paragraphText = new System.Text.StringBuilder(); // Iterate through the lines of the paragraph. foreach (DocumentFormat.OpenXml.Drawing.Text text in paragraph.Descendants <DocumentFormat.OpenXml.Drawing.Text>()) { // Append each line to the previous lines. paragraphText.Append(text.Text); } if (paragraphText.Length > 0) { // Add each paragraph to the linked list. texts.AddLast(paragraphText.ToString()); } } } if (texts.Count > 0) { // Return an array of strings. return(System.Linq.Enumerable.ToArray(texts)); } else { return(null); } }
public static void Main() { var list = new System.Collections.Generic.LinkedList <int>(); var myList = new LinkedList <int>(); for (int i = 0; i < 15; i++) { list.AddLast(i); myList.AddLast(i); } list.Remove(14); myList.Remove(14); Console.WriteLine(string.Join(", ", list)); Console.WriteLine(string.Join(", ", myList)); }
static System.Collections.Generic.LinkedList <TItem> LinkedListImpl <TItem, TEnumerable, TEnumerator>(ref TEnumerable e) where TEnumerable : struct, IStructEnumerable <TItem, TEnumerator> where TEnumerator : struct, IStructEnumerator <TItem> { if (e.IsDefaultValue()) { throw CommonImplementation.Uninitialized(nameof(e)); } var ret = new System.Collections.Generic.LinkedList <TItem>(); foreach (var item in e) { ret.AddLast(item); } return(ret); }
static StackObject *AddLast_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance> @value = (System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance>) typeof(System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Collections.Generic.LinkedList <System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance> > instance_of_this_method = (System.Collections.Generic.LinkedList <System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance> >) typeof(System.Collections.Generic.LinkedList <System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance> >).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.AddLast(@value); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
private void UpdateWorkUnit(string in_wwuFullPath, string in_wwuType, string in_relativePath) { var PathAndIcons = new System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement>(); var currentPathInProj = string.Empty; //Add physical folders to the hierarchy if the work unit isn't in the root folder var physicalPath = in_relativePath.Split(System.IO.Path.DirectorySeparatorChar); for (var i = 0; i < physicalPath.Length - 1; i++) { PathAndIcons.AddLast( new AkWwiseProjectData.PathElement(physicalPath[i], WwiseObjectType.PhysicalFolder, System.Guid.Empty)); currentPathInProj = System.IO.Path.Combine(currentPathInProj, physicalPath[i]); } //Parse the work unit file RecurseWorkUnit(AssetType.Create(in_wwuType), new System.IO.FileInfo(in_wwuFullPath), currentPathInProj, in_relativePath.Remove(in_relativePath.LastIndexOf(System.IO.Path.DirectorySeparatorChar)), PathAndIcons); }
void Init() { if (!Directory.Exists(_info.DatePath)) { return; } var list = new DirectoryInfo(_info.DatePath).GetFiles().ToList(); list.Sort((x, y) => String.Compare(x.Name, y.Name, StringComparison.Ordinal)); foreach (var file in list) { var macth = Regex.Match(file.Name, @"\d{8}"); if (macth.Success) { DateTime date; if (DateTime.TryParseExact(macth.Groups[0].Value, "yyyyMMdd", null, DateTimeStyles.None, out date) && date >= _info.DateTime1 && date <= _info.DateTime2) { _files.AddLast(file); _count += (int)file.Length; } } } if (_count > 0) { EndOfSeries = false; _progressDelta = (int)Math.Ceiling(((double)_count / 100)); _progressCount = _progressDelta; _progressPercent = 0; OpenReader(); } if (_current == null) { EndOfSeries = true; } }
public static void Main(string[] args) { System.Collections.Generic.IList <string> al = new System.Collections.Generic.List <string>(); al.Add("1"); al.Add("2"); al.Add("3"); al.Remove("2"); al.RemoveAtReturningValue(1); Sharpen.Collections.AddAll(al, Sharpen.Arrays.AsList("5", "6", "7")); al[0] = "1"; System.Console.Out.WriteLine(al.Count); System.Console.Out.WriteLine((al.Count == 0)); System.Console.Out.WriteLine(al.Contains("3")); System.Console.Out.WriteLine(Sharpen.Collections.ToArray(al)); System.Console.Out.WriteLine(Sharpen.Collections.ToArray(al, new string[al.Count])); System.Collections.Generic.LinkedList <string> ll = new System.Collections.Generic.LinkedList <string>(); ll.AddFirst("f1"); ll.AddLast("l1"); Sharpen.Collections.RemoveFirst(ll); Sharpen.Collections.RemoveLast(ll); ll.Remove("1"); System.Console.Out.WriteLine(ll); }
EnqueuePackageRepositoryToVisit( System.Collections.Generic.LinkedList <System.Tuple <string, PackageDefinition> > reposToVisit, ref int reposAdded, string repoPath, PackageDefinition sourcePackageDefinition) { // need to always pre-load the search paths (reposToVisit) with the repo that the master package resides in if (null != sourcePackageDefinition) { // visited already? ignore if (Graph.Instance.PackageRepositories.Contains(repoPath)) { return; } } // already planned to visit? ignore if (reposToVisit.Any(item => item.Item1 == repoPath)) { return; } reposToVisit.AddLast(System.Tuple.Create <string, PackageDefinition>(repoPath, sourcePackageDefinition)); ++reposAdded; }
private int RecurseWorkUnit(AssetType in_type, System.IO.FileInfo in_workUnit, string in_currentPathInProj, string in_currentPhysicalPath, System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement> in_pathAndIcons, string in_parentPath = "") { m_WwuToProcess.Remove(in_workUnit.FullName); var wwuIndex = -1; try { //Progress bar stuff var msg = "Parsing Work Unit " + in_workUnit.Name; UnityEditor.EditorUtility.DisplayProgressBar(s_progTitle, msg, m_currentWwuCnt / (float)m_totWwuCnt); m_currentWwuCnt++; in_currentPathInProj = System.IO.Path.Combine(in_currentPathInProj, System.IO.Path.GetFileNameWithoutExtension(in_workUnit.Name)); in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement( System.IO.Path.GetFileNameWithoutExtension(in_workUnit.Name), WwiseObjectType.WorkUnit)); var WwuPhysicalPath = System.IO.Path.Combine(in_currentPhysicalPath, in_workUnit.Name); var wwu = ReplaceWwuEntry(WwuPhysicalPath, in_type, out wwuIndex); wwu.ParentPath = in_currentPathInProj; wwu.PhysicalPath = WwuPhysicalPath; wwu.PathAndIcons = new System.Collections.Generic.List <AkWwiseProjectData.PathElement>(in_pathAndIcons); wwu.Guid = System.Guid.Empty; wwu.LastTime = System.IO.File.GetLastWriteTime(in_workUnit.FullName); using (var reader = System.Xml.XmlReader.Create(in_workUnit.FullName)) { reader.MoveToContent(); reader.Read(); while (!reader.EOF && reader.ReadState == System.Xml.ReadState.Interactive) { if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals("WorkUnit")) { if (wwu.Guid.Equals(System.Guid.Empty)) { var ID = reader.GetAttribute("ID"); try { wwu.Guid = new System.Guid(ID); } catch { UnityEngine.Debug.LogWarning("WwiseUnity: Error reading ID <" + ID + "> from work unit <" + in_workUnit.FullName + ">."); throw; } } var persistMode = reader.GetAttribute("PersistMode"); if (persistMode == "Reference") { // ReadFrom advances the reader var matchedElement = System.Xml.Linq.XNode.ReadFrom(reader) as System.Xml.Linq.XElement; var newWorkUnitPath = System.IO.Path.Combine(in_workUnit.Directory.FullName, matchedElement.Attribute("Name").Value + ".wwu"); var newWorkUnit = new System.IO.FileInfo(newWorkUnitPath); // Parse the referenced Work Unit RecurseWorkUnit(in_type, newWorkUnit, in_currentPathInProj, in_currentPhysicalPath, in_pathAndIcons, WwuPhysicalPath); } else { // If the persist mode is "Standalone" or "Nested", it means the current XML tag // is the one corresponding to the current file. We can ignore it and advance the reader reader.Read(); } } else if (reader.NodeType == System.Xml.XmlNodeType.Element && (reader.Name.Equals("AuxBus") || reader.Name.Equals("Folder") || reader.Name.Equals("Bus"))) { WwiseObjectType objType; switch (reader.Name) { case "AuxBus": objType = WwiseObjectType.AuxBus; break; case "Bus": objType = WwiseObjectType.Bus; break; case "Folder": default: objType = WwiseObjectType.Folder; break; } in_currentPathInProj = System.IO.Path.Combine(in_currentPathInProj, reader.GetAttribute("Name")); in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), objType)); bool IsEmptyElement = reader.IsEmptyElement; // Need to cache this because AddElementToList advances the reader. AddElementToList(in_currentPathInProj, reader, in_type, in_pathAndIcons, wwuIndex, objType); if (IsEmptyElement) { // This element has no children, step out of it immediately // Remove the folder/bus from the path in_currentPathInProj = in_currentPathInProj.Remove(in_currentPathInProj.LastIndexOf(System.IO.Path.DirectorySeparatorChar)); in_pathAndIcons.RemoveLast(); // Reader was already advanced by AddElementToList } } else if (reader.NodeType == System.Xml.XmlNodeType.EndElement && (reader.Name.Equals("Folder") || reader.Name.Equals("Bus") || reader.Name.Equals("AuxBus"))) { // Remove the folder/bus from the path in_currentPathInProj = in_currentPathInProj.Remove(in_currentPathInProj.LastIndexOf(System.IO.Path.DirectorySeparatorChar)); in_pathAndIcons.RemoveLast(); // Advance the reader reader.Read(); } else if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals(in_type.XmlElementName)) { // Add the element to the list AddElementToList(in_currentPathInProj, reader, in_type, in_pathAndIcons, wwuIndex); } else { reader.Read(); } } } // Sort the newly populated Wwu alphabetically SortWwu(in_type, wwuIndex); } catch (System.Exception e) { UnityEngine.Debug.LogError(e.ToString()); wwuIndex = -1; } in_pathAndIcons.RemoveLast(); return(wwuIndex); }
public System.IntPtr Allocate(long size) { System.Collections.Generic.LinkedList <T> candidates = new System.Collections.Generic.LinkedList <T>(); System.IntPtr pointer = System.IntPtr.Zero; bool continue_ = true; size += System.Runtime.InteropServices.Marshal.SizeOf(typeof(T)) % System.IntPtr.Size; int wide = System.IntPtr.Size * 8; // 32 or 64 while (continue_) { //If there is no size make a new object which allocated 12 or more bytes to make a gap, next allocation should be aligned. if (size == 0) { object gap = new object(); } candidates.AddLast(new T()); #region Unused //Crashed compiler... Base method is not marked unsafe? //unsafe{ ////Make a local reference to the result //System.TypedReference trResult = __makeref(candidates.Last.Value); ////Make a pointer to the local reference //System.IntPtr localReferenceResult = *(System.IntPtr*)(&trResult); //} #endregion pointer = Concepts.Classes.CommonIntermediateLanguage.As <T, System.IntPtr>(candidates.Last.Value); #region Unused //Fix the handle //System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(candidates.Last.Value, System.Runtime.InteropServices.GCHandleType.Pinned); //To determine if its sized correctly. //pointer = handle.AddrOfPinnedObject(); #endregion continue_ = (pointer.ToInt64() & System.IntPtr.Size - 1) != 0 || (pointer.ToInt64() % wide) == 24; #region Unused //handle.Free(); #endregion } return(pointer); }
/// <summary> /// Adds an item to the back of the queue /// </summary> /// <param name="item">The item to place in the queue</param> public void Enqueue(T item) { _items.AddLast(item); }
private void UpdateTab(Modes m, TextBox txt) { if (FileName.Length == 0) { txt.Text = "File is not set"; return; } try { string tt = System.IO.File.ReadAllText(FileName); if (m == Modes.Text) { txt.Text = tt; return; } SimpleScanner.Scanner scan = new SimpleScanner.Scanner(); scan.SetSource(tt, 0); SimpleParser.Parser pars = new SimpleParser.Parser(scan); var b = pars.Parse(); if (!b) { txt.Text = "Ошибка парсинга"; return; } var r = pars.root; SimpleLang.Visitors.FillParentVisitor parVisitor = new SimpleLang.Visitors.FillParentVisitor(); r.Visit(parVisitor); SimpleLang.Visitors.AutoApplyVisitor optAst = GetASTOptimizer(); optAst.Apply(r); if (m == Modes.ASTOpt) { SimpleLang.Visitors.PrettyPrintVisitor vis = new SimpleLang.Visitors.PrettyPrintVisitor(); r.Visit(vis); txt.Text = vis.Text; return; } SimpleLang.Visitors.ThreeAddressCodeVisitor threeCodeVisitor = new SimpleLang.Visitors.ThreeAddressCodeVisitor(); r.Visit(threeCodeVisitor); if (m == Modes.BeforeThreeCode) { txt.Text = SimpleLang.Visitors.ThreeAddressCodeVisitor.ToString(threeCodeVisitor.GetCode()); Console.WriteLine(txt.Text); return; } if (m == Modes.BeforeRun) { SimpleLang.Compiler.ILCodeGenerator gen = new SimpleLang.Compiler.ILCodeGenerator(); gen.Generate(threeCodeVisitor.GetCode()); var timer = System.Diagnostics.Stopwatch.StartNew(); string res = gen.Execute(); timer.Stop(); res = res + "\n\n\nExecuted: " + timer.ElapsedMilliseconds.ToString() + " ms" + " or " + timer.ElapsedTicks.ToString() + " ticks"; txt.Text = res; return; } if (m == Modes.BeforeBlocks) { var blocks = new SimpleLang.Block.Block(threeCodeVisitor).GenerateBlocks(); txt.Text = SimpleLang.Visitors.ThreeAddressCodeVisitor.ToString(blocks); return; } var opt = GetOptimiser(); var outcode = opt.Apply(threeCodeVisitor); if (m == Modes.AfterBlocks) { txt.Text = SimpleLang.Visitors.ThreeAddressCodeVisitor.ToString(outcode); return; } if (m == Modes.AfterTbreeCode) { System.Collections.Generic.LinkedList <SimpleLang.Visitors.ThreeCode> res = new System.Collections.Generic.LinkedList <SimpleLang.Visitors.ThreeCode>(); foreach (var block in outcode) { foreach (SimpleLang.Visitors.ThreeCode code in block) { res.AddLast(code); } } txt.Text = SimpleLang.Visitors.ThreeAddressCodeVisitor.ToString(res); Console.WriteLine(txt.Text); return; } if (m == Modes.AfterRun) { System.Collections.Generic.LinkedList <SimpleLang.Visitors.ThreeCode> res = new System.Collections.Generic.LinkedList <SimpleLang.Visitors.ThreeCode>(); foreach (var block in outcode) { foreach (SimpleLang.Visitors.ThreeCode code in block) { res.AddLast(code); } } SimpleLang.Compiler.ILCodeGenerator gen = new SimpleLang.Compiler.ILCodeGenerator(); gen.Generate(res); var timer = System.Diagnostics.Stopwatch.StartNew(); string ooo = gen.Execute(); timer.Stop(); ooo = ooo + "\n\n\nExecuted: " + timer.ElapsedMilliseconds.ToString() + " ms" + " or " + timer.ElapsedTicks.ToString() + " ticks"; txt.Text = ooo; return; } txt.Text = "Is not implemented"; } catch (Exception e) { txt.Text = e.ToString(); } }
public void Add(string part) { //Add parts parts.AddLast(part); }
protected override BMSByte SerializeDirtyFields() { dirtyFieldsData.Clear(); dirtyFieldsData.Append(_dirtyFields); ulong tick = GameManager.Instance.Tick; UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, tick); if ((0x1 & _dirtyFields[0]) != 0) { UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _position); } if ((0x2 & _dirtyFields[0]) != 0) { UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _rotation); } if ((0x4 & _dirtyFields[0]) != 0) { UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _velocity); } if ((0x8 & _dirtyFields[0]) != 0) { UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _Health); } if ((0x10 & _dirtyFields[0]) != 0) { UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _LastCommand); } if (IsServer) { //server keeps snapshots for the rewind ability //need to locally produce store the snapshot SnapShot snapshot = new SnapShot() { tick = tick, position = _position, rotation = _rotation, velocity = _velocity, Health = _Health, LastCommand = _LastCommand, }; lock (_Snapshots) { _Snapshots.AddLast(snapshot); if (_Snapshots.Count > (IsServer ? 65 : 15)) { //Debug.LogFormat("SerializeDirtyFieldsSnapshot: {0} {1} {2} {3}", _Snapshots.Count, _Snapshots.First.Value.tick, tick, _Snapshots.Last.Value.tick); } } if (OnSnapshotAdded != null) { OnSnapshotAdded(snapshot); } } // Reset all the dirty fields for (int i = 0; i < _dirtyFields.Length; i++) { _dirtyFields[i] = 0; } return(dirtyFieldsData); }
private int RecurseWorkUnit(AssetType in_type, System.IO.FileInfo in_workUnit, string in_currentPathInProj, string in_currentPhysicalPath, System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement> in_pathAndIcons, string in_parentPhysicalPath = "") { m_WwuToProcess.Remove(in_workUnit.FullName); System.Xml.XmlReader reader = null; var wwuIndex = -1; try { //Progress bar stuff var msg = "Parsing Work Unit " + in_workUnit.Name; UnityEditor.EditorUtility.DisplayProgressBar(s_progTitle, msg, m_currentWwuCnt / (float)m_totWwuCnt); m_currentWwuCnt++; in_currentPathInProj = System.IO.Path.Combine(in_currentPathInProj, System.IO.Path.GetFileNameWithoutExtension(in_workUnit.Name)); in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement( System.IO.Path.GetFileNameWithoutExtension(in_workUnit.Name), AkWwiseProjectData.WwiseObjectType.WORKUNIT)); var WwuPhysicalPath = System.IO.Path.Combine(in_currentPhysicalPath, in_workUnit.Name); AkWwiseProjectData.WorkUnit wwu = null; ReplaceWwuEntry(WwuPhysicalPath, in_type, out wwu, out wwuIndex); wwu.ParentPhysicalPath = in_parentPhysicalPath; wwu.PhysicalPath = WwuPhysicalPath; wwu.Guid = ""; wwu.SetLastTime(System.IO.File.GetLastWriteTime(in_workUnit.FullName)); reader = System.Xml.XmlReader.Create(in_workUnit.FullName); reader.MoveToContent(); reader.Read(); while (!reader.EOF && reader.ReadState == System.Xml.ReadState.Interactive) { if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals("WorkUnit")) { if (wwu.Guid.Equals("")) { wwu.Guid = reader.GetAttribute("ID"); } var persistMode = reader.GetAttribute("PersistMode"); if (persistMode == "Reference") { // ReadFrom advances the reader var matchedElement = System.Xml.Linq.XNode.ReadFrom(reader) as System.Xml.Linq.XElement; var newWorkUnitPath = System.IO.Path.Combine(in_workUnit.Directory.FullName, matchedElement.Attribute("Name").Value + ".wwu"); var newWorkUnit = new System.IO.FileInfo(newWorkUnitPath); // Parse the referenced Work Unit if (m_WwuToProcess.Contains(newWorkUnit.FullName)) { RecurseWorkUnit(in_type, newWorkUnit, in_currentPathInProj, in_currentPhysicalPath, in_pathAndIcons, WwuPhysicalPath); } } else { // If the persist mode is "Standalone" or "Nested", it means the current XML tag // is the one corresponding to the current file. We can ignore it and advance the reader reader.Read(); } } else if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals("AuxBus")) { in_currentPathInProj = System.IO.Path.Combine(in_currentPathInProj, reader.GetAttribute("Name")); in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), AkWwiseProjectData.WwiseObjectType.AUXBUS)); var isEmpty = reader.IsEmptyElement; AddElementToList(in_currentPathInProj, reader, in_type, in_pathAndIcons, wwuIndex); if (isEmpty) { in_currentPathInProj = in_currentPathInProj.Remove(in_currentPathInProj.LastIndexOf(System.IO.Path.DirectorySeparatorChar)); in_pathAndIcons.RemoveLast(); } } // Busses and folders act the same for the Hierarchy: simply add them to the path else if (reader.NodeType == System.Xml.XmlNodeType.Element && (reader.Name.Equals("Folder") || reader.Name.Equals("Bus"))) { //check if node has children if (!reader.IsEmptyElement) { // Add the folder/bus to the path in_currentPathInProj = System.IO.Path.Combine(in_currentPathInProj, reader.GetAttribute("Name")); if (reader.Name.Equals("Folder")) { in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), AkWwiseProjectData.WwiseObjectType.FOLDER)); } else if (reader.Name.Equals("Bus")) { in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), AkWwiseProjectData.WwiseObjectType.BUS)); } } // Advance the reader reader.Read(); } else if (reader.NodeType == System.Xml.XmlNodeType.EndElement && (reader.Name.Equals("Folder") || reader.Name.Equals("Bus") || reader.Name.Equals("AuxBus"))) { // Remove the folder/bus from the path in_currentPathInProj = in_currentPathInProj.Remove(in_currentPathInProj.LastIndexOf(System.IO.Path.DirectorySeparatorChar)); in_pathAndIcons.RemoveLast(); // Advance the reader reader.Read(); } else if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals(in_type.XmlElementName)) { // Add the element to the list AddElementToList(in_currentPathInProj, reader, in_type, in_pathAndIcons, wwuIndex); } else { reader.Read(); } } // Sort the newly populated Wwu alphabetically SortWwu(in_type.RootDirectoryName, wwuIndex); } catch (System.Exception e) { UnityEngine.Debug.LogError(e.ToString()); wwuIndex = -1; } if (reader != null) { reader.Close(); } in_pathAndIcons.RemoveLast(); return(wwuIndex); }
/// <summary>Call this method to add geometry to the cursor.</summary> /// <remarks> /// Call this method to add geometry to the cursor. After this method is /// called, call immediately the tock() method on the GeometryCursor returned /// by the OperatorUnion (or OperatorConvexHull with b_merge == true). Call /// next() on the GeometryCursor returned by the OperatorUnion when done /// listening to incoming geometries to finish the union operation. /// </remarks> /// <param name="geom">The geometry to be pushed into the cursor.</param> public void Tick(com.epl.geometry.Geometry geom) { m_geomList.AddLast(geom); }
/// <summary> /// Adds the specified item to the end of the queue /// </summary> /// <param name="item">The item</param> public void Enqueue(T item) { _list.AddLast(item); }