Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public override void CopyFrom(IFungusCollection rhsCol)
        {
            var rhs = Promote(rhsCol);

            if (rhs != null)
            {
                collection.Clear();
                collection.AddRange(rhs.collection);
            }
        }
Ejemplo n.º 3
0
        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]);
                }
            }
        }
Ejemplo n.º 4
0
        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]));
                }
            }
        }
Ejemplo n.º 5
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
 public abstract void Intersection(IFungusCollection rhsCol);
Ejemplo n.º 10
0
 public abstract void RemoveAll(IFungusCollection rhsCol);
Ejemplo n.º 11
0
 public abstract void Exclusive(IFungusCollection rhsCol);
Ejemplo n.º 12
0
 public abstract void CopyFrom(IFungusCollection rhsCol);
Ejemplo n.º 13
0
 public abstract bool ContainsAnyOf(IFungusCollection rhsCol);
Ejemplo n.º 14
0
 public abstract bool ContainsAllOfOrdered(IFungusCollection rhsCol);
Ejemplo n.º 15
0
 public abstract void AddUnique(IFungusCollection rhsCol);