/** * Dump the cache entries from first to list for debugging. */ @SuppressWarnings("unchecked") // No generics for public fields public void dumpCacheEntries() { log.debug( "dumpingCacheEntries" ); for ( MemoryElementDescriptor<K, V> me = list.getFirst(); me != null; me = (MemoryElementDescriptor<K, V>) me.next ) { log.debug( "dumpCacheEntries> key=" + me.ce.getKey() + ", val=" + me.ce.getVal() ); } }
/** * Dump the cache entries from first to list for debugging. */ @SuppressWarnings("unchecked") // No generics for public fields public void dumpCacheEntries() { log.debug( "dumpingCacheEntries" ); for ( LRUElementDescriptor<K, V> me = list.getFirst(); me != null; me = (LRUElementDescriptor<K, V>) me.next ) { if ( log.isDebugEnabled() ) { log.debug( "dumpCacheEntries> key=" + me.getKey() + ", val=" + me.getPayload() ); } } }
/** * Logs an error is an element that should be in the cache is not. * <p> * @param key */ @SuppressWarnings("unchecked") // No generics for public fields protected void verifyCache( Object key ) { if ( !log.isDebugEnabled() ) { return; } boolean found = false; // go through the linked list looking for the key for (LRUElementDescriptor<K, V> li = list.getFirst(); li != null; li = (LRUElementDescriptor<K, V>) li.next ) { if ( li.getKey() == key ) { found = true; log.debug( "verifycache(key) key match: " + key ); break; } } if ( !found ) { log.error( "verifycache(key), couldn't find key! : " + key ); } }
/** * Dump the cache entries from first to list for debugging. */ @SuppressWarnings("unchecked") // No generics for public fields public void dumpCacheEntries() { log.debug( "dumpingCacheEntries" ); for ( LRUElementDescriptor<K, V> me = list.getFirst(); me != null; me = (LRUElementDescriptor<K, V>) me.next ) { if ( log.isDebugEnabled() ) { log.debug( "dumpCacheEntries> key=" + me.getKey() + ", val=" + me.getPayload() ); } } }
/** * Logs an error is an element that should be in the cache is not. * <p> * @param key */ @SuppressWarnings("unchecked") // No generics for public fields protected void verifyCache( Object key ) { if ( !log.isDebugEnabled() ) { return; } boolean found = false; // go through the linked list looking for the key for (LRUElementDescriptor<K, V> li = list.getFirst(); li != null; li = (LRUElementDescriptor<K, V>) li.next ) { if ( li.getKey() == key ) { found = true; log.debug( "verifycache(key) key match: " + key ); break; } } if ( !found ) { log.error( "verifycache(key), couldn't find key! : " + key ); } }
/** * Logs an error if an element that should be in the cache is not. * <p> * @param key */ @SuppressWarnings("unchecked") // No generics for public fields private void verifyCache( K key ) { if ( !log.isDebugEnabled() ) { return; } boolean found = false; // go through the linked list looking for the key for ( MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next ) { if ( li.ce.getKey() == key ) { found = true; log.debug( "verifycache(key) key match: " + key ); break; } } if ( !found ) { log.error( "verifycache(key)[" + cacheName + "], couldn't find key! : " + key ); } }
/** * Dump the cache entries from first to list for debugging. */ @SuppressWarnings("unchecked") // No generics for public fields private void dumpCacheEntries() { log.debug("dumpingCacheEntries"); for (MemoryElementDescriptor<K, V> me = list.getFirst(); me != null; me = (MemoryElementDescriptor<K, V>) me.next) { log.debug("dumpCacheEntries> key=" + me.getCacheElement().getKey() + ", val=" + me.getCacheElement().getVal()); } }
/** * Logs an error if an element that should be in the cache is not. * <p> * * @param key */ @SuppressWarnings("unchecked") // No generics for public fields private void verifyCache(K key) { boolean found = false; // go through the linked list looking for the key for (MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next) { if (li.getCacheElement().getKey() == key) { found = true; log.debug("verifycache(key) key match: " + key); break; } } if (!found) { log.error("verifycache(key)[" + getCacheName() + "], couldn't find key! : " + key); } }
+ " elements" ); log.debug( "verifycache: checking linked list by key " ); for (LRUElementDescriptor<K, V> li = list.getFirst(); li != null; li = (LRUElementDescriptor<K, V>) li.next ) for (LRUElementDescriptor<K, V> li3 = list.getFirst(); li3 != null; li3 = (LRUElementDescriptor<K, V>) li3.next ) for (LRUElementDescriptor<K, V> li2 = list.getFirst(); li2 != null; li2 = (LRUElementDescriptor<K, V>) li2.next )
+ dumpCacheSize() + " elements" ); log.debug( "verifycache: checking linked list by key " ); for ( MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next ) for ( MemoryElementDescriptor<K, V> li3 = list.getFirst(); li3 != null; li3 = (MemoryElementDescriptor<K, V>) li3.next ) for ( MemoryElementDescriptor<K, V> li2 = list.getFirst(); li2 != null; li2 = (MemoryElementDescriptor<K, V>) li2.next )
+ list.size() + " elements"); log.debug("verifycache: checking linked list by key "); for (MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next) for (MemoryElementDescriptor<K, V> li3 = list.getFirst(); li3 != null; li3 = (MemoryElementDescriptor<K, V>) li3.next) for (MemoryElementDescriptor<K, V> li2 = list.getFirst(); li2 != null; li2 = (MemoryElementDescriptor<K, V>) li2.next)
LRUElementDescriptor<K, V> first = list.getFirst(); old = map.put(first.getKey(), first);
/** verify that it's added last. */ public void testMakeLast_wasAlone() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); list.addFirst( node1 ); // DO WORK list.makeLast( node1 ); // VERIFY assertEquals( "Wrong size", 1, list.size() ); assertEquals( "Wrong last", node1, list.getLast() ); assertEquals( "Wrong first", node1, list.getFirst() ); }
/** verify that it's added last. */ public void testMakeLast_wasAlone() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); list.addFirst( node1 ); // DO WORK list.makeLast( node1 ); // VERIFY assertEquals( "Wrong size", 1, list.size() ); assertEquals( "Wrong last", node1, list.getLast() ); assertEquals( "Wrong first", node1, list.getFirst() ); }
/** verify that it's added last. */ public void testMakeLast_wasLast() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); list.addFirst( node1 ); list.addFirst( node2 ); // DO WORK list.makeLast( node1 ); // VERIFY assertEquals( "Wrong size", 2, list.size() ); assertEquals( "Wrong last", node1, list.getLast() ); assertEquals( "Wrong first", node2, list.getFirst() ); }
/** verify that it's added last. */ public void testMakeLast_wasLast() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); list.addFirst( node1 ); list.addFirst( node2 ); // DO WORK list.makeLast( node1 ); // VERIFY assertEquals( "Wrong size", 2, list.size() ); assertEquals( "Wrong last", node1, list.getLast() ); assertEquals( "Wrong first", node2, list.getFirst() ); }
/** verify that it's added last. */ public void testMakeLast_wasFirst() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); list.addFirst( node2 ); list.addFirst( node1 ); // DO WORK list.makeLast( node1 ); // VERIFY assertEquals( "Wrong size", 2, list.size() ); assertEquals( "Wrong last", node1, list.getLast() ); assertEquals( "Wrong first", node2, list.getFirst() ); }
/** verify that it's added last. */ public void testMakeLast_wasFirst() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); list.addFirst( node2 ); list.addFirst( node1 ); // DO WORK list.makeLast( node1 ); // VERIFY assertEquals( "Wrong size", 2, list.size() ); assertEquals( "Wrong last", node1, list.getLast() ); assertEquals( "Wrong first", node2, list.getFirst() ); }
/** verify that it's added last. */ public void testMakeLast_wasInMiddle() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); String payload3 = "payload3"; DoubleLinkedListNode<String> node3 = new DoubleLinkedListNode<String>( payload3 ); list.addFirst( node2 ); list.addFirst( node1 ); list.addFirst( node3 ); // DO WORK list.makeLast( node1 ); // VERIFY assertEquals( "Wrong size", 3, list.size() ); assertEquals( "Wrong last", node1, list.getLast() ); assertEquals( "Wrong first", node3, list.getFirst() ); }
/** verify that it's added last. */ public void testMakeLast_wasInMiddle() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); String payload3 = "payload3"; DoubleLinkedListNode<String> node3 = new DoubleLinkedListNode<String>( payload3 ); list.addFirst( node2 ); list.addFirst( node1 ); list.addFirst( node3 ); // DO WORK list.makeLast( node1 ); // VERIFY assertEquals( "Wrong size", 3, list.size() ); assertEquals( "Wrong last", node1, list.getLast() ); assertEquals( "Wrong first", node3, list.getFirst() ); }