Giter Club home page Giter Club logo

Comments (5)

taylover2016 avatar taylover2016 commented on May 29, 2024

给 new_idx 赋值的逻辑就是 在没有字串的那个 else if 后面又加了一个 else {new_idx = index},但是不知道为什么holes.cc里的"bdca"写入就不成功...

from skr_learning.

Kiprey avatar Kiprey commented on May 29, 2024

我理了一下你的思路,你的代码应该是这样吧?

// 获取当前子串的新起始位置
size_t new_idx = -1;
// 如果前面确实有子串
if (pos_iter != _unassemble_strs.end() && pos_iter->first <= index) {
    const size_t up_idx = pos_iter->first;

    // 如果当前子串前面出现了重叠
    if (index < up_idx + pos_iter->second.size())
        new_idx = up_idx + pos_iter->second.size();
}
// 如果前面没有子串,则和当前读取到的pos进行比较
else if (index < _next_assembled_idx)
    new_idx = _next_assembled_idx;
else
    new_idx = index;

from skr_learning.

Kiprey avatar Kiprey commented on May 29, 2024

如果思路是类似我刚刚贴出来的那部分代码,那可能是因为忘记处理 前面有子串但不重叠 的情况,即这块位置:

// 获取当前子串的新起始位置
size_t new_idx = -1;
// 如果前面确实有子串
if (pos_iter != _unassemble_strs.end() && pos_iter->first <= index) {
    const size_t up_idx = pos_iter->first;

    // 如果当前子串前面出现了重叠
    if (index < up_idx + pos_iter->second.size())
        new_idx = up_idx + pos_iter->second.size();
    /* -------------------------------------------------------------------------------- */
    else {
        /* NOP, 这里的 new_idx 应该为 index,但是因为没有赋值结果却为 -1 */
    }
    /* -------------------------------------------------------------------------------- */
}
// 如果前面没有子串,则和当前读取到的pos进行比较
else if (index < _next_assembled_idx)
    new_idx = _next_assembled_idx;
else
    new_idx = index;

from skr_learning.

taylover2016 avatar taylover2016 commented on May 29, 2024

啊,damn. 谢谢大佬,辛苦你啦。我刚想了下确实是这样。万分感谢

from skr_learning.

Kiprey avatar Kiprey commented on May 29, 2024

没事没事,有问题再联系

from skr_learning.

Related Issues (10)

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.