CSharp examples for System.Collections.Generic:List
Returns a portion of the list whose keys are greater that the lowerLimit parameter less than the upperLimit parameter.
using System.IO;/* w w w. ja v a 2s .c o m*/ using System; public class Main{ /// <summary> /// Returns a portion of the list whose keys are greater that the lowerLimit parameter less than the upperLimit parameter. /// </summary> /// <param name="list">The list where the portion will be extracted.</param> /// <param name="lowerLimit">The start element of the portion to extract.</param> /// <param name="upperLimit">The end element of the portion to extract.</param> /// <returns>The portion of the collection.</returns> public static System.Collections.SortedList SubMap(System.Collections.SortedList list, Object lowerLimit, Object upperLimit) { System.Collections.Comparer comparer = System.Collections.Comparer.Default; System.Collections.SortedList newList = new System.Collections.SortedList(); if (list != null) { if ((list.Count > 0) && (!(lowerLimit.Equals(upperLimit)))) { int index = 0; while (comparer.Compare(list.GetKey(index), lowerLimit) < 0) index++; for (; index < list.Count; index++) { if (comparer.Compare(list.GetKey(index), upperLimit) >= 0) break; newList.Add(list.GetKey(index), list[list.GetKey(index)]); } } } return newList; } }