KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > cache > policy > ListBasedPolicy


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.excalibur.cache.policy;
9
10 import java.util.LinkedList JavaDoc;
11 import org.apache.avalon.excalibur.cache.ReplacementPolicy;
12
13 /**
14  * FIXME: Remove or determine good name.
15  *
16  * @author <a HREF="mailto:colus@apache.org">Eung-ju Park</a>
17  */

18 public abstract class ListBasedPolicy
19     implements ReplacementPolicy
20 {
21     protected LinkedList JavaDoc m_keyList;
22
23     public ListBasedPolicy()
24     {
25         m_keyList = new LinkedList JavaDoc();
26     }
27
28     public void add( final Object JavaDoc key )
29     {
30         m_keyList.addFirst( key );
31     }
32
33     public void remove( final Object JavaDoc key )
34     {
35         m_keyList.remove( key );
36     }
37
38     public Object JavaDoc selectVictim()
39     {
40         return m_keyList.removeLast();
41     }
42 }
43
Popular Tags