protected internal virtual void RemoveFeature(INode.Feature f) { int size = features.Length; Preconditions.CheckState(size > 0, "Feature " + f.GetType().Name + " not found."); if (size == 1) { Preconditions.CheckState(features[0] == f, "Feature " + f.GetType().Name + " not found." ); features = EmptyFeature; return; } INode.Feature[] arr = new INode.Feature[size - 1]; int j = 0; bool overflow = false; foreach (INode.Feature f1 in features) { if (f1 != f) { if (j == size - 1) { overflow = true; break; } else { arr[j++] = f1; } } } Preconditions.CheckState(!overflow && j == size - 1, "Feature " + f.GetType().Name + " not found."); features = arr; }
protected internal virtual void AddFeature(INode.Feature f) { int size = features.Length; INode.Feature[] arr = new INode.Feature[size + 1]; if (size != 0) { System.Array.Copy(features, 0, arr, 0, size); } arr[size] = f; features = arr; }