Beispiel #1
0
        void System.Collections.IList.Remove(object value)
        {
            int index;

            while ((index = List.IndexOfValue(value)) >= 0)
            {
                List.RemoveAt(index);
            }
        }
        public static void Main(string[] args)
        {
            System.IO.StreamReader reader = OpenInput(args);
            int numLines = System.Int32.Parse(reader.ReadLine());

            System.Collections.Generic.SortedList<int, string> longest = new System.Collections.Generic.SortedList<int, string>();
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line == null)
                    continue;

                if (longest.Count < numLines)
                {
                    longest.Add(line.Length, line);
                }
                else if (line.Length > longest.Keys[0])
                {
                    // We need to add this line and push out the extra that's smallest in our list
                    longest.Add(line.Length, line);
                    longest.RemoveAt(0);
                }
            }

            System.Collections.Generic.IList<int> keys = longest.Keys;
            for (int i = keys.Count - 1; i >= 0; --i)
            {
                System.Console.WriteLine(longest[keys[i]]);
            }
        }
 /// <summary>
 /// Removes an integer at a given position from the collection (e.g. in general not the integer you provide as argument is removed (!)).
 /// </summary>
 /// <param name="position"></param>
 public void RemoveAt(int position)
 {
     _list.RemoveAt(position);
 }