FastLED 3.9.15
Loading...
Searching...
No Matches

◆ update() [2/2]

template<typename T, fl::size N = 0>
T fl::detail::AlphaTrimmedMeanImpl< T, N >::update ( T input)
inline

Definition at line 46 of file alpha_trimmed_mean_impl.h.

46 {
47 if (!mRing.full()) {
48 T* base = &mSorted[0];
50 fl::size idx = static_cast<fl::size>(pos - base);
51 for (fl::size i = mSortedCount; i > idx; --i) {
52 mSorted[i] = mSorted[i - 1];
53 }
54 mSorted[idx] = input;
56 } else {
57 T oldest = mRing.front();
58 T* base = &mSorted[0];
60 fl::size rm = static_cast<fl::size>(rm_pos - base);
61 for (fl::size i = rm; i + 1 < mSortedCount; ++i) {
62 mSorted[i] = mSorted[i + 1];
63 }
65 fl::size idx = static_cast<fl::size>(ins_pos - base);
66 for (fl::size i = mSortedCount - 1; i > idx; --i) {
67 mSorted[i] = mSorted[i - 1];
68 }
69 mSorted[idx] = input;
70 }
71 mRing.push_back(input);
72
75 if (lo >= hi) {
77 } else {
78 T sum = T(0);
79 for (fl::size i = lo; i < hi; ++i) {
80 sum = sum + mSorted[i];
81 }
83 }
84 return mLastValue;
85 }
fl::enable_if< fl::is_floating_point< T >::value, T >::type div_by_count(T sum, fl::size count)
Iterator lower_bound(Iterator first, Iterator last, const T &value, Compare comp) FL_NOEXCEPT
Definition algorithm.h:551

References fl::detail::div_by_count(), fl::lower_bound(), mLastValue, mRing, mSorted, mSortedCount, mTrimCount, and pos.

+ Here is the call graph for this function: