#include #include using std::uint32_t; template void running(void *array, uint32_t len, uint32_t w){ T* arr = static_cast (array); std::deque> cache; for(int i = 0; i < len; ++i){ if(!cache.empty() && cache.front().second == i-w) cache.pop_front(); if constexpr(minmax) while(!cache.empty() && cache.back().first>arr[i]) cache.pop_back(); else while(!cache.empty() && cache.back().first inline void mm(void *array, uint32_t len, uint32_t w, bool mm){ mm? running(array, len, w) : running(array, len, w); } extern "C" { #include int mmw(void *array, unsigned long long misc[]){ char _ty = misc[0]; uint32_t len = misc[1]; uint32_t w = misc[2]; bool minmax = misc[3]-0x10000; switch(_ty){ case 'F': mm(array, len, w, minmax); break; case 'C': case 'G': mm(array, len, w, minmax); break; case 'H': mm(array, len, w, minmax); break; case 'D': case 'I': mm(array, len, w, minmax); break; case 'T': case 'J': mm(array, len, w, minmax); break; case 'L': if(len == 0) break; default: printf("nyi %c\n", _ty); } return 0; } }