--- nono/lib/fixedqueue.h 2026/04/29 17:05:08 1.1.1.8 +++ nono/lib/fixedqueue.h 2026/04/29 17:05:52 1.1.1.12 @@ -20,8 +20,8 @@ // // T 型で上限 capacity 個のキュー。 // スレッドセーフではない。 -template -class FixedQueue : private std::vector +template +class FixedQueue final : private std::vector { using inherited = std::vector; public: @@ -32,7 +32,7 @@ class FixedQueue : private std::vector::value, "T must be arithmetic"); + + if (Empty()) { + return 0; + } + T sum = 0; + for (uint i = 0; i < length; i++) { + sum += Peek(i); + } + return sum / length; + } + private: uint start {}; // 開始位置 uint length {}; // 現在有効な長さ