You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
作者大大 我只是初学者 看您的代码想着动手复现一下btree 233 看到btree.hh 178行发现了一点点小问题
int update(const Key& k, const Value& v) {
if (empty()) return -1;
auto p = search_key(k);
int i = lower_bound(p->key, p->key + p->n, k) - p->key;
if (i == p->n) return -1;
p->key[i] = v;
return 0;
}
应该为 value[i]=v 才能更新值 而不是key
而且if判断可以加i!=k 保证确实找到了一致的值
int update(const Key& k, const Value& v) {
if (empty()) return -1;
auto p = search_key(k);
int i = lower_bound(p->key, p->key + p->n, k) - p->key;
if (i == p->n||k!=p->key[i]) return -1;
p->value[i] = v;
return 0;
}
The text was updated successfully, but these errors were encountered:
作者大大 我只是初学者 看您的代码想着动手复现一下btree 233 看到btree.hh 178行发现了一点点小问题
int update(const Key& k, const Value& v) {
if (empty()) return -1;
auto p = search_key(k);
int i = lower_bound(p->key, p->key + p->n, k) - p->key;
if (i == p->n) return -1;
应该为 value[i]=v 才能更新值 而不是key
而且if判断可以加i!=k 保证确实找到了一致的值
int update(const Key& k, const Value& v) {
if (empty()) return -1;
auto p = search_key(k);
int i = lower_bound(p->key, p->key + p->n, k) - p->key;
if (i == p->n||k!=p->key[i]) return -1;
The text was updated successfully, but these errors were encountered: