operator<
to sort in reverse order?lower_bound
should do what you want, no?lower_bound
should do what you want, no? lower_bound
should do what you want, no? c++
#include <cstdio>
#include <map>
int main() {
std::multimap<int, int, std::greater<>> map;
map.insert({1, 2});
map.insert({4, 3});
map.insert({9, 5});
printf("%d\n", map.lower_bound(8)->first);
return 0;
}
4
for me, which is the first element after 8
, given that I have the std::greater
ordering#include <cstdio>
#include <map>
int main() {
std::multimap<int, int, std::greater<>> map;
map.insert({1, 2});
map.insert({4, 3});
map.insert({9, 5});
auto it = map.lower_bound(8);
it--;
printf("%d\n", it->first);
return 0;
}
#include <cstdio>
#include <map>
int main() {
std::multimap<int, int, std::greater<>> map;
map.insert({1, 2});
map.insert({4, 3});
map.insert({9, 5});
auto it = map.lower_bound(8);
it--;
printf("%d\n", it->first);
return 0;
}
log
2(last - first) + O(1) comparisons). However, for non-LegacyRandomAccessIterators, the number of iterator increments is linear. Notably, std::map, std::multimap, std::set, and std::multiset iterators are not random access, and so their member lower_bound functions should be preferred.
MHHH#include <cstdio>
#include <map>
int main() {
std::multimap<int, int, std::greater<>> map;
map.insert({1, 2});
map.insert({4, 3});
map.insert({9, 5});
auto it = map.lower_bound(8);
it--;
printf("%d\n", it->first);
return 0;
}
!(a < b) && !(b < a)
<
with <=
!(a < b) && !(b < a)
Compare
Compare
states that equality must be !(a < b) && !(b < a)
<=
is UBsort
Compare
Compare
lower_bound
/upper_bound
on multimap
multimap
requires itlower_bound
/upper_bound
on multimap
upper_bound
/lower_bound
member functions don't take another comparison functionlower_bound
/upper_bound
lower_bound
/upper_bound
[ RUN ] Jobs.AbortAbortable
../src/test/jobs.cpp:74: Failure
Expected equality of these values:
pJob->State()
Which is: 1
IJob::STATE_ABORTED
Which is: 3
[ FAILED ] Jobs.AbortAbortable (0 ms)
Commit of #8041 but not the PR run. Failed run: https://github.com/Jupeyy/ddnet/actions/runs/8122654231/job/22202320763std::collections::BTreeMap<usize, LinkedHashMap<NonZeroUsize, MemoryHeapQueueElement>>
std::multiset<SMemoryHeapQueueElement, std::greater<>>;
cpp version btw SMemoryHeapQueueElement
is the same heresv_high_bandwidth
value, which is 0 per default. Could be changed to "Go to next/previous tick" I guess.sv_high_bandwidth
value, which is 0 per default. Could be changed to "Go to next/previous tick" I guess. ❯ mpv \[SubsPlease\]\ Sousou\ no\ Frieren\ -\ 25\ \(1080p\)\ \[7423AE35\].mkv
(+) Video --vid=1 (*) (h264 1920x1080 23.976fps)
(+) Audio --aid=1 --alang=jpn (*) (aac 2ch 44100Hz)
(+) Subs --sid=1 --slang=eng (*) 'English subs' (ass)
Using hardware decoding (nvdec).
AO: [pipewire] 44100Hz stereo 2ch floatp
VO: [gpu] 1920x1080 cuda[nv12]
Exiting... (Quit)