removeId method
Remove the first entry whose id equals id. Returns true if
removed. This is a soft-delete (the node stays in the graph as a
tombstone) — the vector is zeroed and the id set to a sentinel so
search skips it. HNSW does not support cheap true deletion.
Implementation
bool removeId(Object? id) {
for (var i = 0; i < _ids.length; i++) {
if (_ids[i] == id) {
_ids[i] = _tombstone;
_tombstoneCount++;
// Zero its vector so any future distance is (typically) large.
for (var j = 0; j < dim; j++) {
_data[i * dim + j] = 0.0;
}
return true;
}
}
return false;
}