public int RemoveAll(T element) { int firstOccurance = sortedElements.IndexOf(element); int secondoccurance = sortedElements.LastIndexOf(element); if (sortedElements.IndexOf(element) < 0) { return(0); } else { //Predicate<T> predicate = x => x.CompareTo(element) == 0; this.elements.RemoveAll(x => x.CompareTo(element) == 0); sortedElements.RemoveAllCopies(element); reversedElements.RemoveAllCopies(element); return(secondoccurance - firstOccurance + 1); } }