39 lines
906 B
C++
39 lines
906 B
C++
#ifndef _AS68HC11_CACHE_TPP_
|
|
#define _AS68HC11_CACHE_TPP_
|
|
|
|
template <class T,class U>
|
|
WORD MRUCache<T,U>::isInCache(CacheItem<T,U> &cacheItem)
|
|
{
|
|
for(short itemIndex=0;itemIndex<mCacheBlock.size();itemIndex++)
|
|
if(mCacheBlock[itemIndex].cacheItem()==cacheItem.cacheItem())
|
|
{
|
|
cacheItem.cacheItem(mCacheBlock[itemIndex].cacheItem());
|
|
cacheItem.cacheExtraInfo(mCacheBlock[itemIndex].cacheExtraInfo());
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
template <class T,class U>
|
|
void MRUCache<T,U>::insert(CacheItem<T,U> &cacheItem)
|
|
{
|
|
if(mCacheBlock.size()<CacheLength)
|
|
{
|
|
mCacheBlock.insert(&CacheItem<T,U>());
|
|
pullCache();
|
|
mCacheBlock[0]=cacheItem;
|
|
}
|
|
else
|
|
{
|
|
pullCache();
|
|
mCacheBlock[0]=cacheItem;
|
|
}
|
|
}
|
|
|
|
template <class T,class U>
|
|
void MRUCache<T,U>::pullCache(void)
|
|
{
|
|
for(short itemIndex=mCacheBlock.size()-1;itemIndex>0;itemIndex--)
|
|
mCacheBlock[itemIndex]=mCacheBlock[itemIndex-1];
|
|
}
|
|
#endif |