/// <summary> /// Initializes a new instance of the <see cref="ObjectPool"/> class. /// </summary> /// <param name='max_qty'> /// Max_qty. /// </param> public ObjectPool( GameObject prototype, uint max_qty ) { _prototype = prototype; _maxQty = max_qty; _queue = new System.Collections.Generic.Queue<GameObject>(); this.populate(); }
public static bool verifyBalanced(TreeNode td) { System.Collections.Generic.Queue<TreeNode> q = new System.Collections.Generic.Queue<TreeNode>(); q.Enqueue(td); while (q.Count != 0) { TreeNode tn_from_queue = q.Dequeue(); if (tn_from_queue.Nodes.Count == 0) { if (findMin) { Min = tn_from_queue.state; findMin = false; } Max = tn_from_queue.state; } foreach (TreeNode tn_loop in tn_from_queue.Nodes) { tn_loop.state = tn_from_queue.state + 1; q.Enqueue(tn_loop); } } return (Max - Min) <= 1; }
public static bool findLinkV5(GraphNode start, GraphNode end) { System.Collections.Generic.Queue<GraphNode> searched = new System.Collections.Generic.Queue<GraphNode>(); searched.Enqueue(start); start.state = Visiting; while (searched.Count!=0) { GraphNode gn = searched.Dequeue(); if (gn!=null) { gn.state = Visited; foreach (GraphNode node in gn.Nodes) { if (node.state == Unvisitied) { if (node == end) { return true; } node.state = Visiting; searched.Enqueue(node); } } } } return false; }
public Console() { _Messages = new System.Collections.Generic.Queue<string>(); _Input = ""; _LastMessage = ""; _ScrollView = Vector2.zero; _Console = new Regulus.Utility.Console(this ,this); }
Network() { networkThread = null; mode = NetworkMode.HOST; chatBuffer = new System.Collections.Generic.Queue<Chat>(); gameBuffer = new System.Collections.Generic.Queue<Action>(); ip = "127.0.0.1"; port = 10101; stream = null; }
public Peer(System.Net.Sockets.Socket client) { _Socket = client; _SoulProvider = new Remoting.Soul.SoulProvider(this, this); _Responses = new Queue<Remoting.Package>(); _Requests = new Queue<Request>(); _ReadMachine = new Game.StageMachine(); _WriteMachine = new Game.StageMachine(); _Enable = true; }
public static bool findLinkBreath(GraphNode start, GraphNode end) { System.Collections.Generic.Queue<GraphNode> q = new System.Collections.Generic.Queue<GraphNode>(); q.Enqueue(start); while (q.Count != 0) { GraphNode gn_from_queue = q.Dequeue(); if (gn_from_queue == end) { return true; } foreach (GraphNode gn_loop in gn_from_queue.Nodes) { q.Enqueue(gn_loop); } } return false; }
void InitObjectsToPlace() { objectsToPlace = new System.Collections.Generic.Queue<ObjectInstance>(); //We had instances of the objects we want to instantiate ordered by the height they must appear //See ObjectInstance class for more precisions objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(5.0f, 20.0f, 2.0f), 0.0f, 50.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(3.0f, 22.0f, 1.0f), 0.0f, 50.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(-4.0f, 23.0f, 3.2f), 0.0f, 50.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(-3.0f, 25.0f, 0.0f), 0.0f, 55.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.0f, 30.0f, 1.0f), 0.0f, 60.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.0f, 30.0f, 0.0f), 0.0f, 60.0f)); for (float i = -3.0f; i <= 3.0f; i++) { for (float n = -3.0f; n <= 3.0f; n++) { objectsToPlace.Enqueue(new ObjectInstance(creaturePrefab, new Vector3(i*2, 40.0f, n*2), 0.0f, 60.0f)); } } objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.0f, 45.0f, 1.0f), 0.0f, 80.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(2.5f, 45.0f, 0.0f), 0.0f, 80.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.5f, 50.0f, 1.0f), 0.0f, 80.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.0f, 50.0f, 3.0f), 0.0f, 80.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.0f, 60.0f, 1.0f), 20.0f, 70.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.0f, 60.0f, 0.0f), 20.0f, 70.0f)); for (float i = -3.0f; i <= 3.0f; i++) { for (float n = -3.0f; n <= 3.0f; n++) { objectsToPlace.Enqueue(new ObjectInstance(creaturePrefab, new Vector3(i*2, 80.0f, n*2), 20.0f, 100.0f)); } } objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.0f, 80.0f, 0.0f), 40.0f, 100.0f)); objectsToPlace.Enqueue(new ObjectInstance(planctonPrefab, new Vector3(0.0f, 90.0f, 0.0f), 40.0f, 100.0f)); objectsToPlace.Enqueue(new ObjectInstance(runningPlanctonPrefab, new Vector3(5.0f, 100.0f, 15.0f), 55.0f, 150.0f)); objectsToPlace.Enqueue(new ObjectInstance(loupiottePrefab, new Vector3(5.0f, 75.0f, 15.0f), 65.0f, 150.0f)); objectsToPlace.Enqueue(new ObjectInstance(runningPlanctonPrefab, new Vector3(0.0f, 100.0f, 0.0f), 70.0f, 150.0f)); objectsToPlace.Enqueue(new ObjectInstance(loupiottePrefab, new Vector3(5.0f, 85.0f, 15.0f), 75.0f, 150.0f)); objectsToPlace.Enqueue(new ObjectInstance(finalLightPrefab, new Vector3(0.0f, 200.0f, 0.0f), 94.5f, 150.0f)); }
//iterate breadth first public IEnumerator GetBreadthNodes() { System.Collections.Generic.Queue<Node> que = new System.Collections.Generic.Queue<Node>(); que.Enqueue(this); while (0 < que.Count) { Node node = que.Dequeue(); foreach (Node child in node._children) que.Enqueue(child); yield return node; // _value; } }
public WaitQueueStage(System.Collections.Generic.Queue<Package> packages) { this._Packages = packages; }
static StackObject *get_Current_0(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, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); System.Collections.Generic.Queue <ILRuntime.Runtime.Intepreter.ILTypeInstance> .Enumerator instance_of_this_method = (System.Collections.Generic.Queue <ILRuntime.Runtime.Intepreter.ILTypeInstance> .Enumerator) typeof(System.Collections.Generic.Queue <ILRuntime.Runtime.Intepreter.ILTypeInstance> .Enumerator).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); var result_of_this_method = instance_of_this_method.Current; ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.NewUnitHudInterface = binaryReader.ReadTagReference(); return(pointerQueue); }
public StageMachine() { _StandBys = new Queue<IStage>(); _Current = new StageData(); _Handle = _HandleStandByEnter; }
private static async Task LoadQueueInternalAsync(IotHubClient client) { System.Collections.Generic.Queue<DataPoint> tmp = new System.Collections.Generic.Queue<DataPoint>(); try { StorageFolder storageFolder = ApplicationData.Current.LocalFolder; StorageFile file = await storageFolder.GetFileAsync(FILE_NAME); var stream = await file.OpenAsync(FileAccessMode.ReadWrite); ulong size = stream.Size; using (var inputStream = stream.GetInputStreamAt(0)) { using (var dataReader = new DataReader(inputStream)) { uint numBytesLoaded = await dataReader.LoadAsync((uint)size); int count = dataReader.ReadInt32(); for (int i = 0; i < count; i++) { DataPoint p = new DataPoint(); p.Read(dataReader); tmp.Enqueue(p); } } } stream.Dispose(); lock (client.thisLock) { client.queue.Clear(); client.queue = null; client.queue = new System.Collections.Generic.Queue<DataPoint>(tmp); } } catch (Exception) { } }
public override void DoImport(SCObjectSet objectSet, IImportContext context) { if (objectSet.HasRelations) { int allCount = objectSet.Objects.Count; int count = 0; var pendingGroups = new System.Collections.Generic.Queue<PC.SCGroup>(allCount); var pendingRelations = new System.Collections.Generic.Queue<PC.SCRelationObject>(allCount); foreach (var r in objectSet.Relations) { if (r.ParentID == this.Parent.ID) { pendingRelations.Enqueue(r); } } context.SetStatus(0, pendingRelations.Count, "正在寻找当前组织内的关系。"); if (objectSet.HasObjects) { foreach (var obj in objectSet.Objects) { if (obj.SchemaType == "Groups") { pendingGroups.Enqueue((PC.SCGroup)obj); } } } while (pendingGroups.Count > 0) { var grp = pendingGroups.Dequeue(); try { var summaryName = grp.DisplayName; context.SetStatus(count, allCount, "正在导入群组:" + summaryName); if ((from r in pendingRelations where r.ParentID == this.Parent.ID && r.ID == grp.ID select r).Any()) { PC.Executors.SCObjectOperations.InstanceWithPermissions.AddGroup(grp, this.Parent); context.AppendLog("已执行导入群组" + summaryName); if (this.IncludeMembers && objectSet.HasMembership) { context.AppendLog("正在查找群组成员"); var members = from m in objectSet.Membership where m.ContainerID == grp.ID && m.Status == SchemaObjectStatus.Normal select m; foreach (var m in members) { try { var obj = (PC.SCUser)PC.Adapters.SchemaObjectAdapter.Instance.Load(m.ID); if (obj != null) { context.AppendLogFormat("正在添加群组成员{0}\r\n", obj.DisplayName); PC.Executors.SCObjectOperations.InstanceWithPermissions.AddUserToGroup(obj, grp); } } catch (Exception ex) { context.AppendLog("添加群组成员时遇到错误:" + ex.Message); } } } if (this.IncludeConditions && objectSet.HasConditions) { context.AppendLog("正在查找群组条件表达式"); var conditions = new PC.Conditions.SCConditionCollection(); conditions.CopyFrom(ImportService.Instance.FilterConditions(objectSet.Conditions, c => c.OwnerID == grp.ID && c.Type == "Default")); var owner = PC.Adapters.SCConditionAdapter.Instance.Load(grp.ID, "Default") ?? new PC.Conditions.SCConditionOwner() { OwnerID = grp.ID, Type = "Default" }; owner.Conditions.ReplaceItemsWith(conditions, grp.ID, "Default"); try { context.AppendLog("正在添加群组条件表达式"); PC.Adapters.SCConditionAdapter.Instance.UpdateConditions(owner); context.AppendLog("群组条件表达式添加完毕"); } catch (Exception ex) { context.AppendLog("未能添加群组条件表达式,原因是:" + ex.Message); } } } } catch (Exception ex) { context.AppendLog("对群组的操作失败,原因是:" + ex.Message); } } } }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.EasyEnemyDamage = binaryReader.ReadSingle(); this.NormalEnemyDamage = binaryReader.ReadSingle(); this.HardEnemyDamage = binaryReader.ReadSingle(); this.ImpossEnemyDamage = binaryReader.ReadSingle(); this.EasyEnemyVitality = binaryReader.ReadSingle(); this.NormalEnemyVitality = binaryReader.ReadSingle(); this.HardEnemyVitality = binaryReader.ReadSingle(); this.ImpossEnemyVitality = binaryReader.ReadSingle(); this.EasyEnemyShield = binaryReader.ReadSingle(); this.NormalEnemyShield = binaryReader.ReadSingle(); this.HardEnemyShield = binaryReader.ReadSingle(); this.ImpossEnemyShield = binaryReader.ReadSingle(); this.EasyEnemyRecharge = binaryReader.ReadSingle(); this.NormalEnemyRecharge = binaryReader.ReadSingle(); this.HardEnemyRecharge = binaryReader.ReadSingle(); this.ImpossEnemyRecharge = binaryReader.ReadSingle(); this.EasyFriendDamage = binaryReader.ReadSingle(); this.NormalFriendDamage = binaryReader.ReadSingle(); this.HardFriendDamage = binaryReader.ReadSingle(); this.ImpossFriendDamage = binaryReader.ReadSingle(); this.EasyFriendVitality = binaryReader.ReadSingle(); this.NormalFriendVitality = binaryReader.ReadSingle(); this.HardFriendVitality = binaryReader.ReadSingle(); this.ImpossFriendVitality = binaryReader.ReadSingle(); this.EasyFriendShield = binaryReader.ReadSingle(); this.NormalFriendShield = binaryReader.ReadSingle(); this.HardFriendShield = binaryReader.ReadSingle(); this.ImpossFriendShield = binaryReader.ReadSingle(); this.EasyFriendRecharge = binaryReader.ReadSingle(); this.NormalFriendRecharge = binaryReader.ReadSingle(); this.HardFriendRecharge = binaryReader.ReadSingle(); this.ImpossFriendRecharge = binaryReader.ReadSingle(); this.EasyInfectionForms = binaryReader.ReadSingle(); this.NormalInfectionForms = binaryReader.ReadSingle(); this.HardInfectionForms = binaryReader.ReadSingle(); this.ImpossInfectionForms = binaryReader.ReadSingle(); this.fieldpad = binaryReader.ReadBytes(16); this.EasyRateOfFire = binaryReader.ReadSingle(); this.NormalRateOfFire = binaryReader.ReadSingle(); this.HardRateOfFire = binaryReader.ReadSingle(); this.ImpossRateOfFire = binaryReader.ReadSingle(); this.EasyProjectileError = binaryReader.ReadSingle(); this.NormalProjectileError = binaryReader.ReadSingle(); this.HardProjectileError = binaryReader.ReadSingle(); this.ImpossProjectileError = binaryReader.ReadSingle(); this.EasyBurstError = binaryReader.ReadSingle(); this.NormalBurstError = binaryReader.ReadSingle(); this.HardBurstError = binaryReader.ReadSingle(); this.ImpossBurstError = binaryReader.ReadSingle(); this.EasyNewTargetDelay = binaryReader.ReadSingle(); this.NormalNewTargetDelay = binaryReader.ReadSingle(); this.HardNewTargetDelay = binaryReader.ReadSingle(); this.ImpossNewTargetDelay = binaryReader.ReadSingle(); this.EasyBurstSeparation = binaryReader.ReadSingle(); this.NormalBurstSeparation = binaryReader.ReadSingle(); this.HardBurstSeparation = binaryReader.ReadSingle(); this.ImpossBurstSeparation = binaryReader.ReadSingle(); this.EasyTargetTracking = binaryReader.ReadSingle(); this.NormalTargetTracking = binaryReader.ReadSingle(); this.HardTargetTracking = binaryReader.ReadSingle(); this.ImpossTargetTracking = binaryReader.ReadSingle(); this.EasyTargetLeading = binaryReader.ReadSingle(); this.NormalTargetLeading = binaryReader.ReadSingle(); this.HardTargetLeading = binaryReader.ReadSingle(); this.ImpossTargetLeading = binaryReader.ReadSingle(); this.EasyOverchargeChance = binaryReader.ReadSingle(); this.NormalOverchargeChance = binaryReader.ReadSingle(); this.HardOverchargeChance = binaryReader.ReadSingle(); this.ImpossOverchargeChance = binaryReader.ReadSingle(); this.EasySpecialFireDelay = binaryReader.ReadSingle(); this.NormalSpecialFireDelay = binaryReader.ReadSingle(); this.HardSpecialFireDelay = binaryReader.ReadSingle(); this.ImpossSpecialFireDelay = binaryReader.ReadSingle(); this.EasyGuidanceVsPlayer = binaryReader.ReadSingle(); this.NormalGuidanceVsPlayer = binaryReader.ReadSingle(); this.HardGuidanceVsPlayer = binaryReader.ReadSingle(); this.ImpossGuidanceVsPlayer = binaryReader.ReadSingle(); this.EasyMeleeDelayBase = binaryReader.ReadSingle(); this.NormalMeleeDelayBase = binaryReader.ReadSingle(); this.HardMeleeDelayBase = binaryReader.ReadSingle(); this.ImpossMeleeDelayBase = binaryReader.ReadSingle(); this.EasyMeleeDelayScale = binaryReader.ReadSingle(); this.NormalMeleeDelayScale = binaryReader.ReadSingle(); this.HardMeleeDelayScale = binaryReader.ReadSingle(); this.ImpossMeleeDelayScale = binaryReader.ReadSingle(); this.fieldpad0 = binaryReader.ReadBytes(16); this.EasyGrenadeChanceScale = binaryReader.ReadSingle(); this.NormalGrenadeChanceScale = binaryReader.ReadSingle(); this.HardGrenadeChanceScale = binaryReader.ReadSingle(); this.ImpossGrenadeChanceScale = binaryReader.ReadSingle(); this.EasyGrenadeTimerScale = binaryReader.ReadSingle(); this.NormalGrenadeTimerScale = binaryReader.ReadSingle(); this.HardGrenadeTimerScale = binaryReader.ReadSingle(); this.ImpossGrenadeTimerScale = binaryReader.ReadSingle(); this.fieldpad1 = binaryReader.ReadBytes(16); this.fieldpad2 = binaryReader.ReadBytes(16); this.fieldpad3 = binaryReader.ReadBytes(16); this.EasyMajorUpgrade = binaryReader.ReadSingle(); this.NormalMajorUpgrade = binaryReader.ReadSingle(); this.HardMajorUpgrade = binaryReader.ReadSingle(); this.ImpossMajorUpgrade = binaryReader.ReadSingle(); this.EasyMajorUpgrade0 = binaryReader.ReadSingle(); this.NormalMajorUpgrade0 = binaryReader.ReadSingle(); this.HardMajorUpgrade0 = binaryReader.ReadSingle(); this.ImpossMajorUpgrade0 = binaryReader.ReadSingle(); this.EasyMajorUpgrade1 = binaryReader.ReadSingle(); this.NormalMajorUpgrade1 = binaryReader.ReadSingle(); this.HardMajorUpgrade1 = binaryReader.ReadSingle(); this.ImpossMajorUpgrade1 = binaryReader.ReadSingle(); this.EasyPlayerVehicleRamChance = binaryReader.ReadSingle(); this.NormalPlayerVehicleRamChance = binaryReader.ReadSingle(); this.HardPlayerVehicleRamChance = binaryReader.ReadSingle(); this.ImpossPlayerVehicleRamChance = binaryReader.ReadSingle(); this.fieldpad4 = binaryReader.ReadBytes(16); this.fieldpad5 = binaryReader.ReadBytes(16); this.fieldpad6 = binaryReader.ReadBytes(16); this.fieldpad7 = binaryReader.ReadBytes(84); return(pointerQueue); }
static StackObject *TryGetValue_0(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, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Collections.Generic.Queue <System.Object> @value = (System.Collections.Generic.Queue <System.Object>) typeof(System.Collections.Generic.Queue <System.Object>).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Type @key = (System.Type) typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.Collections.Generic.Dictionary <System.Type, System.Collections.Generic.Queue <System.Object> > instance_of_this_method = (System.Collections.Generic.Dictionary <System.Type, System.Collections.Generic.Queue <System.Object> >) typeof(System.Collections.Generic.Dictionary <System.Type, System.Collections.Generic.Queue <System.Object> >).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); var result_of_this_method = instance_of_this_method.TryGetValue(@key, out @value); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.StackObjectReference: { var ___dst = ptr_of_this_method->ValueLong; object ___obj = @value; if (___dst->ObjectType >= ObjectTypes.Object) { if (___obj is CrossBindingAdaptorType) { ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; } __mStack[___dst->Value] = ___obj; } else { ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); } } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @value; } else { var ___type = __domain.GetType(___obj.GetType()) as CLRType; ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @value); } } break; case ObjectTypes.StaticFieldReference: { var ___type = __domain.GetType(ptr_of_this_method->Value); if (___type is ILType) { ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @value; } else { ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @value); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Collections.Generic.Queue <System.Object>[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = @value; } break; } __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); __intp.Free(ptr_of_this_method); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
protected override void TakeArguments(System.Collections.Generic.Queue <string> queue) { FileName = queue.Dequeue(); }
public override void ReadInstances(System.IO.BinaryReader binaryReader, System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue) { base.ReadInstances(binaryReader, pointerQueue); this.Permutations = base.ReadBlockArrayData <DecoratorPermutationsBlock>(binaryReader, pointerQueue.Dequeue()); }
IdentifyAllPackages( bool allowDuplicates = false, bool enforceBamAssemblyVersions = true) { var packageRepos = new System.Collections.Generic.Queue<string>(); foreach (var repo in Graph.Instance.PackageRepositories) { if (packageRepos.Contains(repo)) { continue; } packageRepos.Enqueue(repo); } var masterDefinitionFile = GetMasterPackage(enforceBamAssemblyVersions: enforceBamAssemblyVersions); foreach (var repo in masterDefinitionFile.PackageRepositories) { if (packageRepos.Contains(repo)) { continue; } packageRepos.Enqueue(repo); } // read the definition files of any package found in the package roots var candidatePackageDefinitions = new Array<PackageDefinition>(); candidatePackageDefinitions.Add(masterDefinitionFile); while (packageRepos.Count > 0) { var repo = packageRepos.Dequeue(); if (!System.IO.Directory.Exists(repo)) { throw new Exception("Package repository directory {0} does not exist", repo); } var candidatePackageDirs = System.IO.Directory.GetDirectories(repo, BamSubFolder, System.IO.SearchOption.AllDirectories); Graph.Instance.PackageRepositories.Add(repo); foreach (var bamDir in candidatePackageDirs) { var packageDir = System.IO.Path.GetDirectoryName(bamDir); var packageDefinitionPath = GetPackageDefinitionPathname(packageDir); // ignore any duplicates (can be found due to nested repositories) if (null != candidatePackageDefinitions.Where(item => item.XMLFilename == packageDefinitionPath).FirstOrDefault()) { continue; } var definitionFile = new PackageDefinition(packageDefinitionPath, !Graph.Instance.ForceDefinitionFileUpdate); definitionFile.Read(true, enforceBamAssemblyVersions); candidatePackageDefinitions.Add(definitionFile); foreach (var newRepo in definitionFile.PackageRepositories) { if (Graph.Instance.PackageRepositories.Contains(newRepo)) { continue; } packageRepos.Enqueue(newRepo); } } } // defaults come from // - the master definition file // - command line args (these trump the mdf) // and only requires resolving when referenced var packageDefinitions = new Array<PackageDefinition>(); PackageDefinition.ResolveDependencies(masterDefinitionFile, packageDefinitions, candidatePackageDefinitions); // now resolve any duplicate names using defaults // unless duplicates are allowed var duplicatePackageNames = packageDefinitions.GroupBy(item => item.Name).Where(item => item.Count() > 1).Select(item => item.Key); if ((duplicatePackageNames.Count() > 0) && !allowDuplicates) { var versionSpeciferArgs = new Options.PackageDefaultVersion(); var packageVersionSpecifiers = CommandLineProcessor.Evaluate(versionSpeciferArgs); var toRemove = new Array<PackageDefinition>(); foreach (var dupName in duplicatePackageNames) { var duplicates = packageDefinitions.Where(item => item.Name == dupName); PackageDefinition resolvedDuplicate = null; // command line specifications take precedence to resolve a duplicate foreach (var specifier in packageVersionSpecifiers) { if (!specifier.Contains(dupName)) { continue; } foreach (var dupPackage in duplicates) { if (specifier[1] == dupPackage.Version) { resolvedDuplicate = dupPackage; break; } } if (resolvedDuplicate != null) { break; } var noMatchMessage = new System.Text.StringBuilder(); noMatchMessage.AppendFormat("Command line version specified, {0}, could not resolve to one of the available versions of package {1}:", specifier[1], duplicates.First().Name); noMatchMessage.AppendLine(); foreach (var dup in duplicates) { noMatchMessage.AppendFormat("\t{0}", dup.Version); noMatchMessage.AppendLine(); } throw new Exception(noMatchMessage.ToString()); } if (resolvedDuplicate != null) { toRemove.AddRange(packageDefinitions.Where(item => (item.Name == dupName) && (item != resolvedDuplicate))); continue; } // now look at the master dependency file, for any 'default' specifications var masterDependency = masterDefinitionFile.Dependents.Where(item => item.Item1 == dupName && item.Item3.HasValue && item.Item3.Value).FirstOrDefault(); if (null != masterDependency) { toRemove.AddRange(packageDefinitions.Where(item => (item.Name == dupName) && (item.Version != masterDependency.Item2))); continue; } var resolveErrorMessage = new System.Text.StringBuilder(); resolveErrorMessage.AppendFormat("Unable to resolve to a single version of package {0}. Use --{0}.version=<version> to resolve. Available versions of the package are:", duplicates.First().Name); resolveErrorMessage.AppendLine(); foreach (var dup in duplicates) { resolveErrorMessage.AppendFormat("\t{0}", dup.Version); resolveErrorMessage.AppendLine(); } throw new Exception(resolveErrorMessage.ToString()); } packageDefinitions.RemoveAll(toRemove); } Graph.Instance.SetPackageDefinitions(packageDefinitions); }
public ThreadSocketHandler(int port , Regulus.Game.ICore core) { _Port = port; _Core = core; _Sockets = new Queue<System.Net.Sockets.Socket>(); _Socket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp); _Peers = new Utility.Updater(); _FPS = new Utility.FPSCounter(); }
public unsafe static void FillStencilFromPoint(ImageSurface surface, IBitVector2D stencil, Point start, int tolerance, out Rectangle boundingBox, Gdk.Region limitRegion, bool limitToSelection) { ColorBgra cmp = surface.GetColorBgraUnchecked(start.X, start.Y); int top = int.MaxValue; int bottom = int.MinValue; int left = int.MaxValue; int right = int.MinValue; Gdk.Rectangle[] scans; stencil.Clear(false); if (limitToSelection) { using (Gdk.Region excluded = Gdk.Region.Rectangle(new Gdk.Rectangle(0, 0, stencil.Width, stencil.Height))) { excluded.Xor(limitRegion); scans = excluded.GetRectangles(); } } else { scans = new Gdk.Rectangle[0]; } foreach (Gdk.Rectangle rect in scans) { stencil.Set(rect, true); } var queue = new System.Collections.Generic.Queue <Point> (16); queue.Enqueue(start); while (queue.Count > 0) { Point pt = queue.Dequeue(); ColorBgra *rowPtr = surface.GetRowAddressUnchecked(pt.Y); int localLeft = pt.X - 1; int localRight = pt.X; while (localLeft >= 0 && !stencil.GetUnchecked(localLeft, pt.Y) && CheckColor(cmp, rowPtr[localLeft], tolerance)) { stencil.SetUnchecked(localLeft, pt.Y, true); --localLeft; } int surfaceWidth = surface.Width; while (localRight < surfaceWidth && !stencil.GetUnchecked(localRight, pt.Y) && CheckColor(cmp, rowPtr[localRight], tolerance)) { stencil.SetUnchecked(localRight, pt.Y, true); ++localRight; } ++localLeft; --localRight; Action <int> checkRow = (row) => { int sleft = localLeft; int sright = localLeft; ColorBgra *otherRowPtr = surface.GetRowAddressUnchecked(row); for (int sx = localLeft; sx <= localRight; ++sx) { if (!stencil.GetUnchecked(sx, row) && CheckColor(cmp, otherRowPtr[sx], tolerance)) { ++sright; } else { if (sright - sleft > 0) { queue.Enqueue(new Point(sleft, row)); } ++sright; sleft = sright; } } if (sright - sleft > 0) { queue.Enqueue(new Point(sleft, row)); } }; if (pt.Y > 0) { checkRow(pt.Y - 1); } if (pt.Y < surface.Height - 1) { checkRow(pt.Y + 1); } if (localLeft < left) { left = localLeft; } if (localRight > right) { right = localRight; } if (pt.Y < top) { top = pt.Y; } if (pt.Y > bottom) { bottom = pt.Y; } } foreach (Gdk.Rectangle rect in scans) { stencil.Set(rect, false); } boundingBox = new Rectangle(left, top, right - left + 1, bottom - top + 1); }
public override void ReadInstances(System.IO.BinaryReader binaryReader, System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue) { base.ReadInstances(binaryReader, pointerQueue); this.RowCells = base.ReadBlockArrayData <TableViewListItemReferenceBlock>(binaryReader, pointerQueue.Dequeue()); }
ProcessModule( System.Collections.Generic.Dictionary <Module, int> map, System.Collections.Generic.Queue <Module> toProcess, Module module, int rankIndex) { if (module.Tool != null) { if (null == module.Settings) { module.Requires(module.Tool); var child = module as IChildModule; if ((null == child) || (null == child.Parent)) { // children inherit the settings from their parents module.UsePublicPatches(module.Tool); } try { module.Settings = (module.Tool as ITool).CreateDefaultSettings(module); } catch (System.TypeInitializationException ex) { throw ex.InnerException; } } } if ((0 == module.Dependents.Count) && (0 == module.Requirements.Count)) { return; } if (module is IModuleGroup) { var children = module.Children; this.ApplyGroupDependenciesToChildren(module, children, module.Dependents); this.ApplyGroupRequirementsToChildren(module, children, module.Requirements); } var nextRankIndex = rankIndex + 1; foreach (var dep in module.Dependents) { if (map.ContainsKey(dep)) { if (map[dep] < nextRankIndex) { MoveModuleRankTo(map, dep, nextRankIndex); } } else { SetModuleRank(map, dep, nextRankIndex); toProcess.Enqueue(dep); } } foreach (var dep in module.Requirements) { if (map.ContainsKey(dep)) { if (map[dep] < nextRankIndex) { MoveModuleRankTo(map, dep, nextRankIndex); } } else { SetModuleRank(map, dep, nextRankIndex); toProcess.Enqueue(dep); } } }
public override void ReadInstances(System.IO.BinaryReader binaryReader, System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue) { base.ReadInstances(binaryReader, pointerQueue); this.Components = base.ReadBlockArrayData <PlatformSoundEffectTemplateComponentBlock>(binaryReader, pointerQueue.Dequeue()); }
public override void ReadInstances(System.IO.BinaryReader binaryReader, System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue) { base.ReadInstances(binaryReader, pointerQueue); this.GlobalVertexShaders = base.ReadBlockArrayData <VertexShaderReferenceBlock>(binaryReader, pointerQueue.Dequeue()); }
public bool SendMessagesAsync(Windows.Foundation.AsyncActionCompletedHandler handler) { int count = 0; lock (thisLock) { count = queue.Count; } if (count > 0) { Func<Task> action = async () => { System.Collections.Generic.Queue<Message> q = new System.Collections.Generic.Queue<Message>(); lock (thisLock) { int i = 0; foreach (DataPoint p in queue) { string s = HeartBeatText(p.t); var telemetryDataPoint = new { ID = Access.DeviceID, TIME = p.time, MSG = s, CC = p.cc, ASDF = p.asdf, PEAK = p.peak, MAX0 = p.max0, MAX1 = p.max1, AVE0 = p.ave0, AVE1 = p.ave1, AVE = p.ave, BEAT = p.beat, NOAUDIO = p.noAudio, AUDIO = p.audio }; var messageString = JsonConvert.SerializeObject(telemetryDataPoint); var message = new Message(Encoding.ASCII.GetBytes(messageString)); q.Enqueue(message); if (++i == MAX_BATCH) break; } msgCount = Math.Min(queue.Count, MAX_BATCH); } var auth = new DeviceAuthenticationWithRegistrySymmetricKey(Access.DeviceID, Access.DeviceKey); DeviceClient deviceClient = DeviceClient.Create(Access.IoTHubUri, auth, TransportType.Http1); await deviceClient.OpenAsync(); IAsyncAction a = deviceClient.SendEventBatchAsync(q); a.Completed = handler; await a; await deviceClient.CloseAsync(); }; task = Task.Factory.StartNew(action); return true; } else return false; }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.SectionOffset = binaryReader.ReadInt16(); return(pointerQueue); }
/// <summary> /// 取得Request內content的數據並寫入指定路徑 /// </summary> /// <param name="request"></param> /// <param name="filePath"></param> /// <returns></returns> private bool SaveRequestBodyAsFile(HttpRequest request, string filePath) { bool result = false; System.Collections.Generic.Queue<byte> buffer = null; System.IO.Stream requestStream = null; byte[] data = null; int readByte = -1; //檢查檔案路徑 if (!CheckFilePath(filePath)) { log.Error(m => { m.Invoke("存檔路徑不存在:" + filePath); }); return false; } //開始寫檔 log.Debug(m => { m.Invoke("開始寫檔: " + filePath); }); using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write)) { buffer = new System.Collections.Generic.Queue<byte>(); requestStream = request.InputStream; try { //read data while ((readByte = requestStream.ReadByte()) > -1) { buffer.Enqueue((byte)readByte); } } catch (Exception ex) { log.Error(m => { m.Invoke("Request InputStream Read Error:" + ex.Message + "\n " + ex.StackTrace); }); } finally { requestStream.Close(); } //cast to byte array data = buffer.ToArray(); //write byte array in file fs.Write(data, 0, data.Length); fs.Flush(); result = true; } return result; }
public override void ReadInstances(System.IO.BinaryReader binaryReader, System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue) { base.ReadInstances(binaryReader, pointerQueue); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.ObjectID.ReadFields(binaryReader))); return(pointerQueue); }
string bfs(int startIdx) { var que = new System.Collections.Generic.Queue<int>(); que.Enqueue(startIdx); var sb = new StringBuilder(); while (que.Count > 0) { int i = que.Dequeue(); sb.AppendFormat("{0} ", a[i]); int leftIdx = 2 * i + 1, rightIdx = 2 * i + 2; if (leftIdx < a.Length) que.Enqueue(leftIdx); if (rightIdx < a.Length) que.Enqueue(rightIdx); } return sb.ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="MessagingNetworkAdapter"/> class. /// </summary> /// <param name="netClient">The net client.</param> public MessagingNetworkAdapter(NetworkClient netClient) { this.netClient = netClient; queue = new System.Collections.Generic.Queue<Message>(); queueMutex = new System.Threading.Mutex(); }
void _FrameworkUpdate() { Logger.Info("_FrameworkUpdate begin."); Regulus.Utility.Poller<SoulProvider> providers = new Regulus.Utility.Poller<SoulProvider>(); while (_Framework != null && _Framework.Update() == true && Running) { System.Threading.Thread.Sleep(0); Queue<SoulProvider> q = null; lock (_SynObject) { if (_NewProviderQueue.Count > 0) { q = _NewProviderQueue; _NewProviderQueue = new Queue<SoulProvider>(); } } if (q != null) { foreach (var provider in q) { providers.Add(provider); provider.BreakEvent += () => { providers.Remove(p => p == provider); }; _Framework.ObtainController(provider); } } _UpdateProvider(providers.UpdateSet()); } Logger.Info("_FrameworkUpdate end."); }
public void CopyTo (System.IO.Stream destination, int minAwaits, int maxAwaits) { System.Collections.Generic.Queue<IAsyncResult> ars = new System.Collections.Generic.Queue<IAsyncResult> (); //todo: add automatic unit size tuning support int unit = 16384; long l; try { l = Length; } catch { l = long.MaxValue; } try { while (l != 0) { int lt = (int)Math.Min (unit, l); if (l != long.MaxValue) l -= lt; byte[] bytes = new byte[lt]; ars.Enqueue (BeginRead (bytes, 0, lt, (ar) => { int readbytes = EndRead (ar); byte[] buf = (byte[])ar.AsyncState; destination.BeginWrite (buf, 0, readbytes, (dar) => { destination.EndWrite (dar); }, null); }, bytes)); if (ars.Count > maxAwaits) { while (ars.Count > minAwaits) ars.Dequeue ().AsyncWaitHandle.WaitOne (); } } } catch { //unknown length if (l != long.MaxValue) throw; } while (ars.Count != 0) ars.Dequeue ().AsyncWaitHandle.WaitOne (); destination.Flush (); }
/// <summary> /// This method assumes that the parameter handed over is to be filled with SAEA objects for /// sending ansychronously to a remote peer. Each created SAEA object is gets the /// SocketOptions.None flage and the completed event is attached the OnSendingComplete /// method of this class. The buffer and remote endpoint will be assigned on sending data. /// </summary> /// <param name="SAEAQueue">the queue of objects to be filled.</param> private void fillWithSendingSAEAobjects(ref System.Collections.Generic.Queue<SocketAsyncEventArgs> SAEAQueue) { SAEAQueue = new System.Collections.Generic.Queue<SocketAsyncEventArgs>(IOObjectCount); for (int i=0; i < IOObjectCount; ++i) { var SAEAobject = new SocketAsyncEventArgs(); SAEAobject.SocketFlags = SocketFlags.None; SAEAobject.Completed += OnSendingMessageComplete; SAEAQueue.Enqueue(SAEAobject); } }
// Use this for initialization void Start() { Enemies[0] = enemy1; Enemies[1] = enemy2; Enemies[2] = enemy3; enemiesCount = enemiesCountFromUnity; randomNumer = new System.Random(); EnemiesQueue = new System.Collections.Generic.Queue<GameObject>(); Physics2D.IgnoreLayerCollision(11, 11); aTimer = new System.Timers.Timer(); aTimer.Interval = randomNumer.Next() % maxSpawnTime + minSpawnTime; aTimer.Elapsed += OnTimedEvent; System.GC.KeepAlive(aTimer); UnityEngine.Random.Range(0, enemiesCount); }
static public void CalcTest() { Calc myCalc = new Calc(); System.Console.WriteLine("\n------------ Calc Phase 1: Explicit Calls ---------------\n"); myCalc.set(3); myCalc.add(2); myCalc.sub(8); myCalc.mult(2); myCalc.sub(5); myCalc.add(4); myCalc.add(22); myCalc.sub(4); myCalc.mult(2); myCalc.sub(5); myCalc.set(11); myCalc.add(2); myCalc.sub(7); myCalc.mult(3); myCalc.sub(5); System.Console.WriteLine("\n------------ Calc Phase 2: Data Driven ---------------\n"); Calc_Data data; // myCalc.set(3); data.type = Calc_Type.CALC_SET; data.value = 3; myCalc.doWork(data); // myCalc.add(2); data.type = Calc_Type.CALC_ADD; data.value = 2; myCalc.doWork(data); // myCalc.sub(8); data.type = Calc_Type.CALC_SUB; data.value = 8; myCalc.doWork(data); // myCalc.mult(2); data.type = Calc_Type.CALC_MULT; data.value = 2; myCalc.doWork(data); // myCalc.sub(5); data.type = Calc_Type.CALC_SUB; data.value = 5; myCalc.doWork(data); // myCalc.add(4); data.type = Calc_Type.CALC_ADD; data.value = 4; myCalc.doWork(data); // myCalc.add(22); data.type = Calc_Type.CALC_ADD; data.value = 22; myCalc.doWork(data); // myCalc.sub(4); data.type = Calc_Type.CALC_SUB; data.value = 4; myCalc.doWork(data); // myCalc.mult(2); data.type = Calc_Type.CALC_MULT; data.value = 2; myCalc.doWork(data); // myCalc.sub(5); data.type = Calc_Type.CALC_SUB; data.value = 5; myCalc.doWork(data); // myCalc.set(11); data.type = Calc_Type.CALC_SET; data.value = 11; myCalc.doWork(data); // myCalc.add(2); data.type = Calc_Type.CALC_ADD; data.value = 2; myCalc.doWork(data); // myCalc.sub(7); data.type = Calc_Type.CALC_SUB; data.value = 7; myCalc.doWork(data); // myCalc.mult(3); data.type = Calc_Type.CALC_MULT; data.value = 3; myCalc.doWork(data); // myCalc.sub(5); data.type = Calc_Type.CALC_SUB; data.value = 5; myCalc.doWork(data); System.Console.WriteLine("\n------------ Calc Phase 3: Queued Data Driven ---------------\n"); // Creates and initializes a new Queue. System.Collections.Generic.Queue <Calc_Data> myQ = new System.Collections.Generic.Queue <Calc_Data>(); // myCalc.set(3); data.type = Calc_Type.CALC_SET; data.value = 3; myQ.Enqueue(data); // myCalc.add(2); data.type = Calc_Type.CALC_ADD; data.value = 2; myQ.Enqueue(data); // myCalc.sub(8); data.type = Calc_Type.CALC_SUB; data.value = 8; myQ.Enqueue(data); // myCalc.mult(2); data.type = Calc_Type.CALC_MULT; data.value = 2; myQ.Enqueue(data); // myCalc.sub(5); data.type = Calc_Type.CALC_SUB; data.value = 5; myQ.Enqueue(data); // myCalc.add(4); data.type = Calc_Type.CALC_ADD; data.value = 4; myQ.Enqueue(data); // myCalc.add(22); data.type = Calc_Type.CALC_ADD; data.value = 22; myQ.Enqueue(data); // myCalc.sub(4); data.type = Calc_Type.CALC_SUB; data.value = 4; myQ.Enqueue(data); // myCalc.mult(2); data.type = Calc_Type.CALC_MULT; data.value = 2; myQ.Enqueue(data); // myCalc.sub(5); data.type = Calc_Type.CALC_SUB; data.value = 5; myQ.Enqueue(data); // myCalc.set(11); data.type = Calc_Type.CALC_SET; data.value = 11; myQ.Enqueue(data); // myCalc.add(2); data.type = Calc_Type.CALC_ADD; data.value = 2; myQ.Enqueue(data); // myCalc.sub(7); data.type = Calc_Type.CALC_SUB; data.value = 7; myQ.Enqueue(data); // myCalc.mult(3); data.type = Calc_Type.CALC_MULT; data.value = 3; myQ.Enqueue(data); // myCalc.sub(5); data.type = Calc_Type.CALC_SUB; data.value = 5; myQ.Enqueue(data); // Now the queue is NOW filled // print the contents int count = myQ.Count; for (int i = 0; i < count; i++) { Calc_Data tmpData = myQ.Dequeue(); myCalc.doWork(tmpData); } }
static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref System.Collections.Generic.Queue <ILRuntime.Runtime.Intepreter.ILTypeInstance> .Enumerator instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Collections.Generic.Queue <ILRuntime.Runtime.Intepreter.ILTypeInstance> .Enumerator[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
private static async Task SaveQueueInternalAsync(IotHubClient client) { try { System.Collections.Generic.Queue<DataPoint> tmp = null; lock (client.thisLock) { tmp = new System.Collections.Generic.Queue<DataPoint>(client.queue); } StorageFolder storageFolder = ApplicationData.Current.LocalFolder; StorageFile file = await storageFolder.CreateFileAsync(FILE_NAME, CreationCollisionOption.ReplaceExisting); var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); using (var outputStream = stream.GetOutputStreamAt(0)) { using (var dataWriter = new DataWriter(outputStream)) { dataWriter.WriteInt32(tmp.Count); foreach (var item in tmp) { item.Write(dataWriter); } await dataWriter.StoreAsync(); await outputStream.FlushAsync(); } } stream.Dispose(); } catch (Exception) { } }
// Use this for initialization void Start() { player= GameObject.Find ("Player"); firstLight = GameObject.Find("FirstLight"); FirstLight.OnDisturb += Init; //We enqueu all object that will be instantiated InitObjectsToPlace(); objectsToDestroy = new System.Collections.Generic.Queue<ObjectDestroy>(); started = false; }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.GuidedAngularVelocity = binaryReader.ReadSingle(); return(pointerQueue); }
public override void Evaluate() { this.ReasonToExecute = null; var graph = Bam.Core.Graph.Instance; var factory = graph.MetaData as System.Threading.Tasks.TaskFactory; this.EvaluationTask = factory.StartNew(() => { // does the object file exist? var objectFilePath = this.GeneratedPaths[Key].Parse(); if (!System.IO.File.Exists(objectFilePath)) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.FileDoesNotExist(this.GeneratedPaths[Key]); return; } var objectFileWriteTime = System.IO.File.GetLastWriteTime(objectFilePath); // has the source file been evaluated to be rebuilt? if ((this as IRequiresSourceModule).Source.ReasonToExecute != null) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(this.GeneratedPaths[Key], this.InputPath); return; } // is the source file newer than the object file? var sourcePath = this.InputPath.Parse(); var sourceWriteTime = System.IO.File.GetLastWriteTime(sourcePath); if (sourceWriteTime > objectFileWriteTime) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(this.GeneratedPaths[Key], this.InputPath); return; } if (this is WinResource) { return; } // are there any headers as explicit dependencies (procedurally generated most likely), which are newer? var explicitHeadersUpdated = new Bam.Core.StringArray(); foreach (var dep in this.Dependents) { if (!(dep is HeaderFile)) { continue; } if (null == dep.ReasonToExecute) { continue; } explicitHeadersUpdated.AddUnique((dep as HeaderFile).InputPath.Parse()); } var includeSearchPaths = (this.Settings as C.ICommonCompilerSettings).IncludePaths; var filesToSearch = new System.Collections.Generic.Queue<string>(); filesToSearch.Enqueue(sourcePath); var headerPathsFound = new Bam.Core.StringArray(); while (filesToSearch.Count > 0) { var fileToSearch = filesToSearch.Dequeue(); string fileContents = null; using (System.IO.TextReader reader = new System.IO.StreamReader(fileToSearch)) { fileContents = reader.ReadToEnd(); } // never know if developers are consistent with #include "header.h" or #include <header.h> so look for both var matches = System.Text.RegularExpressions.Regex.Matches( fileContents, "^\\s*#include [\"<]([^\\s]*)[\">]", System.Text.RegularExpressions.RegexOptions.Multiline); if (0 == matches.Count) { // no #includes return; } foreach (System.Text.RegularExpressions.Match match in matches) { var headerFile = match.Groups[1].Value; bool exists = false; // search for the file on the include paths the compiler uses foreach (var includePath in includeSearchPaths) { try { var potentialPath = System.IO.Path.Combine(includePath.Parse(), headerFile); if (!System.IO.File.Exists(potentialPath)) { continue; } potentialPath = System.IO.Path.GetFullPath(potentialPath); var headerWriteTime = System.IO.File.GetLastWriteTime(potentialPath); // early out - header is newer than generated object file if (headerWriteTime > objectFileWriteTime) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer( this.GeneratedPaths[Key], Bam.Core.TokenizedString.CreateVerbatim(potentialPath)); return; } if (explicitHeadersUpdated.Contains(potentialPath)) { // found #included header in list of explicitly dependent headers that have been updated this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer( this.GeneratedPaths[Key], Bam.Core.TokenizedString.CreateVerbatim(potentialPath)); return; } if (!headerPathsFound.Contains(potentialPath)) { headerPathsFound.Add(potentialPath); filesToSearch.Enqueue(potentialPath); } exists = true; break; } catch (System.Exception ex) { Bam.Core.Log.MessageAll("IncludeDependency Exception: Cannot locate '{0}' on '{1}' due to {2}", headerFile, includePath, ex.Message); } } if (!exists) { #if false Bam.Core.Log.DebugMessage("***** Could not locate '{0}' on any include search path, included from {1}:\n{2}", match.Groups[1], fileToSearch, entry.includePaths.ToString('\n')); #endif } } } return; }); }
void _Run(string[] command_paraments) { System.Collections.Generic.Queue<string> cmdArgs = new System.Collections.Generic.Queue<string>(command_paraments); if (cmdArgs.Count > 0) { var cmd = cmdArgs.Dequeue(); int runCount = Command.Run(cmd, cmdArgs.ToArray()); if (runCount != 0) { _Viewer.WriteLine("執行完畢."); } else { _Viewer.WriteLine("無此命令."); } } }
/// <summary> /// This method assumes that the parameter handed over is to be filled with SAEA objects for /// reading ansychronously from the socket. Each created SAEA object is assigned a buffer of /// 512Bytes in size and gets the localEndPoint of the underlying socket as its /// RemoteEndPoint. The OnReadingComplete method is attached to the Completed event. /// </summary> /// <param name="SAEAQueue">the queue to be filled</param> private void fillWithReadingSAEAobjects(ref System.Collections.Generic.Queue<SocketAsyncEventArgs> SAEAQueue) { SAEAQueue = new System.Collections.Generic.Queue<SocketAsyncEventArgs>(IOObjectCount); for (int i=0; i < IOObjectCount; ++i) { var SAEAobject = new SocketAsyncEventArgs(); SAEAobject.RemoteEndPoint = _udpSocket.LocalEndPoint; SAEAobject.SocketFlags = SocketFlags.None; SAEAobject.SetBuffer(new byte[512], 0, 512); SAEAobject.Completed += OnReadingMessageComplete; SAEAQueue.Enqueue(SAEAobject); } }
private PathData() { primPath = new System.Collections.Generic.Queue<Transform>(); darkPrimPath = new System.Collections.Generic.Queue<Transform>(); }
public void ReferenceQueueStory() { var que = new System.Collections.Generic.Queue<string>(); que.Enqueue("foo"); que.Count.ShouldEqual(1); que.Peek().ShouldEqual("foo"); que.Dequeue().ShouldEqual("foo"); que.Count.ShouldEqual(0); que.Enqueue("foo"); que.Enqueue("bar"); que.Count.ShouldEqual(2); que.Peek().ShouldEqual("foo"); que.Dequeue().ShouldEqual("foo"); que.Dequeue().ShouldEqual("bar"); que.Count.ShouldEqual(0); que.Enqueue("foo"); que.Enqueue("bar"); que.Enqueue("baz"); que.Clear(); que.ShouldBeEmpty(); }
static public void FSMTest() { System.Console.WriteLine("\n------------ FSM Phase 1: Explicit Calls ---------------\n"); FSM myFSM = new FSM(); myFSM.advance(0); //a myFSM.advance(1); //b myFSM.advance(0); //e myFSM.advance(1); //a myFSM.advance(1); //b myFSM.advance(0); //e myFSM.advance(0); //c myFSM.advance(1); //e myFSM.advance(1); //a myFSM.advance(1); //b myFSM.advance(1); //c myFSM.advance(0); //d myFSM.advance(0); //d myFSM.advance(1); //b myFSM.set(FSM_StateEnum.STATE_C); myFSM.advance(0); myFSM.advance(0); myFSM.advance(0); myFSM.set(FSM_StateEnum.STATE_C); myFSM.advance(1); myFSM.advance(0); myFSM.advance(0); myFSM.set(FSM_StateEnum.STATE_B); myFSM.advance(1); myFSM.advance(1); myFSM.advance(0); myFSM.set(FSM_StateEnum.STATE_D); myFSM.advance(1); myFSM.advance(0); myFSM.advance(1); System.Console.WriteLine("\n------------ FSM Phase 2: Data Driven ---------------\n"); FSM_Data myData; myData.input = 0; myData.state = FSM_StateEnum.STATE_A; myData.type = FSM_Type.FSM_ADV; //myFSM.advance(0); //a myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(1); //b myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(0); //e myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(1); //a myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(1); //b myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(0); //e myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(0); //c myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(1); //e myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(1); //a myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(1); //b myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(1); //c myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(0); //d myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(0); //d myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(1); //b myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.set(FSM_StateEnum.STATE_C); myData.type = FSM_Type.FSM_SET; myData.state = FSM_StateEnum.STATE_C; myFSM.doWork(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.set(FSM_StateEnum.STATE_C); myData.type = FSM_Type.FSM_SET; myData.state = FSM_StateEnum.STATE_C; myFSM.doWork(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.set(FSM_StateEnum.STATE_B); myData.type = FSM_Type.FSM_SET; myData.state = FSM_StateEnum.STATE_B; myFSM.doWork(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.set(FSM_StateEnum.STATE_D); myData.type = FSM_Type.FSM_SET; myData.state = FSM_StateEnum.STATE_D; myFSM.doWork(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myFSM.doWork(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myFSM.doWork(myData); System.Console.WriteLine("\n------------ FSM Phase 3: Queued Data Driven ---------------\n"); System.Collections.Generic.Queue <FSM_Data> myQ_FSM = new System.Collections.Generic.Queue <FSM_Data>(); myData.input = 0; myData.state = FSM_StateEnum.STATE_A; myData.type = FSM_Type.FSM_ADV; //myFSM.advance(0); //a myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(1); //b myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(0); //e myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(1); //a myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(1); //b myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(0); //e myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(0); //c myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(1); //e myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(1); //a myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(1); //b myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(1); //c myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(0); //d myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(0); //d myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(1); //b myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.set(FSM_StateEnum.STATE_C); myData.type = FSM_Type.FSM_SET; myData.state = FSM_StateEnum.STATE_C; myQ_FSM.Enqueue(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.set(FSM_StateEnum.STATE_C); myData.type = FSM_Type.FSM_SET; myData.state = FSM_StateEnum.STATE_C; myQ_FSM.Enqueue(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.set(FSM_StateEnum.STATE_B); myData.type = FSM_Type.FSM_SET; myData.state = FSM_StateEnum.STATE_B; myQ_FSM.Enqueue(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.set(FSM_StateEnum.STATE_D); myData.type = FSM_Type.FSM_SET; myData.state = FSM_StateEnum.STATE_D; myQ_FSM.Enqueue(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); //myFSM.advance(0); myData.type = FSM_Type.FSM_ADV; myData.input = 0; myQ_FSM.Enqueue(myData); //myFSM.advance(1); myData.type = FSM_Type.FSM_ADV; myData.input = 1; myQ_FSM.Enqueue(myData); // Now the queue is NOW filled // print the contents int count = myQ_FSM.Count; for (int i = 0; i < count; i++) { FSM_Data tmpData = myQ_FSM.Dequeue(); myFSM.doWork(tmpData); } }