Comments (5)
给 new_idx 赋值的逻辑就是 在没有字串的那个 else if 后面又加了一个 else {new_idx = index},但是不知道为什么holes.cc里的"bdca"写入就不成功...
from skr_learning.
我理了一下你的思路,你的代码应该是这样吧?
// 获取当前子串的新起始位置
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.
如果思路是类似我刚刚贴出来的那部分代码,那可能是因为忘记处理 前面有子串但不重叠 的情况,即这块位置:
// 获取当前子串的新起始位置
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.
啊,damn. 谢谢大佬,辛苦你啦。我刚想了下确实是这样。万分感谢
from skr_learning.
没事没事,有问题再联系
from skr_learning.
Related Issues (10)
- 看了很感动,加油 HOT 1
- 好感动 很真诚啊
- 催更 HOT 1
- 催更催更 HOT 1
- 确实很感人 HOT 1
- 博主的做法非常值得学习 HOT 1
- 和大佬贴贴 HOT 1
- 师傅您好!想和您简单交流一下 HOT 2
- 完结撒花
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skr_learning.