Beispiel #1
0
        public void clear()
        {
            while (true)
            {
                Cacheable oldest = retrievedItems.pop();

                if (oldest == null)
                {
                    available = size;
                    return;
                }

                oldest.unlink();
                oldest.unlinkCacheable();
            }
        }
Beispiel #2
0
        public void put(Cacheable item, long key)
        {
            if (available == 0)
            {
                Cacheable oldest = retrievedItems.pop();
                oldest.unlink();
                oldest.unlinkCacheable();

                if (oldest == empty)
                {
                    Cacheable secondOldest = retrievedItems.pop();
                    secondOldest.unlink();
                    secondOldest.unlinkCacheable();
                }
            }
            else
            {
                available--;
            }

            hashmap.put(key, item);
            retrievedItems.push(item);
            return;
        }