At method
Returns the P stored in key, allocating (or reallocating)
if necessary.
If the slot already exists and its current capacity is >= count, the
existing pointer is reused. If capacity is insufficient the old block is
freed and a new one of size count is allocated.
key – slot identifier (must not be null).
count – minimum element capacity required (default: 1).
Implementation
P At(String key, [int count = 1]) {
final existing = slots[key];
if (existing != null) {
final (ptr, currentCount) = existing;
if (count <= currentCount) {
slots[key] = (ptr, count);
return ptr;
}
freeFunc(pointerToSource(ptr));
}
final ptr = pointerFactory(allocatorFunc(count));
slots[key] = (ptr, count);
return ptr;
}