旧版手动对比算法出了问题 #1

Closed
opened 3 years ago by lensfrex · 0 comments
Owner

e22d05f823/work20220401/neoString/CString.cpp (L162)

如果在这里要手动做比较的话应该是要这样写的:

    int compareLength = std::min(compareString.length, length);
    for (int i = 0; i < compareLength; ++i) {
        if (data[i] != compareString.data[i]) {
            return data[i] > compareString.data[i];
        }
    }

    return false;
https://git.ciduid.top/lensfrex/cpp-work/src/commit/e22d05f823c365e1bf044bb678e12de0d1e3eafd/work20220401/neoString/CString.cpp#L162 如果在这里要手动做比较的话应该是要这样写的: ``` int compareLength = std::min(compareString.length, length); for (int i = 0; i < compareLength; ++i) { if (data[i] != compareString.data[i]) { return data[i] > compareString.data[i]; } } return false; ```
lensfrex closed this issue 3 years ago
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Reference: lensfrex/cpp-work#1
Loading…
There is no content yet.