#include <lru.h>
Public 型 | |
typedef u8 | counter_type |
typedef size_t | size_type |
Public メソッド | |
void | construct (const size_type way_num) |
void | reset () |
set () | |
set (const size_type size) | |
size_type | size () const |
size_type | target () |
void | touch (const size_type i) |
~set () | |
Static Public 変数 | |
static const std::numeric_limits< counter_type > | counter_info |
static const std::numeric_limits< size_type > | size_info |
Protected メソッド | |
void | rewind () |
Protected 変数 | |
size_type | m_mru |
counter_type * | m_stamp |
counter_type | m_tick |
size_type | m_way_num |
typedef u8 shttl::lru_time< key_type >::set::counter_type |
typedef size_t shttl::lru_time< key_type >::set::size_type |
shttl::lru_time< key_type >::set::set | ( | const size_type | size | ) | [inline] |
参照先 shttl::lru_time< key_type >::set::reset().
00102 : 00103 m_way_num(size), 00104 m_stamp( new counter_type[size] ) 00105 { 00106 reset(); 00107 }
関数の呼び出しグラフ:
shttl::lru_time< key_type >::set::set | ( | ) | [inline] |
shttl::lru_time< key_type >::set::~set | ( | ) | [inline] |
void shttl::lru_time< key_type >::set::construct | ( | const size_type | way_num | ) | [inline] |
参照先 shttl::lru_time< key_type >::set::m_stamp・shttl::lru_time< key_type >::set::m_way_num・shttl::lru_time< key_type >::set::reset().
00133 { 00134 if(m_stamp) 00135 delete[] m_stamp; 00136 00137 m_way_num = way_num; 00138 m_stamp = new counter_type[way_num]; 00139 reset(); 00140 }
関数の呼び出しグラフ:
void shttl::lru_time< key_type >::set::reset | ( | ) | [inline] |
参照先 shttl::lru_time< key_type >::set::m_mru・shttl::lru_time< key_type >::set::m_stamp・shttl::lru_time< key_type >::set::m_tick・shttl::lru_time< key_type >::set::m_way_num.
参照元 shttl::lru_time< key_type >::set::construct()・shttl::lru_time< key_type >::set::set().
00118 { 00119 for (size_type w = 0; w < m_way_num; ++w) 00120 m_stamp[w] = (counter_type)w; 00121 00122 m_mru = m_way_num - 1; 00123 m_tick = (counter_type)m_way_num; 00124 }
Here is the caller graph for this function:
void shttl::lru_time< key_type >::set::rewind | ( | ) | [inline, protected] |
参照先 shttl::lru_time< key_type >::set::m_mru・shttl::lru_time< key_type >::set::m_stamp・shttl::lru_time< key_type >::set::m_tick・SHTTL_ASSERT・shttl::lru_time< key_type >::set::size().
参照元 shttl::lru_time< key_type >::set::touch().
00180 { 00181 std::vector< std::pair<counter_type, size_type> > v(size()); 00182 00183 for (size_type i = 0; i < size(); ++i) 00184 v[i] = std::pair<counter_type, size_type>(m_stamp[i], i); 00185 00186 sort(v.begin(), v.end()); 00187 00188 for (size_type i = 0; i < size(); ++i) 00189 m_stamp[v[i].second] = (counter_type)i; 00190 00191 SHTTL_ASSERT(m_stamp[m_mru] == size() - 1); 00192 m_tick = (counter_type)size(); 00193 }
関数の呼び出しグラフ:
Here is the caller graph for this function:
size_type shttl::lru_time< key_type >::set::size | ( | ) | const [inline] |
参照先 shttl::lru_time< key_type >::set::m_way_num.
参照元 shttl::lru_time< key_type >::set::rewind()・shttl::lru_time< key_type >::set::target()・shttl::lru_time< key_type >::set::touch().
00098 { return m_way_num; }
Here is the caller graph for this function:
size_type shttl::lru_time< key_type >::set::target | ( | ) | [inline] |
参照先 shttl::lru_time< key_type >::set::m_stamp・shttl::lru_time< key_type >::set::size().
00157 { // find i that m_stamp[i] is minimum 00158 size_type i = 0; 00159 size_type min = m_stamp[0]; 00160 for (size_type j = 1; j < size(); ++j) { 00161 if (m_stamp[j] < min) { 00162 i = j; 00163 min = m_stamp[j]; 00164 } 00165 } 00166 return i; 00167 }
関数の呼び出しグラフ:
void shttl::lru_time< key_type >::set::touch | ( | const size_type | i | ) | [inline] |
参照先 shttl::lru_time< key_type >::set::counter_info・shttl::lru_time< key_type >::set::m_mru・shttl::lru_time< key_type >::set::m_stamp・shttl::lru_time< key_type >::set::m_tick・shttl::lru_time< key_type >::set::rewind()・shttl::lru_time< key_type >::set::size().
00143 { 00144 if(size() <= i) 00145 throw std::out_of_range("set::touch"); 00146 00147 if (i == m_mru) return; // nothing to do 00148 00149 if (m_tick == counter_info.max()) 00150 rewind(); 00151 00152 m_stamp[i] = m_tick++; // main work of touch() 00153 m_mru = i; 00154 }
関数の呼び出しグラフ:
const std::numeric_limits<counter_type> shttl::lru_time< key_type >::set::counter_info [static] |
size_type shttl::lru_time< key_type >::set::m_mru [protected] |
counter_type* shttl::lru_time< key_type >::set::m_stamp [protected] |
counter_type shttl::lru_time< key_type >::set::m_tick [protected] |
size_type shttl::lru_time< key_type >::set::m_way_num [protected] |
const std::numeric_limits<size_type> shttl::lru_time< key_type >::set::size_info [static] |