linked list
载入中...
搜索中...
未找到
LRUList.h
1#ifndef LRU_LIST_HXX
2#define LRU_LIST_HXX
3#include "DoubleLink.h"
7template<class T>
9public:
10 T value;
11 bool tailRemoved;
12public:
15 this->tailRemoved = false;
16 }
17};
18
22template<class T>
23class LRUList :
24 public DoubleLink<T>
25{
26private:
27 unsigned int maxCount;
28public:
29 LRUList(unsigned int count);
31};
32
36template<class T>
38 maxCount = count;
39}
43template<class T>
45 DNode<T>* node = this->findNode(e);
46 if (node != NULL) {
47 this->removeNode(node);
48 this->insertNodeFirst(node);
49 } else {
50 if ((this->count) < (this->maxCount)) {
51 this->insertFirst(e);
52 } else {
53 remvedTail.tailRemoved = true;
54 this->deleteLast(&remvedTail.value);
55 this->insertFirst(e);
56 }
57 }
58}
59
60#endif
Definition LRUList.h:25
LRUList(unsigned int count)
Definition LRUList.h:37
void addNewElement(T e, RemovedTail< T > &remvedTail)
Definition LRUList.h:44
Definition LRUList.h:8
RemovedTail()
Definition LRUList.h:14
Definition DoubleLink.h:11