public static void Main(String[] args)
IList<int> list = new ArrayList<int>();
list.AddAll(new[] { 23, 29, 31, 37, 41, 43, 47, 53 });
ReverseInterval(list, 2, 3);
SwapInitialFinal(list, 2);
list.CollectionCleared += delegate(Object c, ClearedEventArgs eargs)
if (eargs is ClearedRangeEventArgs ceargs)
Console.WriteLine("Cleared [{0}..{1}]", ceargs.Start, ceargs.Start + ceargs.Count - 1);
RemoveSublist1(list, 1, 2);
RemoveSublist2(list, 1, 2);
public static void ReverseInterval<T>(IList<T> list, int i, int n)
list.View(i, n).Reverse();
public static void SwapInitialFinal<T>(IList<T> list, int i)
list.View(0, i).Reverse();
list.View(i, list.Count - i).Reverse();
public static void RemoveSublist1<T>(IList<T> list, int i, int n)
list.RemoveInterval(i, n);
public static void RemoveSublist2<T>(IList<T> list, int i, int n)
public static void RemoveTail1<T>(IList<T> list, int i)
list.RemoveInterval(i, list.Count - i);
public static void RemoveTail2<T>(IList<T> list, int i)
list.View(i, list.Count - i).Clear();
private static void PatFirst<T>(IList<T> list, T x)
private static void PatLast<T>(IList<T> list, T x)
int j = list.LastIndexOf(x);
private static void PatFirstSublist<T>(IList<T> list, T x, int i, int n)
int j = list.View(i, n).IndexOf(x);
private static void PatLastSublist<T>(IList<T> list, T x, int i, int n)
int j = list.View(i, n).LastIndexOf(x);