Esempio n. 1
0
        public IConstraintManager GetSubSet(ISet <Constraint> subset)
        {
            // Don't make a new ConstraintManager if the constraints are the same.
            if (InternalConstraints.SetEquals(subset))
            {
                return(this);
            }

            if (subset.Count >= InternalConstraints.Count)
            {
                throw new ArgumentException("Subset has count >= to count of this constraint manager's constraints");
            }

            // Is this the most efficient way to do this?
            ConstraintManager other = (ConstraintManager)this.MemberwiseClone();

            Debug.Assert(subset.IsSubsetOf(InternalConstraints), "argument ``subset`` is not a valid subset");

            var asIm = ImmutableHashSet <Constraint> .Empty.Union(subset);

            other.InternalConstraints = asIm.ToBuilder();

            // Fully recompute the hashcode on the new constraint manager
            other.FullyRecomputeHashCode();
            return(other);
        }
Esempio n. 2
0
        public IConstraintManager Clone()
        {
            ConstraintManager other = (ConstraintManager)this.MemberwiseClone();
            var asImmutable         = this.InternalConstraints.ToImmutable();

            other.InternalConstraints = asImmutable.ToBuilder();

            return(other);
        }