intermediate

This commit is contained in:
Fabian Freund
2024-12-12 09:44:33 +01:00
parent 0710116feb
commit 6b2ae28828
108 changed files with 5531 additions and 2265 deletions
+21
View File
@@ -0,0 +1,21 @@
import 'dart:async';
class Debouncer {
final Duration debounce;
Timer? _timer;
Debouncer(this.debounce);
bool get isDebouncing => _timer?.isActive ?? false;
void eventOccured(void Function() callback) {
_timer?.cancel();
_timer = Timer(debounce, callback);
}
void dispose() {
_timer?.cancel();
_timer = null;
}
}
+2 -2
View File
@@ -34,7 +34,7 @@ class LRUCache<K, V> {
return value;
}
void set(K key, V value) {
V set(K key, V value) {
if (_cache.containsKey(key)) {
_cache.remove(key); // Remove the existing item before updating.
} else if (_cache.length == _capacity) {
@@ -43,6 +43,6 @@ class LRUCache<K, V> {
); // Explicitly remove the least recently used item if at capacity.
}
_cache[key] = value; // Inserting or updating the item.
return _cache[key] = value; // Inserting or updating the item.
}
}