/// Internal visitor implementation private void acceptVisitorAscending(IQueuedRenderableVisitor visitor) { // List is in descending order, so iterate in reverse for (var index = this._sortedDescending.Count - 1; index >= 0; ++index) { visitor.Visit(this._sortedDescending[index]); } }
/// Internal visitor implementation private void acceptVisitorDescending(IQueuedRenderableVisitor visitor) { // List is already in descending order, so iterate forward foreach (var renderablePass in this._sortedDescending) { visitor.Visit(renderablePass); } }
/// Internal visitor implementation private void acceptVisitorGrouped(IQueuedRenderableVisitor visitor) { foreach (var item in this._grouped) { // Fast bypass if this group is now empty if (item.Value.Count == 0) { continue; } // Visit Pass - allow skip if (!visitor.Visit(item.Key)) { continue; } foreach (var renderable in item.Value) { // Visit Renderable visitor.Visit(renderable); } } }
/// <summary> /// Accept a visitor over the collection contents. /// </summary> /// <param name="visitor">Visitor class which should be called back</param> /// <param name="organizationMode"> /// The organization mode which you want to iterate over. /// Note that this must have been included in an AddOrganizationMode /// call before any renderables were added. /// </param> public void AcceptVisitor(IQueuedRenderableVisitor visitor, OrganizationMode organizationMode) { if ((int)(organizationMode & this._organizationMode) == 0) { throw new ArgumentException( "Organization mode requested in AcceptVistor was not notified " + "to this class ahead of time, therefore may not be supported.", "organizationMode"); } switch (organizationMode) { case OrganizationMode.GroupByPass: acceptVisitorGrouped(visitor); break; case OrganizationMode.Descending: acceptVisitorDescending(visitor); break; case OrganizationMode.Ascending: acceptVisitorAscending(visitor); break; } }