Example #1
0
        public static int Insert <T>(this HashSet <T> source, int index, T value, bool isOverride = false)
        {
            if (source.Contains(value))
            {
                return((!isOverride || !source.Remove(value)) ? 0 : 3);
            }
            else if (source.Count == index)
            {
                source.Add(value);
                return(1);
            }
            var p = source.Range(0, index);

            if (!p.Add(value))
            {
                return(0);
            }
            p = p.AddRange(source.Range(index));
            source.Clear();
            source.AddRange(p);
            return(1);
        }