protected virtual GenericCollection <T> Promote(IFungusCollection col) { if (col is GenericCollection <T> ) { return((GenericCollection <T>)col); } Debug.LogError("Collection cannot promote " + col.GetType().Name + " to " + this.GetType().Name); return(null); }
public override void CopyFrom(IFungusCollection rhsCol) { var rhs = Promote(rhsCol); if (rhs != null) { collection.Clear(); collection.AddRange(rhs.collection); } }
public override void AddUnique(IFungusCollection rhsCol) { var rhs = Promote(rhsCol); if (rhs != null) { for (int i = 0; i < rhs.collection.Count; i++) { AddUnique(rhs.collection[i]); } } }
public override void RemoveAll(IFungusCollection rhsCol) { var rhs = Promote(rhsCol); if (rhs != null) { for (int i = rhsCol.Count - 1; i >= 0; i--) { collection.RemoveAll(x => x.Equals(rhs.collection[i])); } } }
public override void Intersection(IFungusCollection rhsCol) { var rhs = Promote(rhsCol); if (rhs != null) { //only things that are in us and in rhs remain for (int i = collection.Count - 1; i >= 0; i--) { if (!rhs.Contains(collection[i])) { collection.RemoveAt(i); } } } }
public override void Exclusive(IFungusCollection rhsCol) { var rhs = Promote(rhsCol); if (rhs != null) { //if its in both, remove, if its only in 1 keep for (int i = 0; i < rhs.collection.Count; i++) { var item = rhs.collection[i]; if (!collection.Remove(item)) { collection.Add(item); } } } }
public override bool ContainsAnyOf(IFungusCollection rhsCol) { var rhs = Promote(rhsCol); if (rhs != null) { for (int i = 0; i < rhs.collection.Count; i++) { if (collection.Contains(rhs.collection[i])) { return(true); } } } return(false); }
public override bool ContainsAllOfOrdered(IFungusCollection rhsCol) { var rhs = Promote(rhsCol); if (rhs != null) { if (rhs.Count == Count) { for (int i = 0; i < rhs.collection.Count; i++) { if (!rhs.collection[i].Equals(collection[i])) { return(false); } } return(true); } } return(false); }
public abstract void Intersection(IFungusCollection rhsCol);
public abstract void RemoveAll(IFungusCollection rhsCol);
public abstract void Exclusive(IFungusCollection rhsCol);
public abstract void CopyFrom(IFungusCollection rhsCol);
public abstract bool ContainsAnyOf(IFungusCollection rhsCol);
public abstract bool ContainsAllOfOrdered(IFungusCollection rhsCol);
public abstract void AddUnique(IFungusCollection rhsCol);