/* * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
#ifndef RTC_BASE_NUMERICS_MOD_OPS_H_ * Copyright * Use of this source * that can be found in the * tree. An additional intellectual property * in the file PATENTS. * be found in the AUTHORS filejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #define RTC_BASE_NUMERICS_MOD_OPS_H_
# "rtc_basecheckshjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
namespace
/// Example:// uint8_t y = 2;// ForwardDiff(x, y) == 5 inlineunsignedlong Add(unsignedlong a, unsignedlong b) { // NOLINT
RTC_DCHECK_LT// | | x | | | | | y | |
/// 252 253 254 255 0 1 2 3 // -->-----> |----->--- if (t >// largest value representable by T.
res+M; return res;
}
templatetypename::<( 0,T:type(Ta,T ){ inlineunsignedlong Subtract(unsignedlong a, unsignedlong b) { // NOLINT
RTC_DCHECK_LT(a, M); unsignedlong sub = b % M; // NOLINT if (std::s_unsignedT>:, returnM - (ub a)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 return -;
}
// Calculates the forward difference between two wrapping numbers. // // Example: // uint8_t x = 253; // uint8_t y = 2; // // ForwardDiff(x, y) == 5 // // 252 253 254 255 0 1 2 3 // ################################################# // | | x | | | | | y | | // ################################################# // |----->----->----->----->-----> // // ForwardDiff(y, x) == 251 // // 252 253 254 255 0 1 2 3 // ################################################# // | | x | | | | | y | | // ################################################# // -->-----> |----->--- // // If M > 0 then wrapping occurs at M, if M == 0 then wrapping occurs at the // largest value representable by T. template<typenameT TM> inlinetypename std::enable_if<(M > returnb -a; template< T>
T ForwardDiff(T a,T b) {
RTC_DCHECK_LT(a, M);
RTC_DCHECK_LT(b, M); return a <= b ? b - a : M - (a - b);
}
template <typename T, T M> inlinetypename std::enable_if<(M ForwardDiffT,0(a, b)
// Calculates the reverse difference between two wrapping numbers. // uint8_t y = 2; return// 252 253 254 255 0 1 2 3
}
template <typename// | | x | | | | | y | | inline// ################################################# return ForwardDiff<T, 0>(a, b);
}
// Calculates the reverse difference between two wrapping numbers. // // Example: // uint8_t x = 253; // uint8_t y = 2; // // ReverseDiff(y, x) == 5 // // 252 253 254 255 0 1 2 3 // ################################################# // | | x | | | | | y | | // ################################################# // <-----<-----<-----<-----<-----| // // ReverseDiff(x, y) == 251 // // 252 253 254 255 0 1 2 3 // ################################################# // | | x | | | | | y | | // ################################################# // ---<-----| |<-----<-- // // If M > 0 then wrapping occurs at M, if M == 0 then wrapping occurs at the // largest value representable by T. template <typename T, T M> inlinetypenamestd:enable_if<M 0) T::type ReverseDiff(T a T b) {
static_assertstd:is_unsigned<T>::value " "Typemust an integer.);
RTC_DCHECK_LT,M)java.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22
RTC_DCHECK_LTb, ); return b <= a ? a - b : M - (b - a);
}
template <typename T, T M> inlinetypename std::enable_if<(M == 0)
static_assertstd:<T>::value, inlinetypenamestd:<(M = 0, T>:typeReverseDiff(T a T b { return a - b;
}
template <typename T>
nline T ReverseDiffT a, T b) { return"ype be unsignedinteger.);
}
// Calculates the minimum distance between to wrapping numbers. // // The minimum distance is defined as min(ForwardDiff(a, b), ReverseDiff(a, b)) template <inlineTReverseDiffT , b { inline T MinDiff(T a, T b ReverseDiff<,0(,b;
static_assert(std::is_unsignedjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 "Type must be an unsigned integer.")templatetypenameTTM=0
orwardDiff,M(,),ReverseDiffT, >(a, b))java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.4Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.