Esempio n. 1
0
        static void Main(string[] args)
        {
            LruCache <string, object> lruCache = new LruCache <string, object>(2);

            lruCache.Add("item1", new object());

            lruCache.Add("item2", new object());

            lruCache.Add("item3", new object());

            if (lruCache.TryGetValue("item1", out object item1))
            {
                // do something with item1
            }
            else
            {
                lruCache.Add("item1", new object());
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            LruCache lruCache = new LruCache(5);

            //Console.WriteLine(lruCache.Size());

            lruCache.Set(2, 1);
            lruCache.Set(2, 2);
            int res = lruCache.Get(2);

            Console.WriteLine("result returned :" + res);
            lruCache.Set(1, 1);
            lruCache.Set(4, 1);
            int res1 = lruCache.Get(2);

            Console.WriteLine("result returned :" + res1);
            //lruCache.Insert(3, 50);
            Console.ReadLine();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var lruCache = new LruCache <int>(10);

            lruCache.Put("key1", 1);
            lruCache.Put("key2", 2);
            lruCache.Put("key3", 3);
            lruCache.Put("key4", 4);
            lruCache.Put("key5", 5);
            lruCache.Put("key6", 6);
            lruCache.Put("key7", 7);
            lruCache.Put("key8", 8);
            lruCache.Put("key9", 9);
            lruCache.Put("key10", 10);

            foreach (var item in lruCache)
            {
                Console.Write(item);
                Console.Write(" ");
            }
        }