⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lrucachetest.java

📁 Python Development Environment (Python IDE plugin for Eclipse). Features editor, code completion, re
💻 JAVA
字号:
package org.python.pydev.core.cache;

import junit.framework.TestCase;

public class LRUCacheTest extends TestCase {

	public static void main(String[] args) {
		junit.textui.TestRunner.run(LRUCacheTest.class);
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void test() throws Exception {
		
	}
	public void testRegular() throws Exception {
		LRUCache<Integer, Integer> cache = new LRUCache<Integer, Integer>(2);
		cache.add(1,1);
		cache.add(2,2);
		cache.add(3,3);
		assertNull(cache.getObj(1));
		
		cache.add(4,4);
		assertNull(cache.getObj(2));
		
		//there is only 3 and 4 now
		cache.startGrowAsNeeded(Integer.MAX_VALUE);
		cache.add(5,5);
		cache.add(6,6);
		assertNotNull(cache.getObj(3));
		assertNotNull(cache.getObj(4));
		
		cache.stopGrowAsNeeded();
		assertEquals(2, cache.cache.size());
		cache.startGrowAsNeeded(10);
		try {
			cache.startGrowAsNeeded(10);
			fail("We cannot make one start on the top of the other... when using this, it should be synched to avoid it.");
		} catch (Exception e) {
			//ok, expected
		}
		cache.stopGrowAsNeeded();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -