Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }