/// <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); }
/// <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); }
/// <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); }