awesome assets from gffs code
[feisty_meow.git] / kona / src / org / gffs / cache / LRUList.java
1 package org.gffs.cache;
2
3 /*
4  * Copyright 2006 University of Virginia
5  * 
6  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
7  * obtain a copy of the License at
8  * 
9  * http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
13  * and limitations under the License.
14  */
15
16
17 class LRUList<KeyType, DataType> extends CacheList<KeyType, DataType>
18 {
19         public LRUList()
20         {
21                 super(RoleBasedCacheNode.ROLE_LRU);
22         }
23
24         @Override
25         public void insert(RoleBasedCacheNode<KeyType, DataType> node)
26         {
27                 // LRU inserts ALWAYS go at the tail
28                 if (_tail == null) {
29                         _head = _tail = node;
30                         return;
31                 }
32
33                 _tail.setNext(_myRole, node);
34                 node.setPrevious(_myRole, _tail);
35                 _tail = node;
36         }
37
38         public void noteUse(RoleBasedCacheNode<KeyType, DataType> node)
39         {
40                 remove(node);
41                 insert(node);
42         }
43 }