public void Dispose() { _tmp.Clear(); _tree = null; if (_cache.Count < 12) { _cache.Enqueue(this); } }
public void Clear() { m_openNodes.Clear(); m_reachedNodes.Clear(); m_blueSkyNodes.Clear(); NodeDistance = DefaultNodeDistance << 1; m_targets = null; #if PROFILE m_unreachableNodes = 0; #endif }
// Finds common parent for set of given nodes protected static MyVisualSyntaxNode CommonParent(IEnumerable <MyVisualSyntaxNode> nodes) { m_commonParentSet.Clear(); m_activeHeap.Clear(); // Use the set to remove duplicities foreach (var node in nodes) { if (m_commonParentSet.Add(node)) { // inverse the Depth because we have only Min heap m_activeHeap.Insert(new HeapNodeWrapper { Node = node }, -node.Depth); } } HeapNodeWrapper current; do { current = m_activeHeap.RemoveMin(); // We have a solution if (m_activeHeap.Count == 0) { break; } // Node with no sequence inputs means that we have a solution or // there is no solution of we still have some nodes in the heap. if (current.Node.SequenceInputs.Count == 0) { if (m_activeHeap.Count > 0) { return(null); } continue; } current.Node.SequenceInputs.ForEach(node => { // Insert all not visited inputs into the heap if (m_activeHeap.Count > 0 && m_commonParentSet.Add(node)) { current.Node = node; m_activeHeap.Insert(current, -current.Node.Depth); } }); } while (true); // Special case... if (current.Node is MyVisualSyntaxForLoopNode) { var parent = current.Node.SequenceInputs.FirstOrDefault(); return(parent); } return(current.Node); }
protected override void Detach() { m_asteroidsToAdd.Clear(); foreach (var a in m_asteroids.Values) { a.RaiseRemoved(); } m_asteroids.Clear(); while (m_asteroidsToRemove.Count > 0) { m_asteroidsToRemove.Dequeue().ExecuteRemove(); } }