private static void splitAndAddByQ <T>(ref ListSorted <QValue <T> > parsedList, string headerValue, Func <string, T?> converter) where T : struct { splitAndAddByQ(ref parsedList, headerValue, (val, q, lst) => { var conv = converter(val); if (conv != null) { lst.Add(new QValue <T>(q, conv.Value)); } }); }
private static void splitAndAddByQ <T>(ref ListSorted <QValue <T> > parsedList, string headerValue, Action <string, float, ListSorted <QValue <T> > > add) { if (parsedList == null) { parsedList = new ListSorted <QValue <T> >(); } var split = Regex.Split(headerValue, @"\s*,\s*"); foreach (string item in split) { float q = 0; string nItem = item; if (item.Contains(";")) { var match = Regex.Match(item, @";\s*q=(\d+(\.\d+)?)"); if (match.Success) { q = 1 - float.Parse(match.Groups[1].Value); } nItem = item.Remove(item.IndexOf(';')); } add(nItem, q, parsedList); } }
protected bool Remove <S>(ListSorted <S> list, ICollection <ReferenceWrapper> objects) where S : IComparable <S> { if (list == null) { return(false); } bool success = false; for (int i = list.Count - 1; i >= 0; i--) { if (objects.Contains(new ReferenceWrapper(list[i]))) { if (Performing) { list.RemoveAt(i); } success = true; } } return(success); }
private static void splitAndAddByQ(ref ListSorted <QValue <string> > parsedList, string headerValue) { splitAndAddByQ(ref parsedList, headerValue, (val, q, lst) => { lst.Add(new QValue <string>(q, val)); }); }