Beispiel #1
0
        private bool IsSubSetPresent(List <Gate> gates)
        {
            var isSubSetPresent = false;

            var tempGates = new List <Gate>(gates);

            for (var i = 0; i < gates.Count - 1; i++)
            {
                tempGates.RemoveAt(0);
                isSubSetPresent = _root.IsContainSubSetOf(tempGates);
                if (isSubSetPresent)
                {
                    break;
                }
            }
            return(isSubSetPresent);
        }
Beispiel #2
0
        public bool IsContainSubSetOf(List <int> set)
        {
            int curentId = set[0];

            if (Childs.ContainsKey(curentId))
            {
                CompSetNode child = Childs[curentId];
                set.RemoveAt(0);
                if (child.Childs.Count == 0) // this branch is sub set(or equal) of the new set
                {
                    return(true);
                }
                if (set.Count == 0) // no more elementes in new set - not subset in this branch
                {
                    return(false);
                }
                return(child.IsContainSubSetOf(set));
            }
            return(false);
        }