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); } } } }
public bool SetEquals(IndexSet other) { for (var i = 0; i < Math.Min(m_Masks.Count, other.m_Masks.Count); i++) { if (m_Masks[i] != other.m_Masks[i]) { return(false); } } for (var i = other.m_Masks.Count; i < m_Masks.Count; i++) { if (m_Masks[i] > 0) { return(false); } } for (var i = m_Masks.Count; i < other.m_Masks.Count; i++) { if (other.m_Masks[i] > 0) { return(false); } } return(true); }
public void IntersectWith(IndexSet other) { for (var i = 0; i < Math.Min(m_Masks.Count, other.m_Masks.Count); i++) { m_Masks[i] &= other.m_Masks[i]; } }
public void SymmetricExceptWith(IndexSet other) { for (var i = 0; i < Math.Min(m_Masks.Count, other.m_Masks.Count); i++) { m_Masks[i] ^= other.m_Masks[i]; } }
public void UnionWith(IndexSet other) { for (var i = 0; i < Math.Min(m_Masks.Count, other.m_Masks.Count); i++) { m_Masks[i] |= other.m_Masks[i]; } for (var i = m_Masks.Count; i < other.m_Masks.Count; i++) { m_Masks.Add(other.m_Masks[i]); } }
public bool Overlaps(IndexSet other) { for (var i = 0; i < Math.Min(m_Masks.Count, other.m_Masks.Count); i++) { if ((m_Masks[i] & other.m_Masks[i]) > 0) { return(true); } } return(false); }
public bool IsProperSubsetOf(IndexSet other) { var isProper = false; for (var i = 0; i < Math.Min(m_Masks.Count, other.m_Masks.Count); i++) { var mask = m_Masks[i]; var otherMask = other.m_Masks[i]; if ((mask & otherMask) != mask) { return(false); } if ((~mask & otherMask) > 0) { isProper = true; } } for (var i = other.m_Masks.Count; i < m_Masks.Count; i++) { if (m_Masks[i] > 0) { return(false); } } if (!isProper) { for (var i = m_Masks.Count; i < other.m_Masks.Count; i++) { if (other.m_Masks[i] > 0) { return(true); } } } return(isProper); }
public bool IsSupersetOf(IndexSet other) { for (var i = 0; i < Math.Min(m_Masks.Count, other.m_Masks.Count); i++) { var otherMask = other.m_Masks[i]; var mask = m_Masks[i]; if ((otherMask & mask) != otherMask) { return(false); } } for (var i = m_Masks.Count; i < other.m_Masks.Count; i++) { if (other.m_Masks[i] > 0) { return(false); } } return(true); }