Here are the examples of the csharp api System.Collections.Generic.Stack.Clear() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
584 Examples
19
Source : WizardPageContainer.cs
with MIT License
from dahall
with MIT License
from dahall
private void InitialSetup()
{
if (initialized) return;
pageHistory.Clear();
selectedPage = null;
var firstPage = Pages.Find(p => !p.Suppress);
if (firstPage != null) SelectedPage = firstPage;
if (selectedPage == null)
UpdateUIDependencies();
if (showProgressInTaskbarIcon)
{
progressTimer = new Timer() { Interval = 1000, Enabled = true };
progressTimer.Tick += progressTimer_Tick;
}
initialized = true;
}
19
Source : RegionNavigationJournal.cs
with Mozilla Public License 2.0
from daixin10310
with Mozilla Public License 2.0
from daixin10310
public void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory)
{
if (!this.isNavigatingInternal)
{
if (this.CurrentEntry != null)
{
this.backStack.Push(this.CurrentEntry);
}
this.forwardStack.Clear();
if (persistInHistory)
CurrentEntry = entry;
else
CurrentEntry = null;
}
}
19
Source : Program.cs
with Apache License 2.0
from danielmarbach
with Apache License 2.0
from danielmarbach
static void PrintRunnables(Dictionary<int, RunnerWithExplainer> runnables)
{
var currentThreadId = Thread.CurrentThread.ManagedThreadId;
if (threadIds.Count > 4)
{
threadIds.Clear();
}
threadIds.Push(currentThreadId);
var longest = Math.Max(runnables.Values.Max(d => d.Name.Length) + 10, 35);
fullWidth = longest * 2;
var currentColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"|{string.Join("=", Enumerable.Repeat(string.Empty, fullWidth))}|");
Console.WriteLine($"{$"| Thread(s): {string.Join(",", threadIds)}".PadRight(fullWidth)}|");
Console.WriteLine($"|{string.Join("=", Enumerable.Repeat(string.Empty, fullWidth))}|");
Console.WriteLine();
var elements = runnables.Values.Count;
var half = (elements / 2);
for (int i = 0; i < half; i++)
{
var left = runnables.ElementAtOrDefault(i);
if (left.Equals(default))
{
break;
}
var right = runnables.ElementAtOrDefault(i + half);
if (right.Equals(default))
{
break;
}
if (left.Key == right.Key)
{
continue;
}
var leftString = $" ({PadBoth(left.Key.ToString(), 5)}) {left.Value.Name}";
var rightString = $"({PadBoth(right.Key.ToString(), 5)}) {right.Value.Name}";
Console.WriteLine($"{leftString.PadRight(longest)}{rightString}");
}
if (elements % 2 == 1)
{
var last = runnables.Last();
var lastString = $"({PadBoth(last.Key.ToString(), 5)}) {last.Value.Name}";
Console.WriteLine($"{"".PadRight(longest)}{lastString}");
}
Console.WriteLine();
Console.WriteLine($"|{string.Join("=", Enumerable.Repeat(string.Empty, fullWidth))}|");
Console.WriteLine($"{$"| github.com/danielmarbach/Async.Netcore (*)".PadRight(fullWidth)}|");
Console.WriteLine($"{$"| @danielmarbach | planetgeek.ch | LinkedIn : https://goo.gl/YyWJGf".PadRight(fullWidth)}|");
Console.WriteLine($"|{string.Join("=", Enumerable.Repeat(string.Empty, fullWidth))}|");
Console.WriteLine(" (*) don't forget to star the repo ;)");
Console.ForegroundColor = currentColor;
}
19
Source : Program.cs
with Apache License 2.0
from danielmarbach
with Apache License 2.0
from danielmarbach
static void PrintRunnables(Dictionary<int, RunnerWithExplainer> runnables)
{
var currentThreadId = Thread.CurrentThread.ManagedThreadId;
if (threadIds.Count > 4)
{
threadIds.Clear();
}
threadIds.Push(currentThreadId);
var longest = runnables.Values.Max(d => d.Name.Length) + 5;
int fullWidth = longest * 2;
var currentColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"|{string.Join("=", Enumerable.Repeat(string.Empty, fullWidth))}|");
Console.WriteLine($"{$"| Thread(s): {string.Join(",", threadIds)}".PadRight(fullWidth)}|");
Console.WriteLine($"|{string.Join("=", Enumerable.Repeat(string.Empty, fullWidth))}|");
Console.WriteLine();
var elements = runnables.Values.Count;
var half = (elements / 2);
for (int i = 0; i < half; i++)
{
var left = runnables.ElementAtOrDefault(i);
if (left.Equals(default))
{
break;
}
var right = runnables.ElementAtOrDefault(i + half);
if (right.Equals(default))
{
break;
}
if (left.Key == right.Key)
{
continue;
}
var leftString = $" ({PadBoth(left.Key.ToString(), 5)}) {left.Value.Name}";
var rightString = $"({PadBoth(right.Key.ToString(), 5)}) {right.Value.Name}";
Console.WriteLine($"{leftString.PadRight(longest)}{rightString}");
}
if (elements % 2 == 1)
{
var last = runnables.Last();
var lastString = $"({PadBoth(last.Key.ToString(), 5)}) {last.Value.Name}";
Console.WriteLine($"{"".PadRight(longest)}{lastString}");
}
Console.WriteLine();
Console.WriteLine($"|{string.Join("=", Enumerable.Repeat(string.Empty, fullWidth))}|");
Console.WriteLine($"{$"| github.com/danielmarbach/Await.HeadExplosion (*)".PadRight(fullWidth)}|");
Console.WriteLine($"{$"| @danielmarbach | planetgeek.ch | LinkedIn : https://goo.gl/YyWJGf".PadRight(fullWidth)}|");
Console.WriteLine($"|{string.Join("=", Enumerable.Repeat(string.Empty, fullWidth))}|");
Console.WriteLine(" (*) don't forget to star the repo ;)");
Console.ForegroundColor = currentColor;
}
19
Source : ViewDictionary.cs
with Apache License 2.0
from DarkLop
with Apache License 2.0
from DarkLop
public void DestroyViewAll()
{
ViewBase[] views = m_ViewDict.Values.ToArray();
m_OpenViews.Clear();
m_ViewDict.Clear();
m_CurrentView = null;
foreach (ViewBase view in views)
{
if (view != null)
{
view.CloseInternal();
GameObject.Destroy(view.gameObject);
}
}
views = null;
}
19
Source : LiveUIManager.cs
with MIT License
from DataMesh-OpenSource
with MIT License
from DataMesh-OpenSource
private bool ClearStackArray()
{
if (stackCurrentUIForms != null && stackCurrentUIForms.Count >= 1)
{
stackCurrentUIForms.Clear();
return true;
}
return false;
}
19
Source : Logo.cs
with MIT License
from daxnet
with MIT License
from daxnet
public void Execute(string source)
{
procedureScopes.Clear();
procedures.Clear();
procedures.AddRange(new IProcedureOrFunction[]
{
new SqrtFunction(),
new RandomFunction()
});
procedureScopes.Push(new ProcedureScope("Root"));
var syntaxTree = parser.Parse(source);
if (syntaxTree.HasErrors())
{
List<ParsingError> errors = new List<ParsingError>();
foreach (var message in syntaxTree.ParserMessages)
{
errors.Add(new ParsingError(message.Location.Position, message.Location.Column, message.Location.Line, message.Message));
}
throw new ParsingException("Source code parsing failed, see ParsingMessages for more details.", errors);
}
this.ParseTree(syntaxTree.Root);
}
19
Source : CodeOutlineFilter.cs
with MIT License
from daxnet
with MIT License
from daxnet
public override void Reset() {
base.Reset();
Indents.Clear();
Indents.Push(0);
OutputTokens.Clear();
PreviousToken = null;
CurrentToken = null;
PreviousTokenLocation = new SourceLocation();
}
19
Source : ComponentExecutionOrder.cs
with GNU General Public License v3.0
from deathkiller
with GNU General Public License v3.0
from deathkiller
private static Dictionary<Type,int> ScoreGraphNodes(Dictionary<Type,List<OrderConstraint>> graph, IEnumerable<Type> types)
{
Dictionary<Type,int> graphScores = new Dictionary<Type,int>(graph.Count);
// Initialize graph scores for every node. Has to be done explicitly, so we
// have proper scores for types that are unconstrained / not part of the graph.
int baseScore = 0;
foreach (Type type in types)
{
graphScores.Add(type, baseScore++);
}
Stack<Type> visitSchedule = new Stack<Type>();
// For every node, traverse all other reachable nodes and propagate a score
// value through them that increases with the number of visited nodes in
// the chain.
foreach (Type startNode in graph.Keys)
{
visitSchedule.Clear();
visitSchedule.Push(startNode);
while (visitSchedule.Count > 0)
{
Type node = visitSchedule.Pop();
List<OrderConstraint> links;
if (!graph.TryGetValue(node, out links))
continue;
int nodeScore = graphScores[node];
// Push the current node's score to its neighbour nodes and schedule
// them for traversal.
for (int i = 0; i < links.Count; i++)
{
OrderConstraint link = links[i];
Type nextNode = link.LastType;
int nextNodeScore = graphScores[nextNode];
// Determine the minimum score the neighbour node should have
int minNextNodeScore = nodeScore + 1;
// Propagate scores when out of order
if (nextNodeScore < minNextNodeScore)
{
graphScores[nextNode] = minNextNodeScore;
visitSchedule.Push(nextNode);
}
}
}
}
return graphScores;
}
19
Source : ComponentExecutionOrder.cs
with GNU General Public License v3.0
from deathkiller
with GNU General Public License v3.0
from deathkiller
private static List<OrderConstraint> FindConstraintLoop(Dictionary<Type,List<OrderConstraint>> graph)
{
if (graph.Count == 0) return null;
// Note that in our specific case of a constraint graph, all valid graphs share
// the property that there is a maximum of one connection between each two nodes,
// and there are no loops within the graph, so it forms a propert tree.
//
// Thus, we can traverse a valid constraint graph in its entirety and never
// encounter the same node twice.
HashSet<Type> visitedNodes = new HashSet<Type>();
Stack<Type> visitSchedule = new Stack<Type>();
Dictionary<Type,OrderConstraint> prevLinks = new Dictionary<Type,OrderConstraint>();
foreach (Type startNode in graph.Keys)
{
visitedNodes.Clear();
visitSchedule.Clear();
prevLinks.Clear();
// Do a breadth-first graph traversal to see if we'll end up at the start
visitSchedule.Push(startNode);
while (visitSchedule.Count > 0)
{
Type node = visitSchedule.Pop();
// Already visited this node in a previous run? Can't be part of a loop then.
if (!visitedNodes.Add(node))
continue;
List<OrderConstraint> links;
if (!graph.TryGetValue(node, out links))
continue;
for (int i = 0; i < links.Count; i++)
{
OrderConstraint link = links[i];
Type nextNode = link.LastType;
// Found the starting node again through traversal? Found a loop then!
if (nextNode == startNode)
{
List<OrderConstraint> loopPath = new List<OrderConstraint>();
while (true)
{
loopPath.Add(link);
if (!prevLinks.TryGetValue(link.FirstType, out link))
break;
}
return loopPath;
}
prevLinks[nextNode] = link;
visitSchedule.Push(nextNode);
}
}
}
return null;
}
19
Source : DynamicTree.cs
with GNU General Public License v3.0
from deathkiller
with GNU General Public License v3.0
from deathkiller
public void Query(Func<T, bool> callback, ref AABB aabb)
{
queryStack.Clear();
queryStack.Push(root);
while (queryStack.Count > 0) {
int nodeId = queryStack.Pop();
if (nodeId == NullNode) {
continue;
}
TreeNode<T> node = nodes[nodeId];
if (AABB.TestOverlap(ref node.AABB, ref aabb)) {
if (node.IsLeaf()) {
bool proceed = callback(nodes[nodeId].UserData);
if (!proceed) {
return;
}
} else {
queryStack.Push(node.Child1);
queryStack.Push(node.Child2);
}
}
}
}
19
Source : Navigator.cs
with MIT License
from delight-dev
with MIT License
from delight-dev
public void Close()
{
ViewStack.Clear();
SetPageState(null, null, NavigationTransition.Close);
}
19
Source : GraphGUI.cs
with MIT License
from diglungdig
with MIT License
from diglungdig
public void PushSelection()
{
if (_selectionStack == null)
_selectionStack = new Stack<string>();
else
_selectionStack.Clear();
foreach (Node node in selection)
if (node != null) _selectionStack.Push(node.name);
}
19
Source : GraphGUI.cs
with MIT License
from diglungdig
with MIT License
from diglungdig
public void PopSelection()
{
selection.Clear();
while (_selectionStack.Count > 0)
{
var found = graph.GetNodeByName(_selectionStack.Pop());
if (found != null) selection.Add(found);
}
_selectionStack.Clear();
UpdateUnitySelection();
}
19
Source : GUIHelper.cs
with MIT License
from diglungdig
with MIT License
from diglungdig
public void FinishAndCheck() {
if (unbalancedItems.Count == 0) return;
Debug.LogErrorFormat("{0} unbalanced GUI elements found.", unbalancedItems.Count);
foreach (Item item in unbalancedItems) {
Debug.LogErrorFormat("Unbalanced GUI element: {0}", item);
}
// Reset for the next GUI iteration.
unbalancedItems.Clear();
}
19
Source : View.cs
with Microsoft Public License
from Dijji
with Microsoft Public License
from Dijji
public void SetMessage(MessageView mv)
{
if (CurrentMessage != null)
CurrentMessage.ClearContents();
stackMessage.Clear();
UpdateCurrentMessage(mv);
}
19
Source : View.cs
with Microsoft Public License
from Dijji
with Microsoft Public License
from Dijji
public void Clear()
{
SelectedFolder = null;
CurrentMessage = null;
RootFolderViews.Clear();
stackMessage.Clear();
}
19
Source : DirDiffDocViewModel.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
private void SetData(IDirectoryDiffRoot results,
DiffViewModeEnum requestedViewMode)
{
string currentPathA = results.RootPathA;
string currentPathB = results.RootPathB;
List<IDirEntryViewModel> dirs = null;
switch (requestedViewMode)
{
case DiffViewModeEnum.DirectoriesAndFiles:
dirs = CreateViewModelEntries(results.RootEntry.Subentries, currentPathA, currentPathB);
break;
case DiffViewModeEnum.FilesOnly:
// Sort list of different files by their type of difference and show them in UI
var sortedList = results.DifferentFiles
.OrderByDescending(x => (int)(x.EditContext))
.ToList();
dirs = CreateViewModelEntries(sortedList, currentPathA, currentPathB);
break;
default:
throw new ArgumentOutOfRangeException(requestedViewMode.ToString());
}
_DirPathStack.Clear();
SetDirDiffCollectionData(dirs);
CountFilesDeleted = results.CountFilesDeleted;
CountFilesAdded = results.CountFilesAdded;
CountFilesChanged = results.CountFilesChanged;
PathA = string.Empty;
PathB = string.Empty;
// Set a filter description
if (results.Filter == null)
{
this.LblFilter = "All Files";
}
else
{
DirectoryDiffFileFilter filter = results.Filter;
this.LblFilter = string.Format("{0}: {1}", filter.Include ? "Includes" : "Excludes", filter.FilterString);
}
}
19
Source : SharpTreeViewTextSearch.cs
with MIT License
from dolkensp
with MIT License
from dolkensp
void ClearState()
{
isActive = false;
matchPrefix = string.Empty;
lastMatchIndex = -1;
inputStack.Clear();
timer?.Stop();
timer = null;
}
19
Source : EditorCoroutine.cs
with MIT License
from DonnYep
with MIT License
from DonnYep
private bool ProcessIEnumeratorRecursive(IEnumerator enumerator)
{
var root = enumerator;
while(enumerator.Current as IEnumerator != null)
{
kIEnumeratorProcessingStack.Push(enumerator);
enumerator = enumerator.Current as IEnumerator;
}
//process leaf
m_Processor.Set(enumerator.Current);
var result = m_Processor.MoveNext(enumerator);
while (kIEnumeratorProcessingStack.Count > 1)
{
if (!result)
{
result = kIEnumeratorProcessingStack.Pop().MoveNext();
}
else
kIEnumeratorProcessingStack.Clear();
}
if (kIEnumeratorProcessingStack.Count > 0 && !result && root == kIEnumeratorProcessingStack.Pop())
{
result = root.MoveNext();
}
return result;
}
19
Source : fsSerializer.cs
with GNU General Public License v3.0
from Doreamonsky
with GNU General Public License v3.0
from Doreamonsky
public void PurgeTemporaryData() {
_references.Clear();
_lazyReferenceWriter.Clear();
_collectors.Clear();
}
19
Source : FSM.cs
with GNU General Public License v3.0
from Doreamonsky
with GNU General Public License v3.0
from Doreamonsky
public bool EnterState(FSMState newState, TransitionCallMode callMode) {
if ( !isRunning ) {
Logger.LogWarning("Tried to EnterState on an FSM that was not running", LogTag.EXECUTION, this);
return false;
}
if ( newState == null ) {
Logger.LogWarning("Tried to Enter Null State", LogTag.EXECUTION, this);
return false;
}
if ( currentState != null ) {
if ( onStateExit != null ) { onStateExit(currentState); }
currentState.Reset(false);
if ( callMode == TransitionCallMode.Stacked ) {
stateStack.Push(currentState);
if ( stateStack.Count > 5 ) {
Logger.LogWarning("State stack exceeds 5. Ensure that you are not cycling stack calls", LogTag.EXECUTION, this);
}
}
}
if ( callMode == TransitionCallMode.Clean ) {
stateStack.Clear();
}
previousState = currentState;
currentState = newState;
if ( onStateTransition != null ) { onStateTransition(currentState); }
if ( onStateEnter != null ) { onStateEnter(currentState); }
currentState.Execute(agent, blackboard);
return true;
}
19
Source : VersionIdentifier.cs
with MIT License
from dotnet
with MIT License
from dotnet
private static string GetVersionForSingleSegment(string replacedetPathSegment)
{
// Find the start of the version number by finding the major.minor.patch.
// Scan the string forward looking for a digit preceded by one of the delimiters,
// then look for a minor.patch, completing the major.minor.patch. Continue to do so until we get
// to something that is NOT major.minor.patch (this is necessary because we sometimes see things like:
// VS.Redist.Common.NetCore.Templates.x86.2.2.3.0.101-servicing-014320.nupkg
// Continue iterating until we find ALL potential versions. Return the one that is the latest in the segment
// This is to deal with files with multiple major.minor.patchs in the file name, for example:
// Microsoft.NET.Workload.Mono.ToolChain.Manifest-6.0.100.Msi.x64.6.0.0-rc.1.21380.2.symbols.nupkg
int currentIndex = 0;
// Stack of major.minor.patch.
Stack<(int versionNumber, int index)> majorMinorPatchStack = new Stack<(int,int)>(3);
string majorMinorPatch = null;
int majorMinorPatchIndex = 0;
StringBuilder versionSuffix = new StringBuilder();
char prevDelimiterCharacter = char.MinValue;
char nextDelimiterCharacter = char.MinValue;
Dictionary<int,string> majorMinorPatchDictionary = new Dictionary<int, string>();
while (true)
{
string nextSegment;
prevDelimiterCharacter = nextDelimiterCharacter;
int nextDelimiterIndex = replacedetPathSegment.IndexOfAny(_delimiters, currentIndex);
if (nextDelimiterIndex != -1)
{
nextDelimiterCharacter = replacedetPathSegment[nextDelimiterIndex];
nextSegment = replacedetPathSegment.Substring(currentIndex, nextDelimiterIndex - currentIndex);
}
else
{
nextSegment = replacedetPathSegment.Substring(currentIndex);
}
// If we have not yet found the major/minor/patch, then there are four cases:
// - There have been no potential major/minor/patch numbers found and the current segment is a number. Push onto the majorMinorPatch stack
// and continue.
// - There has been at least one number found, but less than 3, and the current segment not a number or not preceded by '.'. In this case,
// we should clear out the stack and continue the search.
// - There have been at least 2 numbers found and the current segment is a number and preceded by '.'. Push onto the majorMinorPatch stack and continue
// - There have been at least 3 numbers found and the current segment is not a number or not preceded by '-'. In this case, we can call this the major minor
// patch number and no longer need to continue searching
if (majorMinorPatch == null)
{
bool isNumber = int.TryParse(nextSegment, out int potentialVersionSegment);
if ((majorMinorPatchStack.Count == 0 && isNumber) ||
(majorMinorPatchStack.Count > 0 && prevDelimiterCharacter == '.' && isNumber))
{
majorMinorPatchStack.Push((potentialVersionSegment, currentIndex));
}
// Check for partial major.minor.patch cases, like: 2.2.bar or 2.2-100.bleh
else if (majorMinorPatchStack.Count > 0 && majorMinorPatchStack.Count < 3 &&
(prevDelimiterCharacter != '.' || !isNumber))
{
majorMinorPatchStack.Clear();
}
// Determine whether we are done with major.minor.patch after this update.
if (majorMinorPatchStack.Count >= 3 && (prevDelimiterCharacter != '.' || !isNumber || nextDelimiterIndex == -1))
{
// Done with major.minor.patch, found. Pop the top 3 elements off the stack.
(int patch, int patchIndex) = majorMinorPatchStack.Pop();
(int minor, int minorIndex) = majorMinorPatchStack.Pop();
(int major, int majorIndex) = majorMinorPatchStack.Pop();
majorMinorPatch = $"{major}.{minor}.{patch}";
majorMinorPatchIndex = majorIndex;
}
}
// Don't use else, so that we don't miss segments
// in case we are just deciding that we've finished major minor patch.
if (majorMinorPatch != null)
{
// Now look at the next segment. If it looks like it could be part of a version, append to what we have
// and continue. If it can't, then we're done.
//
// Cases where we should break out and be done:
// - We have an empty pre-release label and the delimiter is not '-'.
// - We have an empty pre-release label and the next segment does not start with a known tag.
// - We have a non-empty pre-release label and the current segment is not a number and also not 'final'
// A corner case of versioning uses .final to represent a non-date suffixed final pre-release version:
// 3.1.0-preview.10.final
if (versionSuffix.Length == 0 &&
(prevDelimiterCharacter != '-' || !_knownTags.Any(tag => nextSegment.StartsWith(tag, StringComparison.OrdinalIgnoreCase))))
{
majorMinorPatchDictionary.Add(majorMinorPatchIndex, majorMinorPatch);
majorMinorPatch = null;
versionSuffix = new StringBuilder();
}
else if (versionSuffix.Length != 0 && !int.TryParse(nextSegment, out int potentialVersionSegment) && nextSegment != _finalSuffix)
{
majorMinorPatchDictionary.Add(majorMinorPatchIndex, $"{majorMinorPatch}{versionSuffix.ToString()}");
majorMinorPatch = null;
versionSuffix = new StringBuilder();
}
else
{
// Append the delimiter character and then the current segment
versionSuffix.Append(prevDelimiterCharacter);
versionSuffix.Append(nextSegment);
}
}
if (nextDelimiterIndex != -1)
{
currentIndex = nextDelimiterIndex + 1;
}
else
{
break;
}
}
if(majorMinorPatch != null)
{
majorMinorPatchDictionary.Add(majorMinorPatchIndex, $"{majorMinorPatch}{versionSuffix.ToString()}");
}
if (!majorMinorPatchDictionary.Any())
{
return null;
}
int maxKey = majorMinorPatchDictionary.Keys.Max();
return majorMinorPatchDictionary[maxKey];
}
19
Source : ServiceContainer.cs
with MIT License
from dotnet
with MIT License
from dotnet
public static void Clear()
{
services.Clear();
scopedServices.Clear();
}
19
Source : DepthFirstSearch.cs
with MIT License
from dotnet
with MIT License
from dotnet
public override void Clear()
{
base.Clear();
SearchStack.Clear();
}
19
Source : StackAsList.cs
with MIT License
from dotnet
with MIT License
from dotnet
public void Clear()
{
Stack.Clear();
}
19
Source : HttpState.cs
with MIT License
from dotnet
with MIT License
from dotnet
public void ResetState(bool persistHeaders = false, bool persistPath = false)
{
BaseAddress = null;
SwaggerEndpoint = null;
if (!persistHeaders)
{
Headers.Clear();
AddDefaultHeaders();
}
if (!persistPath)
{
PathSections.Clear();
}
}
19
Source : DepthFirstSearch.cs
with MIT License
from dotnet
with MIT License
from dotnet
protected void DoSearch()
{
while (SearchStack.Count > 0)
{
StackFrame frame = SearchStack.Peek();
if (!PushNextChild(frame))
{
// all children have been visited, so we can remove ourselves from the stack.
NodeType node = frame.Node;
IsVisited[node] = VisitState.Finished;
SearchStack.Pop();
OnFinishNode(node);
if (SearchStack.Count > 0)
OnFinishTreeEdge(new Edge<NodeType>(SearchStack.Peek().Node, node));
if (stopped)
{
SearchStack.Clear();
stopped = false;
}
}
}
}
19
Source : ModelAnalysisTransform.cs
with MIT License
from dotnet
with MIT License
from dotnet
protected override IExpression ConvertArrayCreate(IArrayCreateExpression iace)
{
IArrayCreateExpression ace = (IArrayCreateExpression) base.ConvertArrayCreate(iace);
IreplacedignExpression iae = context.FindAncestor<IreplacedignExpression>();
if (iae == null) return ace;
if (iae.Expression != iace) return ace;
if (iace.Initializer != null)
{
var exprs = iace.Initializer.Expressions;
bool expandInitializer = !AllElementsAreLiteral(exprs);
if (expandInitializer)
{
// convert the initializer to a list of replacedignment statements to literal indices
bool wasConvertingArrayCreate = convertingArrayCreate;
if (!wasConvertingArrayCreate)
arrayCreateStmts.Clear();
convertingArrayCreate = true;
IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(iae.Target);
// Sets the size of this variable at this array depth
int depth = Recognizer.GetIndexingDepth(iae.Target);
IExpression[] dimExprs = new IExpression[ace.Dimensions.Count];
for (int i = 0; i < dimExprs.Length; i++)
dimExprs[i] = ace.Dimensions[i];
List<IList<IExpression>> indices = Recognizer.GetIndices(iae.Target);
// for a multi-dimensional array, exprs will contain IBlockExpressions
// dimExprs must be ILiteralExpressions
int[] dims = Util.ArrayInit(dimExprs.Length, i => (int)((ILiteralExpression)dimExprs[i]).Value);
int[] strides = StringUtil.ArrayStrides(dims);
int elementCount = strides[0] * dims[0];
var target = Builder.JaggedArrayIndex(Builder.VarRefExpr(ivd), indices);
int[] mIndex = new int[dims.Length];
for (int linearIndex = elementCount - 1; linearIndex >= 0; linearIndex--)
{
StringUtil.LinearIndexToMultidimensionalIndex(linearIndex, strides, mIndex);
var indexExprs = Util.ArrayInit(mIndex.Length, i => Builder.LiteralExpr(mIndex[i]));
var lhs = Builder.ArrayIndex(target, indexExprs);
var expr = GetInitializerElement(exprs, mIndex);
var replacedignStmt = Builder.replacedignStmt(lhs, expr);
var st = ConvertStatement(replacedignStmt);
arrayCreateStmts.Push(st);
}
ace.Initializer = null;
convertingArrayCreate = wasConvertingArrayCreate;
if (!wasConvertingArrayCreate)
{
context.AddStatementsAfterCurrent(arrayCreateStmts);
}
}
}
return ace;
}
19
Source : PreallocatedAutomataObjects.cs
with MIT License
from dotnet
with MIT License
from dotnet
internal static (GenerationalDictionary<IntPair, int>, Stack<(int, int, int)>) LeaseProductState()
{
var result = productState;
if (result.Item1 == null)
{
result = (new GenerationalDictionary<IntPair, int>(), new Stack<(int, int, int)>());
productState = result;
}
result.Item1.Clear();
result.Item2.Clear();
return result;
}
19
Source : PreallocatedAutomataObjects.cs
with MIT License
from dotnet
with MIT License
from dotnet
internal static (Stack<int>, TarjanStateInfo[], Stack<IntPair>, int) LeaseFindStronglyConnectedComponentsState(int stateCount)
{
var (stack, stateInfo, traversalStack, nextGeneration) = findStronglyConnectedComponentsState;
// This check will work in both cases: when state was not initialized and when
// generation has overflown over 0.
if (nextGeneration == 0)
{
stack = new Stack<int>();
stateInfo = new TarjanStateInfo[stateCount];
traversalStack = new Stack<IntPair>();
}
if (stateInfo.Length < stateCount)
{
var newLength = Math.Max(stateCount, stateInfo.Length * 2);
stateInfo = new TarjanStateInfo[newLength];
}
stack.Clear();
traversalStack.Clear();
++nextGeneration;
var result = (stack, stateInfo, traversalStack, nextGeneration);
// We need to always update the currently stored state, because at the very least
// current generation was bumped and we need to preserve this for next time
// this method is called.
findStronglyConnectedComponentsState = result;
return result;
}
19
Source : PreallocatedAutomataObjects.cs
with MIT License
from dotnet
with MIT License
from dotnet
internal static (Stack<(int, int, Weight, int)>, Stack<Weight>, GenerationalDictionary<IntPair, Weight>) LeaseGetLogValueState()
{
var result = getLogValueState;
if (result.Item1 == null)
{
result = ValueTuple.Create(
new Stack<(int, int, Weight, int)>(),
new Stack<Weight>(),
new GenerationalDictionary<IntPair, Weight>());
getLogValueState = result;
}
result.Item1.Clear();
result.Item2.Clear();
result.Item3.Clear();
return result;
}
19
Source : PreallocatedAutomataObjects.cs
with MIT License
from dotnet
with MIT License
from dotnet
internal static (Stack<int>, bool[]) LeaseRemoveDeadStatesState(int statesCount)
{
var result = removeDeadStatesState;
if (result.Item1 == null)
{
result = (new Stack<int>(), result.Item2);
removeDeadStatesState = result;
}
var resultLength = result.Item2?.Length ?? -1;
if (resultLength < statesCount)
{
result = (result.Item1, new bool[Math.Max(statesCount, resultLength * 2)]);
removeDeadStatesState = result;
}
result.Item1.Clear();
Array.Clear(result.Item2, 0, statesCount);
return result;
}
19
Source : AsnWriter.cs
with MIT License
from dotnet
with MIT License
from dotnet
public void Reset()
{
this.CheckDisposed();
if (this._offset > 0)
{
Debug.replacedert(this._buffer != null);
Array.Clear(this._buffer, 0, this._offset);
this._offset = 0;
this._nestingStack?.Clear();
}
}
19
Source : ScalingCanvas.cs
with MIT License
from dotnet
with MIT License
from dotnet
public void ResetState()
{
_canvas.ResetState();
_scaleXStack.Clear();
_scaleYStack.Clear();
_scaleX = 1;
_scaleY = 1;
}
19
Source : PathBuilder.cs
with MIT License
from dotnet
with MIT License
from dotnet
public PathF BuildPath(string pathreplacedtring)
{
try
{
_lastCommand = '~';
_lastCurveControlPoint = null;
_path = null;
_commandStack.Clear();
_relativePoint = new PointF(0, 0);
_closeWhenDone = false;
#if DEBUG_PATH
Logger.Debug(aPathString);
#endif
pathreplacedtring = pathreplacedtring.Replace("Infinity", "0");
pathreplacedtring = Regex.Replace(pathreplacedtring, "([a-zA-Z])", " $1 ");
pathreplacedtring = pathreplacedtring.Replace("-", " -");
pathreplacedtring = pathreplacedtring.Replace(" E -", "E-");
pathreplacedtring = pathreplacedtring.Replace(" e -", "e-");
#if DEBUG_PATH
Logger.Debug(aPathString);
#endif
string[] args = pathreplacedtring.Split(new[] {' ', '\r', '\n', '\t', ','}, StringSplitOptions.RemoveEmptyEntries);
for (int i = args.Length - 1; i >= 0; i--)
{
string entry = args[i];
char c = entry[0];
if (char.IsLetter(c))
{
if (entry.Length > 1)
{
entry = entry.Substring(1);
if (char.IsLetter(entry[0]))
{
if (entry.Length > 1)
{
_commandStack.Push(entry.Substring(1));
#if DEBUG_PATH
Logger.Debug(vEntry.Substring(1));
#endif
}
_commandStack.Push(entry[0].ToInvariantString());
#if DEBUG_PATH
Logger.Debug(vEntry[0].ToString());
#endif
}
else
{
_commandStack.Push(entry);
#if DEBUG_PATH
Logger.Debug(vEntry);
#endif
}
}
_commandStack.Push(c.ToInvariantString());
#if DEBUG_PATH
Logger.Debug(vChar.ToString());
#endif
}
else
{
_commandStack.Push(entry);
#if DEBUG_PATH
Logger.Debug(vEntry);
#endif
}
}
while (_commandStack.Count > 0)
{
if (_path == null)
{
_path = new PathF();
}
string topCommand = _commandStack.Pop();
var firstLetter = topCommand[0];
if (IsCommand(firstLetter))
HandleCommand(topCommand);
else
{
_commandStack.Push(topCommand);
HandleCommand(_lastCommand.ToString());
}
}
if (_path != null && !_path.Closed)
{
if (_closeWhenDone)
{
_path.Close();
}
}
}
catch (Exception exc)
{
#if DEBUG
Logger.Debug("=== An error occured parsing the path. ===", exc);
Logger.Debug(pathreplacedtring);
throw;
#endif
}
return _path;
}
19
Source : CreateAddAndClear.cs
with MIT License
from dotnet
with MIT License
from dotnet
[Benchmark]
public Stack<T> Stack()
{
Stack<T> stack = new Stack<T>();
foreach (T value in _uniqueValues)
{
stack.Push(value);
}
stack.Clear();
return stack;
}
19
Source : EventRoute.cs
with MIT License
from dotnet
with MIT License
from dotnet
internal void Clear()
{
_routedEvent = null;
_routeItemList.Clear();
if (_branchNodeStack != null)
{
_branchNodeStack.Clear();
}
_sourceItemList.Clear();
}
19
Source : LiveShapingBlock.cs
with MIT License
from dotnet
with MIT License
from dotnet
RBFinger<LiveShapingItem> SearchLeft(LiveShapingItem item, int offset, Comparison<LiveShapingItem> comparison)
{
LiveShapingBlock foundBlock = this;
List<LiveShapingBlock> list = new List<LiveShapingBlock>(); // subtrees to explore
list.Add(LeftChildBlock);
// phase 1, walk up the tree looking for the item in each left-parent
LiveShapingBlock block, parent;
int first, last, size;
for (block = this, parent = block.ParentBlock; parent != null; block = parent, parent = block.ParentBlock)
{
if (parent.RightChildBlock == block)
{
parent.GetFirstAndLastCleanItems(out first, out last, out size);
// find where the search item belongs relative to the clean items
if (first >= size)
{ // no clean items - add the left subtree for later exploration
list.Add(parent.LeftChildBlock);
}
else if (comparison(item, parent.GereplacedemAt(last)) > 0)
{ // item belongs to the right of parent - no need to climb higher
break;
}
else if (comparison(item, parent.GereplacedemAt(first)) >= 0)
{ // item belongs in the parent
return parent.LocalSearch(item, first + 1, last, comparison);
}
else
{ // item belongs to the left of parent, thus also left of unexplored subtrees
list.Clear();
list.Add(parent.LeftChildBlock);
foundBlock = parent;
offset = first;
}
}
}
// phase 2, item wasn't found in a left-parent, so it belongs in one of the
// unexplored subtrees. Search them right-to-left, hoping item didn't move far.
Stack<LiveShapingBlock> stack = new Stack<LiveShapingBlock>(list);
while (stack.Count > 0)
{
block = stack.Pop();
if (block == null)
continue;
block.GetFirstAndLastCleanItems(out first, out last, out size);
if (first >= size)
{ // no clean items - explore the subtrees
stack.Push(block.LeftChildBlock);
stack.Push(block.RightChildBlock);
}
else if (comparison(item, block.GereplacedemAt(last)) > 0)
{ // item belongs to the right
stack.Clear();
stack.Push(block.RightChildBlock);
}
else if (comparison(item, block.GereplacedemAt(first)) >= 0)
{ // item belongs in the current block
return block.LocalSearch(item, first + 1, last, comparison);
}
else
{ // item belongs to the left of the block, or possibly in it
foundBlock = block;
offset = first;
stack.Push(block.LeftChildBlock);
}
}
// phase 3, item wasn't found within any block, so put it at the
// edge of the "found" block
int baseIndex;
GetRootAndIndex(foundBlock, out baseIndex);
return new RBFinger<LiveShapingItem>() { Node = foundBlock, Offset = offset, Index = baseIndex + offset };
}
19
Source : LiveShapingBlock.cs
with MIT License
from dotnet
with MIT License
from dotnet
RBFinger<LiveShapingItem> SearchRight(LiveShapingItem item, int offset, Comparison<LiveShapingItem> comparison)
{
LiveShapingBlock foundBlock = this;
List<LiveShapingBlock> list = new List<LiveShapingBlock>(); // subtrees to explore
list.Add(RightChildBlock);
// phase 1, walk up the tree looking for the item in each right-parent
LiveShapingBlock block, parent;
int first, last, size;
for (block = this, parent = block.ParentBlock; parent != null; block = parent, parent = block.ParentBlock)
{
if (parent.LeftChildBlock == block)
{
parent.GetFirstAndLastCleanItems(out first, out last, out size);
// find where the search item belongs relative to the clean items
if (first >= size)
{ // no clean items - add the right subtree for later exploration
list.Add(parent.RightChildBlock);
}
else if (comparison(item, parent.GereplacedemAt(first)) < 0)
{ // item belongs to the left of parent - no need to climb higher
break;
}
else if (comparison(item, parent.GereplacedemAt(last)) <= 0)
{ // item belongs in the parent
return parent.LocalSearch(item, first + 1, last, comparison);
}
else
{ // item belongs to the right of parent, thus also right of unexplored subtrees
list.Clear();
list.Add(parent.RightChildBlock);
foundBlock = parent;
offset = last + 1;
}
}
}
// phase 2, item wasn't found in a right-parent, so it belongs in one of the
// unexplored subtrees. Search them left-to-right, hoping item didn't move far.
Stack<LiveShapingBlock> stack = new Stack<LiveShapingBlock>(list);
while (stack.Count > 0)
{
block = stack.Pop();
if (block == null)
continue;
block.GetFirstAndLastCleanItems(out first, out last, out size);
if (first >= size)
{ // no clean items - explore the subtrees
stack.Push(block.RightChildBlock);
stack.Push(block.LeftChildBlock);
}
else if (comparison(item, block.GereplacedemAt(first)) < 0)
{ // item belongs to the left
stack.Clear();
stack.Push(block.LeftChildBlock);
}
else if (comparison(item, block.GereplacedemAt(last)) <= 0)
{ // item belongs in the current block
return block.LocalSearch(item, first + 1, last, comparison);
}
else
{ // item belongs to the right of the block, or possibly in it
foundBlock = block;
offset = last + 1;
stack.Push(block.RightChildBlock);
}
}
// phase 3, item wasn't found within any block, so put it at the
// edge of the "found" block
int baseIndex;
GetRootAndIndex(foundBlock, out baseIndex);
return new RBFinger<LiveShapingItem>() { Node = foundBlock, Offset = offset, Index = baseIndex + offset };
}
19
Source : XamlMarkupExtensionWriter.cs
with MIT License
from dotnet
with MIT License
from dotnet
public void Reset()
{
currentState = Start.State;
sb = new StringBuilder();
nodes.Clear();
failed = false;
}
19
Source : MeScanner.cs
with MIT License
from dotnet
with MIT License
from dotnet
private string ReadString()
{
bool escaped = false;
char quoteChar = NullChar;
bool atStart = true;
bool wasQuoted = false;
uint braceCount = 0; // To be compat with v3 which allowed balanced {} inside of strings
StringBuilder sb = new StringBuilder();
char ch;
while(!IsAtEndOfInput)
{
ch = CurrentChar;
// handle escaping and quoting first.
if(escaped)
{
sb.Append(Backslash);
sb.Append(ch);
escaped = false;
}
else if (quoteChar != NullChar)
{
if (ch == Backslash)
{
escaped = true;
}
else if (ch != quoteChar)
{
sb.Append(ch);
}
else
{
ch = CurrentChar;
quoteChar = NullChar;
break; // we are done.
}
}
// If we are inside of MarkupExtensionBracketCharacters for a particular property or position parameter,
// scoop up everything inside one by one, and keep track of nested Bracket Characters in the stack.
else if (_context.CurrentBracketModeParseParameters != null && _context.CurrentBracketModeParseParameters.IsBracketEscapeMode)
{
Stack<char> bracketCharacterStack = _context.CurrentBracketModeParseParameters.BracketCharacterStack;
if (_currentSpecialBracketCharacters.StartsEscapeSequence(ch))
{
bracketCharacterStack.Push(ch);
}
else if (_currentSpecialBracketCharacters.EndsEscapeSequence(ch))
{
if (_currentSpecialBracketCharacters.Match(bracketCharacterStack.Peek(), ch))
{
bracketCharacterStack.Pop();
}
else
{
throw new XamlParseException(this, SR.Get(SRID.InvalidClosingBracketCharacers, ch.ToString()));
}
}
else if (ch == Backslash)
{
escaped = true;
}
if (bracketCharacterStack.Count == 0)
{
_context.CurrentBracketModeParseParameters.IsBracketEscapeMode = false;
}
if (!escaped)
{
sb.Append(ch);
}
}
else
{
bool done = false;
switch (ch)
{
case Space:
if (_state == StringState.Type)
{
done = true; // we are done.
break;
}
sb.Append(ch);
break;
case OpenCurlie:
braceCount++;
sb.Append(ch);
break;
case CloseCurlie:
if (braceCount == 0)
{
done = true;
}
else
{
braceCount--;
sb.Append(ch);
}
break;
case Comma:
done = true; // we are done.
break;
case EqualSign:
_state = StringState.Property;
done = true; // we are done.
break;
case Backslash:
escaped = true;
break;
case Quote1:
case Quote2:
if (!atStart)
{
throw new XamlParseException(this, SR.Get(SRID.QuoteCharactersOutOfPlace));
}
quoteChar = ch;
wasQuoted = true;
break;
default: // All other character (including whitespace)
if (_currentSpecialBracketCharacters != null && _currentSpecialBracketCharacters.StartsEscapeSequence(ch))
{
Stack<char> bracketCharacterStack =
_context.CurrentBracketModeParseParameters.BracketCharacterStack;
bracketCharacterStack.Clear();
bracketCharacterStack.Push(ch);
_context.CurrentBracketModeParseParameters.IsBracketEscapeMode = true;
}
sb.Append(ch);
break;
}
if (done)
{
if (braceCount > 0)
{
throw new XamlParseException(this, SR.Get(SRID.UnexpectedTokenAfterME));
}
else
{
if (_context.CurrentBracketModeParseParameters?.BracketCharacterStack.Count > 0)
{
throw new XamlParseException(this, SR.Get(SRID.MalformedBracketCharacters, ch.ToString()));
}
}
PushBack();
break; // we are done.
}
}
atStart = false;
Advance();
}
if (quoteChar != NullChar)
{
throw new XamlParseException(this, SR.Get(SRID.UnclosedQuote));
}
string result = sb.ToString();
if (!wasQuoted)
{
result = result.TrimEnd(KnownStrings.WhitespaceChars);
result = result.TrimStart(KnownStrings.WhitespaceChars);
}
if (_state == StringState.Property)
{
_currentParameterName = result;
_currentSpecialBracketCharacters = GetBracketCharacterForProperty(_currentParameterName);
}
return result;
}
19
Source : WpfDrawingContext.cs
with MIT License
from dotnet-campus
with MIT License
from dotnet-campus
public void Clear()
{
if (_drawStack != null)
{
_drawStack.Clear();
}
}
19
Source : ScriptingStackDebugSupport.cs
with MIT License
from Dotneteer
with MIT License
from Dotneteer
public void ClearStepOutStack()
{
_stepOutStack.Clear();
}
19
Source : SymbolExtensions.cs
with GNU General Public License v3.0
from Dreamescaper
with GNU General Public License v3.0
from Dreamescaper
public static string GetNamespace(this ISymbol symbol)
{
// ToDisplayString would work here as well, but it is slower
if (!stackPool.TryTake(out var nsNames))
nsNames = new Stack<string>(DefaultSize);
try
{
while (symbol != null)
{
if (symbol is INamespaceSymbol nsSymbol)
{
if (nsSymbol.IsGlobalNamespace)
{
break;
}
nsNames.Push(symbol.Name);
}
symbol = symbol.ContainingSymbol;
}
return string.Join(".", nsNames.ToArray());
}
finally
{
nsNames.Clear();
stackPool.Add(nsNames);
}
}
19
Source : NodeUtils.cs
with MIT License
from ecidevilin
with MIT License
from ecidevilin
public static ShaderStage GetEffectiveShaderStage(MaterialSlot initialSlot, bool goingBackwards)
{
var graph = initialSlot.owner.owner;
s_SlotStack.Clear();
s_SlotStack.Push(initialSlot);
while (s_SlotStack.Any())
{
var slot = s_SlotStack.Pop();
ShaderStage stage;
if (slot.stageCapability.TryGetShaderStage(out stage))
return stage;
if (goingBackwards && slot.isInputSlot)
{
foreach (var edge in graph.GetEdges(slot.slotReference))
{
var node = graph.GetNodeFromGuid(edge.outputSlot.nodeGuid);
s_SlotStack.Push(node.FindOutputSlot<MaterialSlot>(edge.outputSlot.slotId));
}
}
else if (!goingBackwards && slot.isOutputSlot)
{
foreach (var edge in graph.GetEdges(slot.slotReference))
{
var node = graph.GetNodeFromGuid(edge.inputSlot.nodeGuid);
s_SlotStack.Push(node.FindInputSlot<MaterialSlot>(edge.inputSlot.slotId));
}
}
else
{
var ownerSlots = Enumerable.Empty<MaterialSlot>();
if (goingBackwards && slot.isOutputSlot)
ownerSlots = slot.owner.GetInputSlots<MaterialSlot>();
else if (!goingBackwards && slot.isInputSlot)
ownerSlots = slot.owner.GetOutputSlots<MaterialSlot>();
foreach (var ownerSlot in ownerSlots)
s_SlotStack.Push(ownerSlot);
}
}
// We default to fragment shader stage if all connected nodes were compatible with both.
return ShaderStage.Fragment;
}
19
Source : NodeUtils.cs
with MIT License
from ecidevilin
with MIT License
from ecidevilin
public static ShaderStageCapability GetEffectiveShaderStageCapability(MaterialSlot initialSlot, bool goingBackwards)
{
var graph = initialSlot.owner.owner;
s_SlotStack.Clear();
s_SlotStack.Push(initialSlot);
while (s_SlotStack.Any())
{
var slot = s_SlotStack.Pop();
ShaderStage stage;
if (slot.stageCapability.TryGetShaderStage(out stage))
return slot.stageCapability;
if (goingBackwards && slot.isInputSlot)
{
foreach (var edge in graph.GetEdges(slot.slotReference))
{
var node = graph.GetNodeFromGuid(edge.outputSlot.nodeGuid);
s_SlotStack.Push(node.FindOutputSlot<MaterialSlot>(edge.outputSlot.slotId));
}
}
else if (!goingBackwards && slot.isOutputSlot)
{
foreach (var edge in graph.GetEdges(slot.slotReference))
{
var node = graph.GetNodeFromGuid(edge.inputSlot.nodeGuid);
s_SlotStack.Push(node.FindInputSlot<MaterialSlot>(edge.inputSlot.slotId));
}
}
else
{
var ownerSlots = Enumerable.Empty<MaterialSlot>();
if (goingBackwards && slot.isOutputSlot)
ownerSlots = slot.owner.GetInputSlots<MaterialSlot>();
else if (!goingBackwards && slot.isInputSlot)
ownerSlots = slot.owner.GetOutputSlots<MaterialSlot>();
foreach (var ownerSlot in ownerSlots)
s_SlotStack.Push(ownerSlot);
}
}
return ShaderStageCapability.All;
}
19
Source : GraphEditorView.cs
with MIT License
from ecidevilin
with MIT License
from ecidevilin
void UpdateEdgeColors(HashSet<MaterialNodeView> nodeViews)
{
var nodeStack = m_NodeStack;
nodeStack.Clear();
foreach (var nodeView in nodeViews)
nodeStack.Push(nodeView);
while (nodeStack.Any())
{
var nodeView = nodeStack.Pop();
nodeView.UpdatePortInputTypes();
foreach (var anchorView in nodeView.outputContainer.Children().OfType<Port>())
{
foreach (var edgeView in anchorView.connections.OfType<Edge>())
{
var targetSlot = edgeView.input.GetSlot();
if (targetSlot.valueType == SlotValueType.DynamicVector || targetSlot.valueType == SlotValueType.DynamicMatrix || targetSlot.valueType == SlotValueType.Dynamic)
{
var connectedNodeView = edgeView.input.node as MaterialNodeView;
if (connectedNodeView != null && !nodeViews.Contains(connectedNodeView))
{
nodeStack.Push(connectedNodeView);
nodeViews.Add(connectedNodeView);
}
}
}
}
foreach (var anchorView in nodeView.inputContainer.Children().OfType<Port>())
{
var targetSlot = anchorView.GetSlot();
if (targetSlot.valueType != SlotValueType.DynamicVector)
continue;
foreach (var edgeView in anchorView.connections.OfType<Edge>())
{
var connectedNodeView = edgeView.output.node as MaterialNodeView;
if (connectedNodeView != null && !nodeViews.Contains(connectedNodeView))
{
nodeStack.Push(connectedNodeView);
nodeViews.Add(connectedNodeView);
}
}
}
}
}
19
Source : PreviewManager.cs
with MIT License
from ecidevilin
with MIT License
from ecidevilin
void PropagateNodeSet(IndexSet nodeSet, bool forward = true, IEnumerable<Identifier> initialWavefront = null)
{
m_Wavefront.Clear();
if (initialWavefront != null)
{
foreach (var id in initialWavefront)
m_Wavefront.Push(id);
}
else
{
foreach (var index in nodeSet)
m_Wavefront.Push(m_Identifiers[index]);
}
while (m_Wavefront.Count > 0)
{
var index = m_Wavefront.Pop();
var node = m_Graph.GetNodeFromTempId(index);
if (node == null)
continue;
// Loop through all nodes that the node feeds into.
m_Slots.Clear();
if (forward)
node.GetOutputSlots(m_Slots);
else
node.GetInputSlots(m_Slots);
foreach (var slot in m_Slots)
{
m_Edges.Clear();
m_Graph.GetEdges(slot.slotReference, m_Edges);
foreach (var edge in m_Edges)
{
// We look at each node we feed into.
var connectedSlot = forward ? edge.inputSlot : edge.outputSlot;
var connectedNodeGuid = connectedSlot.nodeGuid;
var connectedNode = m_Graph.GetNodeFromGuid(connectedNodeGuid);
// If the input node is already in the set of time-dependent nodes, we don't need to process it.
if (nodeSet.Contains(connectedNode.tempId.index))
continue;
// Add the node to the set of time-dependent nodes, and to the wavefront such that we can process the nodes that it feeds into.
nodeSet.Add(connectedNode.tempId.index);
m_Wavefront.Push(connectedNode.tempId);
}
}
}
}
19
Source : ConvexHullInternal.cs
with GNU Lesser General Public License v3.0
from Edgar077
with GNU Lesser General Public License v3.0
from Edgar077
void TraverseAffectedFaces(ConvexFaceInternal currentFace)
{
TraverseStack.Clear();
TraverseStack.Push(currentFace);
currentFace.Tag = 1;
while (TraverseStack.Count > 0)
{
var top = TraverseStack.Pop();
for (int i = 0; i < Dimension; i++)
{
var adjFace = top.AdjacentFaces[i];
if (adjFace.Tag == 0 && MathHelper.GetVertexDistance(CurrentVertex, adjFace) >= Constants.PlaneDistanceTolerance)
{
AffectedFaceBuffer.Add(adjFace);
adjFace.Tag = 1;
TraverseStack.Push(adjFace);
}
}
}
}
See More Examples