Code Monkey home page Code Monkey logo

algorithm's Introduction

algorithm's People

Contributors

wxggg avatar

Stargazers

 avatar  avatar

Watchers

 avatar

algorithm's Issues

btree 的更新值的函数update应该有一些小问题

作者大大 我只是初学者 看您的代码想着动手复现一下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;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.