public AStarPathfinder(ITileMap map, int maxSearchDistance, bool allowDiagMovement, IAStarHeuristic heuristic) { m_Closed = new List<AStarNode>(); m_Open = new OrderedList<AStarNode>(); m_Heuristic = heuristic; m_Map = map; m_MaxSearchDistance = maxSearchDistance; m_AllowDiagMovement = allowDiagMovement; m_Nodes = new AStarMatrix(map.Width); }
public void Remove_removes_items() { var s = "a string"; var list = new OrderedList<string>(); list.Add(s); Assert.IsTrue(list.Contains(s)); Assert.IsTrue(list.Remove(s)); Assert.IsFalse(list.Contains(s)); }
public void Changing_the_SortFunc_property_changes_the_sort_order() { var ol = new OrderedList<string>(x => x); ol.Add("Cheese"); ol.Add("Acorn"); ol.Add("Blah"); CollectionAssert.AreEqual(new string[] { "Acorn", "Blah", "Cheese" }, ol); ol.SortFunc = x => x.Last().ToString(); CollectionAssert.AreEqual(new string[] { "Cheese", "Blah", "Acorn" }, ol); }
public void List_is_sorted_by_sort_function() { var ol = new OrderedList<int>(); ol.SortFunc = (x) => x; ol.Add(4); ol.Add(2); ol.Add(3); ol.Add(1); var expected = new int[] { 1, 2, 3, 4 }; CollectionAssert.AreEqual(expected, ol); }
public void Add_ToCollection() { var task = new Task("(B) Add_ToCollection +test @task"); var tl = new TaskList(Data.TestDataPath); var tasks = new OrderedList<Task>(tl.Tasks); tasks.Add(task); tl.Add(task); var newTasks = tl.Tasks.ToList(); Assert.AreEqual(tasks.Count, newTasks.Count); for (int i = 0; i < tasks.Count; i++) Assert.AreEqual(tasks[i].ToString(), newTasks[i].ToString()); }
public void EndOrderedList(OrderedList list) { indent -= IndentBy; }
public void Visit(OrderedList orderedList) { var uiElements = BuildChildUIList(orderedList); var inlineContainer = new InlineUIContainer(); inlineContainer.Child = new MarkdownList(true, uiElements); MaybeSplitForParagraph(); _currentParagraph.Inlines.Add(inlineContainer); }
protected override void SetSelectionWithUndo(string description, OrderedList <T> newSelection, T newPrimarySelection) { this.NotifyItemsChanged(this.InternalSelection, newSelection); this.SetSelectionWithUndo(description, newSelection, newPrimarySelection); }
/// <summary> /// Initializes a new instance of the <see cref="RuleFlagProcessor"/> class. /// </summary> public RuleFlagProcessor() { _flags = new OrderedList<IRuleFlag>(Comparison, 5); }
public OrderByBuilderControl() { InitializeComponent(); Controller = new OrderedList <OrderByFilterControl>(ucFilters); Controller.Changed += (sender, args) => Changed?.Invoke(sender, args); }
public void OnInitialise(InitialiseMessage msg) { // Initialise scene manager Console.WriteLine("Initialising scene manager..."); // Initialise messages queuemsg = new PopulateRenderQueue(); queuemsg.SceneManager = this; cameramsg = new PopulateCameraList(); cameramsg.Cameras = new OrderedList<Camera>(new CameraComparer()); cameramsg.ShadowCasters = new HashSet<ShadowCaster>(); lightmsg = new PopulateLightList(); lightmsg.Lights = new OrderedList<Light>(new LightComparer()); psysmsg = new PopulateParticleSystemList(); psysmsg.ParticleSystems = new List<ParticleSystem>(); // Create render queue workitempool = new ResourcePool<RenderWorkItem>(); renderqueue = new OrderedList<RenderWorkItem>(new RenderWorkItemComparer()); effectqueue = new OrderedList<PostProcessEffect>(new PostProcessEffectComparer()); // Setup GBuffer Renderer renderer = Owner.GetComponent<Renderer>(); gbuffer = renderer.CreateRenderTarget(1, "GBuffer"); gbuffer.ClearColour = new Color4(0.0f, 0.0f, 0.0f, 0.0f); gbuffer.AddDepthComponent(); gbuffer_colour = gbuffer.AddTextureComponent(); gbuffer_normal = gbuffer.AddTextureComponent(SlimDX.DXGI.Format.R32G32B32A32_Float); gbuffer_position = gbuffer.AddTextureComponent(SlimDX.DXGI.Format.R32G32B32A32_Float); gbuffer_material = gbuffer.AddTextureComponent(SlimDX.DXGI.Format.R32G32B32A32_Float); gbuffer.Finish(); // Setup light accumulation buffer lightaccum = renderer.CreateRenderTarget(1, "LightAccum"); lightaccum.ClearColour = new Color4(1.0f, 0.0f, 0.0f, 0.0f); lightaccum_diffuse = lightaccum.AddTextureComponent(SlimDX.DXGI.Format.R32G32B32A32_Float); lightaccum_specular = lightaccum.AddTextureComponent(SlimDX.DXGI.Format.R32G32B32A32_Float); lightaccum.Finish(); // Setup particle accumulation buffer particleaccum = renderer.CreateRenderTarget(1, "ParticleAccum"); particleaccum.ClearColour = new Color4(0.0f, 0.0f, 0.0f, 0.0f); particleaccum_colour = particleaccum.AddTextureComponent(); particleaccum.Finish(); // Setup swap buffers swapA = renderer.CreateRenderTarget(1, "SwapA"); swapA_colour = swapA.AddTextureComponent(); swapA.Finish(); swapB = renderer.CreateRenderTarget(1, "SwapB"); swapB_colour = swapB.AddTextureComponent(); swapB.Finish(); // Setup materials MaterialSystem matsys = Owner.GetComponent<MaterialSystem>(); mat_blit = matsys.CreateMaterial("blit", "blit"); mat_blit.SetParameter("smpTexture", renderer.Sampler_Clamp); mat_blitlight = matsys.CreateMaterial("blit_light", "blit_light"); mat_blitlight.SetParameter("smpTexture", renderer.Sampler_Clamp); mat_blitlight.SetParameter("texColour", gbuffer.GetTexture(gbuffer_colour)); mat_blitlight.SetParameter("texDiffuseLight", lightaccum.GetTexture(lightaccum_diffuse)); mat_blitlight.SetParameter("texSpecularLight", lightaccum.GetTexture(lightaccum_specular)); // Setup lights mat_lights = new Dictionary<LightType, Material>(); mat_lights.Add(LightType.Ambient, matsys.CreateMaterial("light_ambient", "light_ambient")); mat_lights.Add(LightType.Directional, matsys.CreateMaterial("light_directional", "light_directional")); mat_lights.Add(LightType.Point, matsys.CreateMaterial("light_point", "light_point")); foreach (Material mat in mat_lights.Values) { mat.SetParameter("texNormal", gbuffer.GetTexture(gbuffer_normal)); mat.SetParameter("texPosition", gbuffer.GetTexture(gbuffer_position)); mat.SetParameter("texMaterial", gbuffer.GetTexture(gbuffer_material)); mat.SetParameter("smpTexture", renderer.Sampler_Clamp); } // Setup meshes mesh_fs = MeshBuilder.BuildFullscreenQuad(); mesh_skybox = MeshBuilder.BuildCube(); }
public BundleProcessor(BundlePlugin bundlePlugin) : base(bundlePlugin) { Minifiers = new OrderedList <IContentMinifier>(); }
private bool TryProcessPage(ContentObject page, IEnumerable <IContentProcessor> pageProcessors, OrderedList <IContentProcessor> pendingPageProcessors, bool copyOutput) { // If page is discarded, skip it if (page.Discard) { return(false); } // By default working on all processors // Order is important! pendingPageProcessors.AddRange(pageProcessors); bool hasBeenProcessed = true; bool breakProcessing = false; // We process the page going through all IContentProcessor from the end of the list // (more priority) to the beginning of the list (less priority). // An IContentProcessor can transform the page to another type of content // that could then be processed by another IContentProcessor // But we make sure that a processor cannot process a page more than one time // to avoid an infinite loop var clock = Stopwatch.StartNew(); while (hasBeenProcessed && !breakProcessing && !page.Discard) { hasBeenProcessed = false; for (int i = pendingPageProcessors.Count - 1; i >= 0; i--) { var processor = pendingPageProcessors[i]; // Note that page.ContentType can be changed by a processor // while processing a page clock.Restart(); try { var result = processor.TryProcess(page); if (result != ContentResult.None) { // Update statistics per plugin var statistics = Site.Statistics; var stat = statistics.GetPluginStat(processor); stat.PageCount++; stat.ContentProcessTime += clock.Elapsed; hasBeenProcessed = true; pendingPageProcessors.RemoveAt(i); breakProcessing = result == ContentResult.Break; break; } } catch (Exception ex) { Site.Error(ex, $"Error while processing {page.Path}."); breakProcessing = true; hasBeenProcessed = true; break; } } } pendingPageProcessors.Clear(); // Copy only if the file are marked as include if (copyOutput && !breakProcessing && !page.Discard) { Site.Content.TryCopyContentToOutput(page, page.GetDestinationPath()); } return(true); }
public T GetOrCreate <T>(Func <WorldCollection, T> createFunction) where T : class, IWorldSystem { return(GetOrCreate(createFunction, OrderedList.GetBefore(typeof(T)), OrderedList.GetAfter(typeof(T)))); }
public TrainRenderer(ITrackParameters trackParameters, ITrainParameters trainParameters, OrderedList <ITrainPalette> trainPalettes) { _trackParameters = trackParameters; _trainParameters = trainParameters; _trainPalettes = trainPalettes; }
public IResult <bool> IsAllowed(string resource, string verb, string subject) => Do <bool> .Try((r) => { var acls = new OrderedList <string, AccessRule>(new ReverseComparer <string>()); var rules = GetAcls(resource, verb); if (rules.HasErrors) { r.AddErrors(rules.Errors); return(false); } // Add rules to the ordered list foreach (var rule in rules.ResultObject) { acls.Add(rule.Resource, rule); // While looping through the rules, if we find any of our specific subjects have an 'Allow' for this resource/verb pair, they are allowed! if (rule.Resource == resource && rule.Verb == verb && rule.Subject == subject && rule.Permission == Permission.Allow) { return(true); } } var aclPermission = Permission.Deny; bool isExplicit = false; bool isFirst = true; bool isSet = false; string mostAppropriateResourcePath = resource; foreach (var acl in acls) { if (isFirst) { mostAppropriateResourcePath = acl.Resource; isFirst = false; } if (isSet && mostAppropriateResourcePath != acl.Resource) { return(aclPermission == Permission.Allow); } if (acl.Subject == "*") { isSet = true; aclPermission = acl.Permission; } if (acl.Subject == subject) { isSet = true; isExplicit = true; aclPermission = acl.Permission; } if (isExplicit) { return(aclPermission == Permission.Allow); } } return(aclPermission == Permission.Allow); }) .Result;
/// <summary> /// Gets the enumerator for the SelectionSet /// </summary> /// /// <returns> /// The enumerator. /// </returns> public IEnumerator <T> GetEnumerator() { return(OrderedList.GetEnumerator()); }
/// <summary> /// Return the zero-based index of item in a sequence. /// </summary> /// /// <param name="item"> /// The item. /// </param> /// /// <returns> /// The zero-based position in the list where the item was found, or -1 if it was not found. /// </returns> public int IndexOf(T item) { return(OrderedList.IndexOf(item)); }
public void ClearComputation() { // classes indexed by day ClassesByDay_ = new OrderedList<Session>[7]; for (int i = 0; i < 7; i++) ClassesByDay_[i] = new OrderedList<Session>(); TimeAtUni_ = new TimeLength(0, 0); TimeInClasses_ = new TimeLength(0, 0); TimeInBreaks_ = new TimeLength(0, 0); Days_ = 0; MinDayLength_ = new TimeLength(24, 0); MaxDayLength_ = new TimeLength(0, 0); AverageDayLength_ = new TimeLength(0, 0); ShortBreak_ = new TimeLength(24, 0); LongBreak_ = new TimeLength(0, 0); AverageBreak_ = new TimeLength(0, 0); NumberBreaks_ = 0; ShortBlock_ = new TimeLength(24, 0); LongBlock_ = new TimeLength(0, 0); AverageBlock_ = new TimeLength(0, 0); NumberBlocks_ = 0; EarlyStart_ = TimeOfDay.Maximum; LateStart_ = TimeOfDay.Minimum; AverageStart_ = TimeOfDay.Minimum; EarlyEnd_ = TimeOfDay.Maximum; LateEnd_ = TimeOfDay.Minimum; AverageEnd_ = TimeOfDay.Minimum; TotalStart_ = new TimeLength(0); TotalEnd_ = new TimeLength(0); }
public HtmlOrderedList(OrderedList olList) { this.builder = new StringBuilder(); this.olList = olList; }
/// <summary> /// Initializes a new instance of the <see cref="TokenRendererPipeline{TContext}"/> class /// with some inital token renderers /// </summary> /// <param name="initalRenderers">The renderers to initalise with</param> public TokenRendererPipeline(List <ITokenRenderer <TContext> > initalRenderers) { tokenRenderers = new OrderedList <ITokenRenderer <TContext> >(initalRenderers); }
public void Delete_InCollection() { var task = new Task("(B) Delete_InCollection +test @task"); var tl = new TaskList(Data.TestDataPath); tl.Add(task); var tasks = new OrderedList<Task>(tl.Tasks); tasks.Remove(tasks.Where(x => x.Raw == task.Raw).First()); tl.Delete(task); var newTasks = tl.Tasks.ToList(); Assert.AreEqual(tasks.Count, newTasks.Count); for (int i = 0; i < tasks.Count; i++) Assert.AreEqual(tasks[i].ToString(), newTasks[i].ToString()); }
public MemoryProvider() { Allowed = new OrderedList <string, AccessRule>(); Denied = new OrderedList <string, AccessRule>(); }
public void Constructor_takes_sort_func() { Assert.DoesNotThrow(() => { var ol = new OrderedList<int>(x => x); }); }
public void StartOrderedList(OrderedList list) { curLists.Push(list.Start); }
protected MarkdownObjectRenderer() { TryWriters = new OrderedList <TryWriteDelegate>(); }
public void Visit(OrderedList orderedList) { var uiElements = BuildChildUIList(orderedList); DirectlyPlaceUIContent(new MarkdownList(true, uiElements)); }
public void EndOrderedList(OrderedList list) { writer.WriteLine("</ol>"); }
public void EndOrderedList(OrderedList list) { curLists.Pop(); }
protected override void SetSelectionInternal(OrderedList <T> newSelection, T newPrimarySelection) { this.NotifyItemsChanged(this.InternalSelection, newSelection); this.SetSelectionInternal(newSelection, newPrimarySelection); }
public void StartOrderedList(OrderedList list) { // make sure a list starts at the beginning of the line: EnsureNewlineEnding(writer); writer.Write("<ol"); if (list.Start != 1) writer.Write(" start=\"" + list.Start.ToString(System.Globalization.CultureInfo.InvariantCulture) + "\""); writer.WriteLine(">"); }
public void FailInsertSetTest() { var list = new OrderedList <int>(new int[] { 10, 5, 7, 5, 2, 15 }); list.Insert(0, 99); }
public void AddOrderedList(OrderedList list) { this.elements.Add(list); }
public void FailItemIndexSetTest() { var list = new OrderedList <int>(new int[] { 10, 5, 7, 5, 2, 15 }); list[0] = 33; }
public void StartOrderedList(OrderedList list) { Write("list (type=ordered tight={0} start={1})", list.IsTight, list.Start); indent += IndentBy; }
public void CorrectData(List<string> text, string expected) { OrderedList testObject = new OrderedList(text); Assert.Equal(text, testObject.Text); }
public QueryPlan GetQueryPlan(IDmObject parsedQuery, IQuery query, IQueryStore queryStore, MetadataIndex rowsEnumerator) { //Todo: Plan's cache's key decision (query-string based plan cache/optimizable-section based cache). OrderedList <double, IProxyPredicate> sortedPlans = new OrderedList <double, IProxyPredicate>(); var optimizableQuery = parsedQuery as IFilterObject; var criteria = AddQueryCriteria(parsedQuery, query.Parameters, queryStore); var queryPlan = new QueryPlan { Criteria = criteria }; if (optimizableQuery != null && optimizableQuery.WherePredicate != null) { ITreePredicate whereExpression = optimizableQuery.WherePredicate; ITreePredicate contractedExpression = whereExpression.Contract(); if (contractedExpression == null) { contractedExpression = whereExpression; } List <ITreePredicate> distribCombinations = new List <ITreePredicate>(); distribCombinations.Add(contractedExpression); //Todo: Restrict this call if there doesn't exist a compound index. while (contractedExpression.Expand() != null) { distribCombinations.Add(contractedExpression.Expand()); contractedExpression = contractedExpression.Expand(); } foreach (var treePredicate in distribCombinations) { if (treePredicate is OrTreePredicate || treePredicate is AndTreePredicate) { break; } if (treePredicate is ComparisonPredicate) { DocumentKey documentKey = null; if (((ComparisonPredicate)treePredicate).TryGetProxyKeyPredicate(rowsEnumerator, out documentKey)) { IProxyPredicate optimizablePredicate = new ProxyPredicate(new KeyPredicate(documentKey, rowsEnumerator), treePredicate); sortedPlans.Add(optimizablePredicate.Statistics[Statistic.ExpectedIO], optimizablePredicate); queryPlan.Predicate = sortedPlans.FirstValues[0].GetExecutionPredicate(queryStore); return(queryPlan); } } } foreach (var expressionState in distribCombinations) { IProxyPredicate optimizablePredicate = expressionState.GetProxyExecutionPredicate(_indexManager, queryStore, rowsEnumerator); sortedPlans.Add(optimizablePredicate.Statistics[Statistic.ExpectedIO], optimizablePredicate); //Todo: Add optimizedPredicate to the SortedList by the cost. } queryPlan.Predicate = sortedPlans.FirstValues[0].GetExecutionPredicate(queryStore); } else { if (criteria.GroupFields != null && criteria.GroupFields.Count == 1 && criteria.GroupFields[0] is AllField && criteria.ContainsAggregations) { if (criteria.Aggregations.Count == 1 && criteria.Aggregations[0].Aggregation is COUNT && criteria.Aggregations[0].Evaluation is AllEvaluable) { queryPlan.Criteria.GroupByField = null; queryPlan.Predicate = new SpecialCountPredicate(rowsEnumerator.KeyCount); queryPlan.IsSpecialExecution = true; return(queryPlan); } } //Todo:1 Projection variable-based index assigning (Functions' arguments + attributes). queryPlan.Predicate = GetSelectAllPredicate(criteria, rowsEnumerator); } return(queryPlan); }
public TrainPainter(OrderedList <ITrainPalette> trainPalettes) { _trainPalettes = trainPalettes; }
public OLState() { this.orderedList = new OrderedList(string.Empty); }
public Solution(Solution other) { this.Combination_ = new List<Stream>(other.Combination_); this.ClassesByDay_ = new OrderedList<Session>[7]; for (int i = 0; i < 7; i++) { ClassesByDay_[i] = new OrderedList<Session>(other.ClassesByDay_[i]); //ClassesByDay_[i] = other.ClassesByDay_[i].Clone(); } this.TimeAtUni_ = other.TimeAtUni_; this.TimeInClasses_ = other.TimeInClasses_; this.TimeInBreaks_ = other.TimeInBreaks_; this.Days_ = other.Days_; this.MinDayLength_ = other.MinDayLength_; this.MaxDayLength_ = other.MaxDayLength_; this.AverageDayLength_ = other.AverageDayLength_; this.ShortBreak_ = other.ShortBreak_; this.LongBreak_ = other.LongBreak_; this.AverageBreak_ = other.AverageBreak_; this.NumberBreaks_ = other.NumberBreaks_; this.ShortBlock_ = other.ShortBlock_; this.LongBlock_ = other.LongBlock_; this.AverageBlock_ = other.AverageBlock_; this.NumberBlocks_ = other.NumberBlocks_; this.EarlyStart_ = other.EarlyStart_; this.LateStart_ = other.LateStart_; this.AverageStart_ = other.AverageStart_; this.EarlyEnd_ = other.EarlyEnd_; this.LateEnd_ = other.EarlyEnd_; this.AverageEnd_ = other.AverageEnd_; this.TotalStart_ = other.TotalStart_; this.TotalEnd_ = other.TotalEnd_; }