Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
dart::FixedCache< K, V, kCapacity > Class Template Reference

#include <fixed_cache.h>

Classes

struct  Entry
 

Public Member Functions

 FixedCache ()
 
 ~FixedCache ()
 
VLookup (K key)
 
void Insert (K key, V value)
 
void Clear ()
 

Detailed Description

template<class K, class V, intptr_t kCapacity>
class dart::FixedCache< K, V, kCapacity >

Definition at line 24 of file fixed_cache.h.

Constructor & Destructor Documentation

◆ FixedCache()

template<class K , class V , intptr_t kCapacity>
dart::FixedCache< K, V, kCapacity >::FixedCache ( )
inline

Definition at line 31 of file fixed_cache.h.

31: length_(0) {}

◆ ~FixedCache()

template<class K , class V , intptr_t kCapacity>
dart::FixedCache< K, V, kCapacity >::~FixedCache ( )
inline

Definition at line 33 of file fixed_cache.h.

33{ Clear(); }

Member Function Documentation

◆ Clear()

template<class K , class V , intptr_t kCapacity>
void dart::FixedCache< K, V, kCapacity >::Clear ( )
inline

Definition at line 62 of file fixed_cache.h.

62 {
63 MutexLocker ml(&mutex_);
64 length_ = 0;
65 }

◆ Insert()

template<class K , class V , intptr_t kCapacity>
void dart::FixedCache< K, V, kCapacity >::Insert ( K  key,
V  value 
)
inline

Definition at line 43 of file fixed_cache.h.

43 {
44 MutexLocker ml(&mutex_);
45
46 intptr_t i = LowerBound(key);
47
48 if (length_ == kCapacity) {
49 length_ = kCapacity - 1;
50 if (i == kCapacity) i = kCapacity - 1;
51 }
52
53 for (intptr_t j = length_ - 1; j >= i; j--) {
54 pairs_[j + 1] = pairs_[j];
55 }
56
57 length_ += 1;
58 pairs_[i].key = key;
59 pairs_[i].value = value;
60 }
uint8_t value

◆ Lookup()

template<class K , class V , intptr_t kCapacity>
V * dart::FixedCache< K, V, kCapacity >::Lookup ( K  key)
inline

Definition at line 35 of file fixed_cache.h.

35 {
36 MutexLocker ml(&mutex_);
37
38 intptr_t i = LowerBound(key);
39 if (i != length_ && pairs_[i].key == key) return &pairs_[i].value;
40 return nullptr;
41 }

The documentation for this class was generated from the following file: