예제 #1
0
 /// <summary>
 /// Dodaje novi ili prvi clan u kolekciju - a ako je kolekcija null onda je instancira
 /// </summary>
 /// <param name="col"></param>
 /// <param name="newItem"></param>
 /// <returns></returns>
 public static oneOrMore <T> operator +(oneOrMore <T> col, T newItem)
 {
     if (col == null)
     {
         col = new oneOrMore <T>();
     }
     if (!col.Contains(newItem))
     {
         col.Add(newItem);
     }
     return(col);
 }
예제 #2
0
        /// <summary>
        /// Sklanja item iz operatora
        /// </summary>
        /// <param name="col"></param>
        /// <param name="newItem"></param>
        /// <returns></returns>
        public static oneOrMore <T> operator -(oneOrMore <T> col, T newItem)
        {
            if (col == null)
            {
                col = new oneOrMore <T>();
            }
            else
            {
                col.Remove(newItem);
            }

            return(col);
        }
예제 #3
0
 /// <summary>
 /// Oduzima sve clanove iz prosledjene kolekcije
 /// </summary>
 /// <param name="col"></param>
 /// <param name="newItem"></param>
 /// <returns></returns>
 public static oneOrMore <T> operator -(oneOrMore <T> col, IEnumerable <T> newItem)
 {
     if (col == null)
     {
         col = new oneOrMore <T>();
     }
     foreach (T t in newItem)
     {
         if (col.Contains(t))
         {
             col.Remove(t);
         }
     }
     return(col);
 }