static void Main(string[] args)
        {
            RedBlackTreeList <int> tree = new RedBlackTreeList <int>();

            for (int i = 1; i <= 10; i++)
            {
                tree.Add(i);
            }

            tree.Remove(9);

            bool contains = tree.ContainsKey(5);

            Console.WriteLine("Does value exist? " + (contains ? "yes" : "no"));

            uint count = tree.Count;

            tree.Greatest(out int greatest);
            tree.Least(out int least);
            Console.WriteLine($"{count} elements in the range {least}-{greatest}");

            Console.WriteLine("Values: " + string.Join(", ", tree.GetEnumerable()));

            Console.Write("Values: ");
            foreach (EntryList <int> node in tree)
            {
                Console.Write(node + " ");
            }

            Console.ReadKey();
        }
예제 #2
0
        protected virtual TValue DequeueItem(out TPriority priority)
        {
            var association = GetNextItem();

            var item = association.Value.First.Value;
            association.Value.RemoveFirst();

            var key = association.Key;

            if (association.Value.Count == 0)
            {
                tree.Remove(association.Key);
            }

            Count--;

            priority = key;
            return item;
        }