Changeset View
Changeset View
Standalone View
Standalone View
addons/tabswitcher/tabswitcherfilesmodel.cpp
Show All 24 Lines | |||||
25 | #include <algorithm> | 25 | #include <algorithm> | ||
26 | 26 | | |||
27 | namespace detail { | 27 | namespace detail { | ||
28 | /** | 28 | /** | ||
29 | * adpated from https://helloacm.com/c-coding-exercise-longest-common-prefix/ | 29 | * adpated from https://helloacm.com/c-coding-exercise-longest-common-prefix/ | ||
30 | * see also http://www.cplusplus.com/forum/beginner/83540/ | 30 | * see also http://www.cplusplus.com/forum/beginner/83540/ | ||
31 | * Note that if strs contains the empty string, the result will be "" | 31 | * Note that if strs contains the empty string, the result will be "" | ||
32 | */ | 32 | */ | ||
33 | QString longestCommonPrefix(std::vector<QString>& strs) { | 33 | QString longestCommonPrefix(std::vector<QString> const & strs) { | ||
34 | int n = INT_MAX; | 34 | int n = INT_MAX; | ||
35 | if (strs.size() <= 0) { | 35 | if (strs.size() <= 0) { | ||
36 | return QString(); | 36 | return QString(); | ||
37 | } | 37 | } | ||
38 | if (strs.size() == 1) { | 38 | if (strs.size() == 1) { | ||
39 | return strs[0]; | 39 | return strs[0]; | ||
40 | } | 40 | } | ||
41 | // get the min length | 41 | // get the min length | ||
▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines |