2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: lru.h /main/5 1996/08/21 15:53:46 drk $
26 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
27 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28 * States. Use of a copyright notice is precautionary only and does not
29 * imply publication or disclosure.
31 * This software contains confidential information and trade secrets of HaL
32 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
33 * without the prior express written permission of HaL Computer Systems, Inc.
35 * RESTRICTED RIGHTS LEGEND
36 * Use, duplication, or disclosure by the Government is subject to
37 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38 * Technical Data and Computer Software clause at DFARS 252.227-7013.
39 * HaL Computer Systems, Inc.
40 * 1315 Dell Avenue, Campbell, CA 95008
49 #include "utility/c_stream.h"
54 #include "utility/debug.h"
55 #include "dstr/dlist.h"
56 #include "storage/rep_policy.h"
58 class lru: public rep_policy {
65 void lower_last(rep_cell*& replaced);
68 lru(int a_size, int i_size, Boolean remove_cells) ;
71 // promotes the cell x to the active list.
72 // In the first version, the replaced is the cell dumped from the
73 // active list. It is set to zero if no dumping takes place.
74 // Boolean = true: replaced is saved in the inactive list
76 virtual Boolean promote(rep_cell& x, rep_cell*& replaced);
77 virtual Boolean promote(rep_cell& x);
79 // put x to the last of position_t list. Only from
80 // somewhere in active list -> active list's last
82 // somewhere in active list -> inactive list's last
85 // somewhere in inactive list -> active list's last
88 virtual Boolean derank(rep_cell& x, position_t);
90 // walk through all cells in either the active or inactive list,
91 long first(position_t = ACTIVE);
92 rep_cell* operator()(long index, position_t);
93 rep_cell* operator()(long index) { return operator()(index, ACTIVE); };
94 void next(long & index, position_t = ACTIVE);
96 // the last cell in either of the list
97 long last(position_t = ACTIVE);
99 Boolean remove(rep_cell& x); // remove a cell x
100 void remove(); // remove all cells
101 void forget(); // let go all cells, do nothing on them
104 int active_elmts() { return active_list.count(); };
105 int inactive_elmts() { return inactive_list.count(); };
107 dlist& get_active_list() { return active_list; };
108 dlist& get_inactive_list() { return inactive_list; };