Created
November 27, 2024 16:37
-
-
Save jamesu/449774f1e9660f5610b3e986aa09c566 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename V, int S, int T> | |
class TableLookup { | |
public: | |
TableLookup(DataChunker* chunker) : mTables((S+(T-1)) / T, nullptr), mChunker(chunker), mNumEntries(0) {} | |
bool insert(U32 address, const V& value); | |
bool lookup(U32 address, V& value) const; | |
void clear(U32 address); | |
bool isFull() const; | |
inline U32 size() const; | |
inline U32 lastTableIdx() const; | |
inline U32 lastTableEntry(U32 tableIdx) const; | |
private: | |
struct Table { | |
std::array<V, T> values; | |
std::bitset<T> residency; | |
}; | |
DataChunker* mChunker; | |
std::vector<Table*> mTables; | |
U32 mNumEntries; | |
}; | |
typedef TableLookup<U16, 2097152, 1024> CharMap; | |
typedef TableLookup<U16, 65536, 2048> GlyphMap; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment