• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_NQE_WEIGHTED_OBSERVATION_H_
6 #define NET_NQE_WEIGHTED_OBSERVATION_H_
7 
8 #include "net/base/net_export.h"
9 
10 namespace net::nqe::internal {
11 
12 // Holds an observation and its weight.
13 struct NET_EXPORT_PRIVATE WeightedObservation {
WeightedObservationWeightedObservation14   WeightedObservation(int32_t value, double weight)
15       : value(value), weight(weight) {}
16 
WeightedObservationWeightedObservation17   WeightedObservation(const WeightedObservation& other)
18       : WeightedObservation(other.value, other.weight) {}
19 
20   WeightedObservation& operator=(const WeightedObservation& other) = default;
21 
22   // Required for sorting the samples in the ascending order of values.
23   bool operator<(const WeightedObservation& other) const {
24     return (value < other.value);
25   }
26 
27   // Value of the sample.
28   int32_t value;
29 
30   // Weight of the sample. This is computed based on how much time has passed
31   // since the sample was taken.
32   double weight;
33 };
34 
35 }  // namespace net::nqe::internal
36 
37 #endif  // NET_NQE_WEIGHTED_OBSERVATION_H_
38