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
View Source File : TemplateEngin.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
private static string codeTreeEnd(Stack<string> codeTree, string tag) {
string ret = string.Empty;
Stack<int> pop = new Stack<int>();
foreach (string ct in codeTree) {
if (ct == "import" ||
ct == "include") {
pop.Push(1);
} else if (ct == tag) {
pop.Push(2);
break;
} else {
if (string.IsNullOrEmpty(tag) == false) pop.Clear();
break;
}
}
if (pop.Count == 0 && string.IsNullOrEmpty(tag) == false)
return string.Concat("语法错误,{", tag, "} {/", tag, "} 并没配对");
while (pop.Count > 0 && pop.Pop() > 0) codeTree.Pop();
return ret;
}
19
View Source File : JsonWriter.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public void Reset ()
{
has_reached_end = false;
ctx_stack.Clear ();
context = new WriterContext ();
ctx_stack.Push (context);
if (inst_string_builder != null)
inst_string_builder.Remove (0, inst_string_builder.Length);
}
19
View Source File : JsonReader.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public bool Read ()
{
if (end_of_input)
return false;
if (end_of_json) {
end_of_json = false;
automaton_stack.Clear ();
automaton_stack.Push ((int) ParserToken.End);
automaton_stack.Push ((int) ParserToken.Text);
}
parser_in_string = false;
parser_return = false;
token = JsonToken.None;
token_value = null;
if (! read_started) {
read_started = true;
if (! ReadToken ())
return false;
}
int[] entry_symbols;
while (true) {
if (parser_return) {
if (automaton_stack.Peek () == (int) ParserToken.End)
end_of_json = true;
return true;
}
current_symbol = automaton_stack.Pop ();
ProcessSymbol ();
if (current_symbol == current_input) {
if (! ReadToken ()) {
if (automaton_stack.Peek () != (int) ParserToken.End)
throw new JsonException (
"Input doesn't evaluate to proper JSON text");
if (parser_return)
return true;
return false;
}
continue;
}
try {
entry_symbols =
parse_table[current_symbol][current_input];
} catch (KeyNotFoundException e) {
throw new JsonException ((ParserToken) current_input, e);
}
if (entry_symbols[0] == (int) ParserToken.Epsilon)
continue;
for (int i = entry_symbols.Length - 1; i >= 0; i--)
automaton_stack.Push (entry_symbols[i]);
}
}
19
View Source File : IExpressionNodeExtensions.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
private static Stack<IExpressionNode> GetMatchSegments(IExpressionNode node)
{
var result = new Stack<IExpressionNode>();
// Node is a named-value
if (node is NamedValue)
{
result.Push(node);
}
// Node is an index
else if (node is Sdk.Operators.Index index)
{
while (true)
{
// Push parameter 1. Treat anything other than literal as a wildcard.
var parameter1 = index.Parameters[1];
result.Push(parameter1 is Literal ? parameter1 : new Wildcard());
var parameter0 = index.Parameters[0];
// Parameter 0 is a named-value
if (parameter0 is NamedValue)
{
result.Push(parameter0);
break;
}
// Parameter 0 is an index
else if (parameter0 is Sdk.Operators.Index index2)
{
index = index2;
}
// Otherwise clear
else
{
result.Clear();
break;
}
}
}
return result;
}
19
View Source File : ILASTBuilder.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a
License : GNU General Public License v3.0
Project Creator : Aekras1a
private ILASTTree BuildAST(CILInstrList instrs, ILASTVariable[] beginStack)
{
var tree = new ILASTTree();
var evalStack = new Stack<ILASTVariable>(beginStack);
Func<int, IILASTNode[]> popArgs = numArgs =>
{
var args = new IILASTNode[numArgs];
for(var i = numArgs - 1; i >= 0; i--)
args[i] = evalStack.Pop();
return args;
};
var prefixes = new List<Instruction>();
foreach(var instr in instrs)
{
if(instr.OpCode.OpCodeType == OpCodeType.Prefix)
{
prefixes.Add(instr);
continue;
}
int pushes, pops;
ILASTExpression expr;
if(instr.OpCode.Code == Code.Dup)
{
pushes = pops = 1;
var arg = evalStack.Peek();
expr = new ILASTExpression
{
ILCode = Code.Dup,
Operand = null,
Arguments = new IILASTNode[] {arg}
};
}
else
{
instr.CalculateStackUsage(method.ReturnType.ElementType != ElementType.Void, out pushes, out pops);
Debug.replacedert(pushes == 0 || pushes == 1);
if(pops == -1)
{
evalStack.Clear();
pops = 0;
}
expr = new ILASTExpression
{
ILCode = instr.OpCode.Code,
Operand = instr.Operand,
Arguments = popArgs(pops)
};
if(expr.Operand is Instruction || expr.Operand is Instruction[])
instrReferences.Add(expr);
}
expr.CILInstr = instr;
if(prefixes.Count > 0)
{
expr.Prefixes = prefixes.ToArray();
prefixes.Clear();
}
if(pushes == 1)
{
var variable = new ILASTVariable
{
Name = string.Format("s_{0:x4}", instr.Offset),
VariableType = ILASTVariableType.StackVar
};
evalStack.Push(variable);
tree.Add(new ILASTreplacedignment
{
Variable = variable,
Value = expr
});
}
else
{
tree.Add(expr);
}
}
tree.StackRemains = evalStack.Reverse().ToArray();
return tree;
}
19
View Source File : UnsafeResourcePool.cs
License : The Unlicense
Project Creator : aeroson
License : The Unlicense
Project Creator : aeroson
public override void Clear()
{
stack.Clear();
}
19
View Source File : ArrayPool.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
public void Clear()
{
for (int i = 0; i <= SpanHelper.MaximumSpanSizePower; ++i)
{
pools[i].Clear();
}
}
19
View Source File : DynamicTree.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
public void Query(Func<int, 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(nodeId);
if (proceed == false)
{
return;
}
}
else
{
_queryStack.Push(node.Child1);
_queryStack.Push(node.Child2);
}
}
}
}
19
View Source File : DynamicTree.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
public void RayCast(Func<RayCastInput, int, float> callback, ref RayCastInput input)
{
Vector2 p1 = input.Point1;
Vector2 p2 = input.Point2;
Vector2 r = p2 - p1;
Debug.replacedert(r.LengthSquared() > 0.0f);
r.Normalize();
// v is perpendicular to the segment.
Vector2 absV = MathUtils.Abs(new Vector2(-r.Y, r.X)); //FPE: Inlined the 'v' variable
// Separating axis for segment (Gino, p80).
// |dot(v, p1 - c)| > dot(|v|, h)
float maxFraction = input.MaxFraction;
// Build a bounding box for the segment.
AABB segmentAABB = new AABB();
{
Vector2 t = p1 + maxFraction * (p2 - p1);
Vector2.Min(ref p1, ref t, out segmentAABB.LowerBound);
Vector2.Max(ref p1, ref t, out segmentAABB.UpperBound);
}
_raycastStack.Clear();
_raycastStack.Push(_root);
while (_raycastStack.Count > 0)
{
int nodeId = _raycastStack.Pop();
if (nodeId == NullNode)
{
continue;
}
TreeNode<T> node = _nodes[nodeId];
if (AABB.TestOverlap(ref node.AABB, ref segmentAABB) == false)
{
continue;
}
// Separating axis for segment (Gino, p80).
// |dot(v, p1 - c)| > dot(|v|, h)
Vector2 c = node.AABB.Center;
Vector2 h = node.AABB.Extents;
float separation = Math.Abs(Vector2.Dot(new Vector2(-r.Y, r.X), p1 - c)) - Vector2.Dot(absV, h);
if (separation > 0.0f)
{
continue;
}
if (node.IsLeaf())
{
RayCastInput subInput;
subInput.Point1 = input.Point1;
subInput.Point2 = input.Point2;
subInput.MaxFraction = maxFraction;
float value = callback(subInput, nodeId);
if (value == 0.0f)
{
// the client has terminated the raycast.
return;
}
if (value > 0.0f)
{
// Update segment bounding box.
maxFraction = value;
Vector2 t = p1 + maxFraction * (p2 - p1);
segmentAABB.LowerBound = Vector2.Min(p1, t);
segmentAABB.UpperBound = Vector2.Max(p1, t);
}
}
else
{
_raycastStack.Push(node.Child1);
_raycastStack.Push(node.Child2);
}
}
}
19
View Source File : Pool.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
public void Clear()
{
stack.Clear();
}
19
View Source File : BaseNode.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
public bool UpdatePortsForField(string fieldName, bool sendPortUpdatedEvent = true)
{
bool changed = false;
fieldsToUpdate.Clear();
updatedFields.Clear();
fieldsToUpdate.Push(new PortUpdate{fieldNames = new List<string>(){fieldName}, node = this});
// Iterate through all the ports that needs to be updated, following graph connection when the
// port is updated. This is required ton have type propagation multiple nodes that changes port types
// are connected to each other (i.e. the relay node)
while (fieldsToUpdate.Count != 0)
{
var (fields, node) = fieldsToUpdate.Pop();
// Avoid updating twice a port
if (updatedFields.Any((t) => t.node == node && fields.SequenceEqual(t.fieldNames)))
continue;
updatedFields.Add(new PortUpdate{fieldNames = fields, node = node});
foreach (var field in fields)
{
if (node.UpdatePortsForFieldLocal(field, sendPortUpdatedEvent))
{
foreach (var port in node.IsFieldInput(field) ? (NodePortContainer)node.inputPorts : node.outputPorts)
{
if (port.fieldName != field)
continue;
foreach(var edge in port.GetEdges())
{
var edgeNode = (node.IsFieldInput(field)) ? edge.outputNode : edge.inputNode;
var fieldsWithBehavior = edgeNode.nodeFields.Values.Where(f => HasCustomBehavior(f)).Select(f => f.fieldName).ToList();
fieldsToUpdate.Push(new PortUpdate{fieldNames = fieldsWithBehavior, node = edgeNode});
}
}
changed = true;
}
}
}
return changed;
}
19
View Source File : MixtureGraphProcessor.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
void ProcessNodeList(CommandBuffer cmd, HashSet<BaseNode> nodes)
{
HashSet<ILoopStart> starts = new HashSet<ILoopStart>();
HashSet<ILoopEnd> ends = new HashSet<ILoopEnd>();
HashSet<INeedLoopReset> iNeedLoopReset = new HashSet<INeedLoopReset>();
// Note that this jump pattern doesn't handle correctly the multiple dependencies a for loop
// can have and it may cause some nodes to be processed multiple times unnecessarily, depending on the compute order.
Stack<(ILoopStart node, int index)> jumps = new Stack<(ILoopStart, int)>();
// TODO: cache?
var sortedNodes = nodes.Where(n => n.computeOrder >= 0).OrderBy(n => n.computeOrder).ToList();
int maxLoopCount = 0;
jumps.Clear();
starts.Clear();
ends.Clear();
iNeedLoopReset.Clear();
for (int executionIndex = 0; executionIndex < sortedNodes.Count; executionIndex++)
{
maxLoopCount++;
if (maxLoopCount > 10000)
return;
var node = sortedNodes[executionIndex];
if (node is ILoopStart loopStart)
{
if (!starts.Contains(loopStart))
{
loopStart.PrepareLoopStart();
jumps.Push((loopStart, executionIndex));
starts.Add(loopStart);
}
}
bool finalIteration = false;
if (node is ILoopEnd loopEnd)
{
if (jumps.Count == 0)
{
Debug.Log("Aborted execution, for end without start");
return ;
}
var startLoop = jumps.Peek();
if (!ends.Contains(loopEnd))
{
loopEnd.PrepareLoopEnd(startLoop.node);
ends.Add(loopEnd);
}
// Jump back to the foreach start
if (!startLoop.node.IsLasreplacederation())
{
executionIndex = startLoop.index - 1;
}
else
{
var fs2 = jumps.Pop();
starts.Remove(fs2.node);
ends.Remove(loopEnd);
finalIteration = true;
}
}
if (node is INeedLoopReset i)
{
if (!iNeedLoopReset.Contains(i))
{
i.PrepareNewIteration();
iNeedLoopReset.Add(i);
}
// TODO: remove this node form iNeedLoopReset when we go over a foreach start again
}
if (finalIteration && node is ILoopEnd le)
{
le.FinalIteration();
}
ProcessNode(cmd, node);
}
}
19
View Source File : UndoRedoSystem.cs
License : MIT License
Project Creator : AlFasGD
License : MIT License
Project Creator : AlFasGD
public void RegisterActions(string description = null)
{
TemporaryUndoableAction.Description = description ?? DefaultDescription;
UndoStack.Push(TemporaryUndoableAction);
TemporaryUndoableAction = new UndoableAction();
RedoStack.Clear();
}
19
View Source File : TCompactProtocol.cs
License : MIT License
Project Creator : aloneguid
License : MIT License
Project Creator : aloneguid
public void reset()
{
lastField_.Clear();
lastFieldId_ = 0;
}
19
View Source File : InputManager.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
public void ClearModalInputStack()
{
modalInputStack.Clear();
}
19
View Source File : InputManager.cs
License : MIT License
Project Creator : anderm
License : MIT License
Project Creator : anderm
public void ClearFallbackInputStack()
{
fallbackInputStack.Clear();
}
19
View Source File : UndoManager.cs
License : MIT License
Project Creator : AnnoDesigner
License : MIT License
Project Creator : AnnoDesigner
public void Clear()
{
UndoStack.Clear();
RedoStack.Clear();
IsDirty = false;
}
19
View Source File : UndoManager.cs
License : MIT License
Project Creator : AnnoDesigner
License : MIT License
Project Creator : AnnoDesigner
public void RegisterOperation(IOperation operation)
{
if (CurrentCompositeOperation != null)
{
CurrentCompositeOperation.Operations.Add(operation);
}
else
{
UndoStack.Push(operation);
RedoStack.Clear();
}
}
19
View Source File : IMGUI.cs
License : MIT License
Project Creator : Apostolique
License : MIT License
Project Creator : Apostolique
private void Cleanup() {
Reset();
foreach (var kc in _activeComponents.Reverse()) {
if (kc.Value.LastPing != InputHelper.CurrentFrame - 1) {
Remove(kc.Key, kc.Value);
}
}
_currentParent = this;
_maxChildren = 0;
_childrenCount = 0;
_parents.Clear();
_idsUsedThisFrame.Clear();
}
19
View Source File : TemplateDocument.cs
License : MIT License
Project Creator : aprilyush
License : MIT License
Project Creator : aprilyush
private void ParseString(Template ownerTemplate, Tag container, string text)
{
//设置根文档模板
this.DoreplacedentElement = ownerTemplate;
//this.Text = text;
if (string.IsNullOrEmpty(text)) return;
int charOffset = 0, offset = 0;
bool isClosedTag;
Match match = null;
//标签堆栈
Stack<Tag> tagStack = new Stack<Tag>();
tagStack.Push(container);
try
{
while (offset < text.Length)
{
if (ParserHelper.IsVariableTagStart(text, offset) && (match = ParserRegex.VarTagRegex.Match(text, offset)).Success) //匹配到模板变量
{
//构建文本节点
ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, match.Index - charOffset);
//构建模板变量
ParserHelper.CreateVariableTag(ownerTemplate, container, match);
}
else if (ParserHelper.IsTagStart(text, offset) && (match = ParserRegex.TagRegex.Match(text, offset)).Success) //匹配到某种类型的标签
{
//构建文本节点
ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, match.Index - charOffset);
//构建标签
Tag tag = ParserHelper.CreateTag(ownerTemplate, match, out isClosedTag);
//将标签加入堆栈
tagStack.Push(tag);
//将解析权交给标签
bool flag = tag.ProcessBeginTag(ownerTemplate, container, tagStack, text, ref match, isClosedTag);
//非已闭合标签或者是单标签则处理标签的结束标签
if (flag)
{
tag.ProcessEndTag(ownerTemplate, tag, tagStack, text, ref match);
}
if (tagStack.Count > 0 && tagStack.Peek() == tag && isClosedTag)
{
//闭合标签则回滚一级
tagStack.Pop();
}
//取得容器
if (tagStack.Count > 0) container = tagStack.Peek();
}
else if (ParserHelper.IsCloseTagStart(text, offset) && (match = ParserRegex.EndTagRegex.Match(text, offset)).Success) //匹配到某个结束标签
{
//取得标签名称
string name = match.Groups["tagname"].Value;
//非匹配的结束标签.则模板有错
throw new ParserException("无效的结束标签");
}
else if (ParserHelper.IsVTExpressionStart(text, offset))
{
char s = ParserHelper.ReadChar(text, offset + ParserHelper.VTExpressionHead.Length);
int startOffset = offset + ParserHelper.VTExpressionHead.Length + 1;
int lastOffset = text.IndexOf(s, offset + ParserHelper.VTExpressionHead.Length + 1);
if (lastOffset == -1) throw new ParserException(string.Format("无法找到VT表达式\"{0}\"的结束标记", ParserHelper.VTExpressionHead));
string code = text.Substring(startOffset, lastOffset - startOffset);
if (code.Length > 0)
{
//构建文本节点
ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, offset - charOffset);
//解析表达式里的代码
new TemplateDoreplacedent(ownerTemplate, container, code, ownerTemplate.OwnerDoreplacedent.DoreplacedentConfig);
}
offset = lastOffset + 1;
charOffset = offset;
continue;
}
else if (ParserHelper.IsCommentTagStart(text, offset))
{
//构建文本节点
ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, offset - charOffset);
//找到注释的起始标记"<!--vt[",则直接查找结束标记"]-->"
offset = text.IndexOf(ParserHelper.CommentTagEnd, offset + ParserHelper.CommentTagStart.Length);
if (offset == -1) throw new ParserException("无法找到注释的结束标记");
offset += ParserHelper.CommentTagEnd.Length;
charOffset = offset;
continue;
}
//处理偏移位置
if (match != null && match.Success)
{
charOffset = offset = match.Index + match.Length;
match = null;
}
else
{
offset++;
}
}
//处理文本字符
ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, text.Length - charOffset);
if (tagStack.Count > 1)
{
//堆栈里还有其它元素.则有错误
throw new ParserException(string.Format("{0}标签未闭合", tagStack.Pop()));
}
}
catch (ParserException ex)
{
//如果错误中不包含行号与列号.则计算行号与列号
if (!ex.HaveLineAndColumnNumber && match != null && match.Success)
{
//获取当前出错时正在解析的模板文件
string file = string.Empty;
Tag tag = container;
while (string.IsNullOrEmpty(file) && tag != null)
{
if (tag is Template)
{
file = ((Template)tag).File;
}
else if (tag is IncludeTag)
{
file = ((IncludeTag)tag).File;
}
tag = tag.Parent;
}
if (string.IsNullOrEmpty(file))
{
throw new ParserException(Utility.GetLineAndColumnNumber(text, match.Index), match.ToString(), ex.Message);
}
else
{
throw new ParserException(file, Utility.GetLineAndColumnNumber(text, match.Index), match.ToString(), ex.Message);
}
}
else
{
//继续抛出错误
throw;
}
}
finally
{
//清空堆栈
tagStack.Clear();
tagStack = null;
}
}
19
View Source File : UndoRedoStack.cs
License : MIT License
Project Creator : Aragas
License : MIT License
Project Creator : Aragas
public void Do(IAction action)
{
action.DoAction();
UndoStack.Push(action);
RedoStack.Clear();
}
19
View Source File : UndoRedoStack.cs
License : MIT License
Project Creator : Aragas
License : MIT License
Project Creator : Aragas
public void ClearStack()
{
UndoStack.Clear();
RedoStack.Clear();
}
19
View Source File : RegexLexer.cs
License : MIT License
Project Creator : arbelatech
License : MIT License
Project Creator : arbelatech
protected override IEnumerable<Token> GetTokensUnprocessed(string text)
{
var rules = GetStateRules();
int pos = 0;
var stateStack = new Stack<string>(50);
stateStack.Push("root");
var currentStateRules = rules[stateStack.Peek()];
while (true)
{
bool found = false;
foreach (var rule in currentStateRules)
{
var m = rule.Regex.Match(text, pos);
if (m.Success)
{
var context = new RegexLexerContext(pos, m, stateStack, rule.TokenType);
Debug.replacedert(m.Index == pos, $"Regex \"{rule.Regex}\" should have matched at position {pos} but matched at {m.Index}");
var tokens = rule.Action.Execute(context);
foreach (var token in tokens)
yield return token;
pos = context.Position;
currentStateRules = rules[stateStack.Peek()];
found = true;
break;
}
}
if (!found)
{
if (pos >= text.Length)
break;
if (text[pos] == '\n')
{
stateStack.Clear();
stateStack.Push("root");
currentStateRules = rules["root"];
yield return new Token(pos, TokenTypes.Text, "\n");
pos++;
continue;
}
yield return new Token(pos, TokenTypes.Error, text[pos].ToString());
pos++;
}
}
}
19
View Source File : ShaderDebugger.cs
License : MIT License
Project Creator : arigo
License : MIT License
Project Creator : arigo
void SceneGUICallback(SceneView scene_view)
{
if (Event.current.type != EventType.Repaint)
return;
if (!freeze_view && (Time.unscaledTime != most_recent_load || display_roots == null ||
display_roots.Length != display_count))
{
if (buffer == null || buffer.count == 0)
return;
most_recent_count = GetBufferLength();
if (most_recent_count > debug_array.Length)
most_recent_count = debug_array.Length;
buffer.GetData(debug_array, 0, 0, most_recent_count);
Matrix4x4 times_half_plus_half = Matrix4x4.idenreplacedy;
times_half_plus_half.SetTRS(new Vector3(0.5f, 0.5f, 0), Quaternion.idenreplacedy, new Vector3(0.5f, 0.5f, 1));
mat_screen2cam = Matrix4x4.Inverse(Matrix4x4.Scale(buf_scale) * times_half_plus_half * buf_projmat);
mat_cam2world = Matrix4x4.Inverse(buf_world2camera);
display_roots = new uint[display_count];
if (most_recent_count > 1)
{
/* first try to see if there are <= display_count entries in total */
int total = 0;
for (uint j = 1; j < most_recent_count; j++)
if (debug_array[j].kind == _DEBUG_ROOT)
{
total++;
if (total > display_count)
break;
}
if (total > display_count)
{
/* too many entries: sample randomly */
for (int i = 0; i < display_count; i++)
{
uint j = (uint)Random.Range(1, most_recent_count);
while (debug_array[j].next < j)
j = debug_array[j].next;
Debug.replacedert(debug_array[j].kind == _DEBUG_ROOT);
display_roots[i] = j;
}
}
else
{
/* not too many entries: pick them all */
total = 0;
for (uint j = 1; j < most_recent_count; j++)
if (debug_array[j].kind == _DEBUG_ROOT)
display_roots[total++] = j;
}
}
most_recent_load = Time.unscaledTime;
}
Handles.matrix = Matrix4x4.idenreplacedy;
stack.Clear();
textlines.Clear();
if (display_roots != null && debug_array != null)
for (int i = 0; i < display_roots.Length; i++)
DisplayHandle(display_roots[i]);
}
19
View Source File : InspectorUtility.cs
License : MIT License
Project Creator : arimger
License : MIT License
Project Creator : arimger
private static void OnBreakEditor(Editor editor)
{
cachedEditors.Clear();
}
19
View Source File : BitmapCanvas.cs
License : Apache License 2.0
Project Creator : ascora
License : Apache License 2.0
Project Creator : ascora
public void Clear(Color color)
{
UpdateDrawingSessionWithFlags(0);
CurrentRenderTarget.Clear(color);
_matrixSaves.Clear();
_flagSaves.Clear();
_clipSaves.Clear();
}
19
View Source File : BitmapCanvas.cs
License : Apache License 2.0
Project Creator : ascora
License : Apache License 2.0
Project Creator : ascora
internal IDisposable CreateSession(float width, float height, DeviceContext drawingSession)
{
_canvasDrawingSessions.Clear();
//_renderTarget = drawingSession;
_canvasDrawingSessions.Push(new RenderTargetHolder { RenderTarget = drawingSession });
UpdateClip(width, height);
return PushMask(_currentClip, 1f);
//return new Disposable(() => { });
}
19
View Source File : DialogueController.cs
License : MIT License
Project Creator : ashblue
License : MIT License
Project Creator : ashblue
public void Stop () {
foreach (var dialogue in _activeDialogue) {
dialogue.Stop();
}
_activeDialogue.Clear();
}
19
View Source File : Invoker.cs
License : MIT License
Project Creator : AshV
License : MIT License
Project Creator : AshV
public void flush()
{
undo_commands.Clear();
redo_commands.Clear();
}
19
View Source File : Behavior.cs
License : Apache License 2.0
Project Creator : asynkron
License : Apache License 2.0
Project Creator : asynkron
public void Become(Receive receive)
{
_behaviors.Clear();
_behaviors.Push(receive);
}
19
View Source File : TextTransformation.cs
License : MIT License
Project Creator : atifaziz
License : MIT License
Project Creator : atifaziz
public void ClearIndent ()
{
currentIndent = string.Empty;
Indents.Clear ();
}
19
View Source File : Detection.cs
License : MIT License
Project Creator : audinowho
License : MIT License
Project Creator : audinowho
public static List<Rect> FindAllRects(bool[][] grid)
{
List<Rect> resultRects = new List<Rect>();
// create a pre-process where each grid value actually indicates how many 1's are below it
int[][] intGrid = new int[grid.Length][];
for (int xx = 0; xx < grid.Length; xx++)
{
intGrid[xx] = new int[grid[0].Length];
// first line (bottom)
if (grid[xx][grid[0].Length - 1])
intGrid[xx][grid[0].Length - 1] = 1;
// all lines above the first line
for (int yy = grid[0].Length - 2; yy >= 0; yy--)
{
if (grid[xx][yy])
intGrid[xx][yy] = intGrid[xx][yy + 1] + 1;
}
}
// go through each row with the histogram approach; capacity is known so might as well specify it here
Stack<int> prevShadow = new Stack<int>(intGrid.Length);
for (int yy = 0; yy < intGrid[0].Length; yy++)
{
prevShadow.Clear();
prevShadow.Push(-1);
int prevZero = -1;
for (int xx = 0; xx < intGrid.Length; xx++)
{
// encountered a smaller number? compute rectangles with all stack values greater than the current number
int prevHistogram = prevShadow.Peek() > -1 ? intGrid[prevShadow.Peek()][yy] : 0;
while (intGrid[xx][yy] <= prevHistogram)
{
prevShadow.Pop();
if (prevHistogram == intGrid[xx][yy])
break;
// this new rectangle is not a subset of a larger rectangle if...
// for the row above this rectangle, the position of 1's going back to the start of the rectangle
// is GREATER than the end border (exclusive) of this rectangle.
// if it's equal or less, this rectangle is a subset and should not be counted
// so just keep track of the last zero
if (prevZero > prevShadow.Peek())
resultRects.Add(new Rect(prevShadow.Peek() + 1, yy, xx - (prevShadow.Peek() + 1), prevHistogram));
prevHistogram = prevShadow.Peek() > -1 ? intGrid[prevShadow.Peek()][yy] : 0;
}
prevShadow.Push(xx);
if (yy <= 0 || intGrid[xx][yy - 1] == 0)
prevZero = xx;
}
// close out with one last 0.
int lastHistogram = prevShadow.Peek() > -1 ? intGrid[prevShadow.Peek()][yy] : 0;
while (lastHistogram > 0)
{
prevShadow.Pop();
// check on prevZero here too
if (prevZero > prevShadow.Peek())
resultRects.Add(new Rect(prevShadow.Peek() + 1, yy, intGrid.Length - (prevShadow.Peek() + 1), lastHistogram));
lastHistogram = prevShadow.Peek() > -1 ? intGrid[prevShadow.Peek()][yy] : 0;
}
}
return resultRects;
}
19
View Source File : RegionNavigationJournal.cs
License : MIT License
Project Creator : AvaloniaCommunity
License : MIT License
Project Creator : AvaloniaCommunity
public void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory)
{
if (!this.isNavigatingInternal)
{
if (this.CurrentEntry != null && persistInHistory)
{
this.backStack.Push(this.CurrentEntry);
}
this.forwardStack.Clear();
this.CurrentEntry = entry;
}
}
19
View Source File : RegionNavigationJournal.cs
License : MIT License
Project Creator : AvaloniaCommunity
License : MIT License
Project Creator : AvaloniaCommunity
public void Clear()
{
this.CurrentEntry = null;
this.backStack.Clear();
this.forwardStack.Clear();
}
19
View Source File : QuickLinkedList.cs
License : MIT License
Project Creator : Avatarchik
License : MIT License
Project Creator : Avatarchik
public void Clear()
{
_emptyIds.Clear();
_list.Clear();
_first = -1;
_last = -1;
}
19
View Source File : MySqlSelectBuilder.cs
License : MIT License
Project Creator : azist
License : MIT License
Project Creator : azist
void IDisposable.Dispose()
#pragma warning restore CA1063 // Implement IDisposable Correctly
{
Limit = 0;
m_SchemaName = null;
m_Statement.Clear();// StringBuilder uses internal pool to relive allocation pressure
m_Select.Clear();
m_From.Clear();
m_Where.Clear();
m_OrderBy.Clear();
m_WhereLevels.Clear();
m_CurrentWhereNodes = 0;
m_GroupBy.Clear();
m_Having.Clear();
m_Parameters.Clear();//List: but does not trim excess so internal buffer gets cached
Thread.MemoryBarrier();
//push to cache
if (null == Interlocked.CompareExchange(ref s_Cache1, this, null)) return;
if (null == Interlocked.CompareExchange(ref s_Cache2, this, null)) return;
if (null == Interlocked.CompareExchange(ref s_Cache3, this, null)) return;
if (null == Interlocked.CompareExchange(ref s_Cache4, this, null)) return;
Interlocked.CompareExchange(ref s_Cache5, this, null);
}
19
View Source File : Lexer.cs
License : MIT License
Project Creator : Azure
License : MIT License
Project Creator : Azure
public virtual void Reset()
{
// wack Lexer state variables
if (_input != null)
{
_input.Seek(0);
}
// rewind the input
_token = null;
_type = TokenConstants.InvalidType;
_channel = TokenConstants.DefaultChannel;
_tokenStartCharIndex = -1;
_tokenStartColumn = -1;
_tokenStartLine = -1;
_text = null;
_hitEOF = false;
_mode = Antlr4.Runtime.Lexer.DEFAULT_MODE;
_modeStack.Clear();
Interpreter.Reset();
}
19
View Source File : CommandManager.cs
License : MIT License
Project Creator : b-editor
License : MIT License
Project Creator : b-editor
public void Do(IRecordCommand command)
{
if (!_process)
{
Debug.WriteLine("if (!process) {...");
return;
}
try
{
_process = false;
command.Do();
UndoStack.Push(command);
CanUndo = UndoStack.Count > 0;
RedoStack.Clear();
CanRedo = RedoStack.Count > 0;
}
catch
{
Debug.Fail("Commandの実行中に例外が発生。");
CommandCancel?.Invoke(null, EventArgs.Empty);
}
_process = true;
Executed?.Invoke(command, CommandType.Do);
}
19
View Source File : CommandManager.cs
License : MIT License
Project Creator : b-editor
License : MIT License
Project Creator : b-editor
public void Clear()
{
UndoStack.Clear();
RedoStack.Clear();
CanUndo = false;
CanRedo = false;
CommandsClear?.Invoke(this, EventArgs.Empty);
}
19
View Source File : LoadBalancer.cs
License : GNU General Public License v3.0
Project Creator : BardMusicPlayer
License : GNU General Public License v3.0
Project Creator : BardMusicPlayer
public void Dispose()
{
_freeVoices.Clear();
_activeVoices.Clear();
}
19
View Source File : CardProvider.cs
License : Apache License 2.0
Project Creator : Bigotter
License : Apache License 2.0
Project Creator : Bigotter
void LoadLevel() {
_currentLevel ++;
if (_currentLevel > 3) {
_currentLevel = 1;
}
_currentEventState = EVENT_STATE.STATE_PRE_EVENT;
_preEventCards.Clear ();
_postEventCards.Clear ();
_eventCards.Clear ();
_levelCards.Clear ();
foreach (var card in _allCards.Values) {
if (card.level == _currentLevel) {
if (card.IsInitial ()) {
if (card.IsPreEvent ()) {
_preEventCards.Push (card);
} else if (card.IsEventCard ()) {
_eventCards.Push (card);
} else if (card.IsPostEventCard()) {
_postEventCards.Push(card);
}
} else {
_levelCards.Add (card.id, card);
}
if (card.IsStartEvent ()) {
_startLevelCard = card;
}
}
}
_preEventCards = shuffle (_preEventCards);
_eventCards = shuffle (_eventCards);
}
19
View Source File : CardProvider.cs
License : Apache License 2.0
Project Creator : Bigotter
License : Apache License 2.0
Project Creator : Bigotter
private Stack<T> shuffle<T>(Stack<T> stack)
{
List<T> list = stack.ToList();
stack.Clear ();
while(list.Count > 0)
{
int randomIndex = Random.Range(0, list.Count);
stack.Push(list[randomIndex]);
list.RemoveAt(randomIndex);
}
return stack;
}
19
View Source File : UndoRedoStack.cs
License : MIT License
Project Creator : blish-hud
License : MIT License
Project Creator : blish-hud
public void Reset() {
_stack.Clear();
}
19
View Source File : ChunksArray.cs
License : MIT License
Project Creator : BogdanovKirill
License : MIT License
Project Creator : BogdanovKirill
public void Clear()
{
_freeChunks.Clear();
_sizesList.Clear();
_chunksCount = 0;
}
19
View Source File : Ac4PatternModelConstraint.cs
License : MIT License
Project Creator : BorisTheBrave
License : MIT License
Project Creator : BorisTheBrave
public void Clear()
{
toPropagate.Clear();
compatible = new int[indexCount, patternCount, directionsCount];
var edgeLabels = new int[directionsCount];
for (int index = 0; index < indexCount; index++)
{
if (!topology.ContainsIndex(index))
continue;
// Cache edgeLabels
for (int d = 0; d < directionsCount; d++)
{
edgeLabels[d] = topology.TryMove(index, (Direction)d, out var dest, out var _, out var el) ? (int)el : -1;
}
for (int pattern = 0; pattern < patternCount; pattern++)
{
for (int d = 0; d < directionsCount; d++)
{
var el = edgeLabels[d];
if (el >= 0)
{
var compatiblePatterns = propagatorArray[pattern][el].Length;
compatible[index, pattern, d] = compatiblePatterns;
if (compatiblePatterns == 0 && propagator.Wave.Get(index, pattern))
{
if (propagator.InternalBan(index, pattern))
{
propagator.SetContradiction();
}
break;
}
}
}
}
}
}
19
View Source File : OneStepPatternModelConstraint.cs
License : MIT License
Project Creator : BorisTheBrave
License : MIT License
Project Creator : BorisTheBrave
public void Clear()
{
toPropagate.Clear();
this.wave = propagator.Wave;
}
19
View Source File : NPCFindPath.cs
License : MIT License
Project Creator : Bozar
License : MIT License
Project Creator : Bozar
private bool GetNextStep(int[] source, out int[] next)
{
// Step 1: Search all available destinations.
int[][] neighbors = GameCore.AxeManCore.GetComponent<Distance>()
.GetNeighbor(source);
int minDistance = GetDistanceMapValue(source);
int currentDistance;
Stack<int[]> steps = new Stack<int[]>();
foreach (int[] neighbor in neighbors)
{
currentDistance = GetDistanceMapValue(neighbor);
if (currentDistance < minDistance)
{
minDistance = currentDistance;
steps.Clear();
steps.Push(neighbor);
}
else if (currentDistance == minDistance)
{
steps.Push(neighbor);
}
}
// Step 2: Pick one destination.
next = null;
int count = steps.Count;
int pick;
if (count > 1)
{
// TODO: Get a random int from 0 to count.
pick = 0;
for (int i = 0; i < count; i++)
{
next = steps.Pop();
if (i == pick)
{
break;
}
}
}
else if (count == 1)
{
next = steps.Pop();
}
return count > 0;
}
19
View Source File : PaintManager.cs
License : GNU General Public License v3.0
Project Creator : brownhci
License : GNU General Public License v3.0
Project Creator : brownhci
private void performNewCommand(PaintCommand command) {
if (!undoStack.Contains (command)) {
redoStack.Clear ();
undoStack.Push (command);
}
//Debug.Log ("new command pushed " + "undo "+ undoStack.Count + "redo " + redoStack.Count);
}
19
View Source File : TCP2_MaterialInspector_SG.cs
License : GNU General Public License v3.0
Project Creator : brownhci
License : GNU General Public License v3.0
Project Creator : brownhci
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
mMaterialEditor = materialEditor;
#if SHOW_DEFAULT_INSPECTOR
base.OnGUI();
return;
#else
//Header
EditorGUILayout.BeginHorizontal();
var label = (Screen.width > 450f) ? "TOONY COLORS PRO 2 - INSPECTOR (Generated Shader)" : (Screen.width > 300f ? "TOONY COLORS PRO 2 - INSPECTOR" : "TOONY COLORS PRO 2");
TCP2_GUI.HeaderBig(label);
if(TCP2_GUI.Button(TCP2_GUI.CogIcon, "O", "Open in Shader Generator"))
{
if(targetMaterial.shader != null)
{
TCP2_ShaderGenerator.OpenWithShader(targetMaterial.shader);
}
}
EditorGUILayout.EndHorizontal();
TCP2_GUI.Separator();
//Iterate Shader properties
materialEditor.serializedObject.Update();
var mShader = materialEditor.serializedObject.FindProperty("m_Shader");
toggledGroups.Clear();
if(materialEditor.isVisible && !mShader.hasMultipleDifferentValues && mShader.objectReferenceValue != null)
{
//Retina display fix
EditorGUIUtility.labelWidth = TCP2_Utils.ScreenWidthRetina - 120f;
EditorGUIUtility.fieldWidth = 64f;
EditorGUI.BeginChangeCheck();
EditorGUI.indentLevel++;
foreach (var p in properties)
{
var visible = (toggledGroups.Count == 0 || toggledGroups.Peek());
//Hacky way to separate material inspector properties into foldout groups
if(p.name.StartsWith("__BeginGroup"))
{
//Foldout
if(visible)
{
GUILayout.Space(8f);
p.floatValue = EditorGUILayout.Foldout(p.floatValue > 0, p.displayName, TCP2_GUI.FoldoutBold) ? 1 : 0;
}
EditorGUI.indentLevel++;
toggledGroups.Push((p.floatValue > 0) && visible);
}
else if(p.name.StartsWith("__EndGroup"))
{
EditorGUI.indentLevel--;
toggledGroups.Pop();
GUILayout.Space(8f);
}
else
{
//Draw regular property
if(visible && (p.flags & (MaterialProperty.PropFlags.PerRendererData | MaterialProperty.PropFlags.HideInInspector)) == MaterialProperty.PropFlags.None)
mMaterialEditor.ShaderProperty(p, p.displayName);
}
}
EditorGUI.indentLevel--;
if (EditorGUI.EndChangeCheck())
{
materialEditor.PropertiesChanged();
}
}
#endif // !SHOW_DEFAULT_INSPECTOR
#if UNITY_5_5_OR_NEWER
TCP2_GUI.Separator();
materialEditor.RenderQueueField();
#endif
#if UNITY_5_6_OR_NEWER
materialEditor.EnableInstancingField();
#endif
}
19
View Source File : TCP2_ShaderGenerator.UIFeatures.cs
License : GNU General Public License v3.0
Project Creator : brownhci
License : GNU General Public License v3.0
Project Creator : brownhci
public static void ClearFoldoutStack()
{
UIFeature_DropDownStart.ClearDropDownsList();
FoldoutStack.Clear();
}
See More Examples