sizeOf method
Return approximate size of Suggester instance in memory
Implementation
int sizeOf() {
const SIZE_OF_INT = 4;
// Strings are shared between multiple instances of Entry.
// Get all unique Entry strings and find total size of strings
final uniqueEntries = _ttMultiMap.values.toSet();
var entryStringBytes = 0;
for (final entryTerm in uniqueEntries) {
entryStringBytes += entryTerm.entry.value.codeUnits.length * SIZE_OF_INT;
}
// Add to size of underlying TernaryTreap accounting for _tp field
// that is unique to each Suggestion instance.
return entryStringBytes + _ttMultiMap.sizeOf(SIZE_OF_INT);
}