public GPTreeConstraints Constraints(GPInitializer initializer) { if (ConstraintsIndex < 0 || ConstraintsIndex > initializer.TreeConstraints.Count - 1) { throw new InvalidOperationException("ConstraintsIndex is outside of the allowable range: [0, initializer.TreeConstraints.Length - 1]"); } return(initializer.TreeConstraints[ConstraintsIndex]); }
public override bool CompatibleWith(GPInitializer initializer, GPType t) { // if the type is me, then I'm compatible with it if (t.Type == Type) { return(true); } // if the type an atomic type, then return false if (t.Type < initializer.NumAtomicTypes) { return(false); } // if the type is < 0 (it's a set type), then I'm compatible // if I'm contained in it. Use its sparse array. return(((GPSetType)t).TypesSparse[Type]); }
public override bool CompatibleWith(GPInitializer initializer, GPType t) { // if the type is me, then I'm compatible with it. if (t.Type == Type) { return(true); } // if the type is an atomic type, then I'm compatible with it if I contain it. // Use the sparse array. if (t.Type < initializer.NumAtomicTypes) { // atomic type, faster than doing instanceof return(TypesSparse[t.Type]); } // else the type is a set type. I'm compatible with it if we contain // an atomic type in common. Use the sorted packed array. var s = (GPSetType)t; var x = 0; var y = 0; for (; x < TypesPacked.Length && y < s.TypesPacked.Length;) { if (TypesPacked[x] == s.TypesPacked[y]) { return(true); } if (TypesPacked[x] < s.TypesPacked[y]) { x++; } else { y++; } } return(false); }
/// <summary> /// Am I compatible with ("fit" with) <i>t</i>? For two atomic /// types, this is done by direct pointer equality. For /// two set types, this is done by determining if the intersection /// is nonempty. A set type is compatible with an atomic type /// if it contains the atomic type in its set. /// </summary> public abstract bool CompatibleWith(GPInitializer initializer, GPType t);