Beispiel #1
0
        public HashedLinkedList <T> CopyToHashedLinkedList <T>(ICollection <T> lst)
        {
            HashedLinkedList <T> lstCopy = new HashedLinkedList <T>();

            foreach (var item in lst)
            {
                lstCopy.Add((T)item);
            }
            return(lstCopy);
        }
Beispiel #2
0
    public static void Main(String[] args) {
      HashedLinkedList<int> test = new HashedLinkedList<int>();
      for (int i = 0; i < 33; i++) {
        test.Add(i);
      } // for

      // Fails after 7 removals
      for (int i = 0; i < 33; i++) {
        Console.WriteLine(i);
        test.Remove(i);
      } // for

      // Fails after 23 removals
//        for (int i = 32; i >= 0; i--) {
//          Console.WriteLine(i);
//          test.Remove(i);
//        } // for
    }
Beispiel #3
0
        public static void Main(String[] args)
        {
            HashedLinkedList <int> test = new HashedLinkedList <int>();

            for (int i = 0; i < 33; i++)
            {
                test.Add(i);
            } // for

            // Fails after 7 removals
            for (int i = 0; i < 33; i++)
            {
                Console.WriteLine(i);
                test.Remove(i);
            } // for

            // Fails after 23 removals
//        for (int i = 32; i >= 0; i--) {
//          Console.WriteLine(i);
//          test.Remove(i);
//        } // for
        }
Beispiel #4
0
        public static void Main()
        {
            var test = new HashedLinkedList <int>();

            for (var i = 0; i < 33; i++)
            {
                test.Add(i);
            }

            // Fails after 7 removals
            for (var i = 0; i < 33; i++)
            {
                Console.WriteLine(i);
                test.Remove(i);
            }

            // Fails after 23 removals
            for (var i = 32; i >= 0; i--)
            {
                Console.WriteLine(i);
                test.Remove(i);
            }
        }
Beispiel #5
0
        public void Main()
        {
            // Construct hashed array list using collection initializer
            var list = new HashedLinkedList <int> {
                2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59
            };

            // Chose from list
            list.Choose();

            var array = new int[list.Count];

            // Copy list to array
            list.CopyTo(array, 0);

            // Add item to the end of list
            list.Add(61);

            // Add range to list
            array = new[] { 67, 71, 73, 79, 83 };
            list.AddRange(array);

            // Check if list contains an item
            list.Contains(list.Choose());

            // Check if list contains all items in enumerable
            list.ContainsRange(array);

            // Count all occuerence of an item
            list.CountDuplicates(list.Choose());

            // Find an item in list
            var itemToFind = list.Last;

            list.Find(ref itemToFind);

            // Return all occurence of an item
            list.FindDuplicates(itemToFind);

            // Remove within range
            list.RemoveIndexRange(0, 3);

            var range = new[] { list.First, list.Last };

            // Remove all items in enumerable from list
            list.RemoveRange(range);

            // Retain all items in enumarable from list
            list.RetainRange(list.ToArray());

            var lastItem = list.Last;

            // Find last index of an item
            list.LastIndexOf(lastItem);

            // Insert at the end of list
            list.InsertLast(100);

            // Insert at the beginning of list
            list.InsertFirst(-100);

            // Reverse list
            list.Reverse();

            // Shuffle list
            list.Shuffle();

            // Sort list
            list.Sort();

            // Check if list is sorted
            var isSorted = list.IsSorted();

            // Print all items in list by indexer
            var index = 0;

            foreach (var item in list)
            {
                Console.WriteLine($"list[{index++}] = {item}");
            }

            // Clear list
            list.Clear();
        }
 public void Add(IDestination destination)
 => destinations.Add(destination);