-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCStationTableCache.cpp
53 lines (40 loc) · 1021 Bytes
/
CStationTableCache.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// CStationTableCache.cpp
//
// CStationTableCache class
// Copyright (c) 2013 by Kronosaur Productions, LLC. All Rights Reserved.
#include "PreComp.h"
void CStationTableCache::DeleteAll (void)
// DeleteAll
//
// Delete all entries
{
int i;
for (i = 0; i < m_Cache.GetCount(); i++)
delete m_Cache[i];
m_Cache.DeleteAll();
}
bool CStationTableCache::FindTable (const CString &sDesc, TArray<SEntry> **retpTable)
// GetTable
//
// If a table with the given description is found in the cache we return TRUE.
// If not, we return FALSE.
//
// Either way, retpTable is initialized with a pointer to a table to read
// or write.
{
if (m_Cache.Find(sDesc, retpTable))
{
m_iCacheHits++;
return true;
}
m_iCacheMisses++;
return false;
}
int CStationTableCache::GetCacheHitRate (void) const
// GetCacheHitRate
//
// Returns the current hit rate percentage (0-100)
{
int iTotal = m_iCacheHits + m_iCacheMisses;
return (iTotal > 0 ? (int)((100.0 * (double)m_iCacheHits / iTotal) + 0.5) : 100);
}