Template Class Scatter
Defined in File scatter.hpp
Inheritance Relationships
Base Type
public std::map< double, T >
Class Documentation
-
template<class T>
class Scatter : public std::map<double, T> A container for managing scattered data points with unique numeric keys.
The Scatter class is a specialized map that provides additional functionalities such as adding points, retrieving values, computing minimum spacing, and summing values.
- Template Parameters:
T – The type of the values stored in the map.
Public Functions
-
inline Scatter()
Default constructor.
-
inline Scatter(double x, const T &y)
Constructs a Scatter instance with a single data point.
- Parameters:
x – The key (x-coordinate) of the data point.
y – The value (y-coordinate) of the data point.
-
inline Scatter(const std::vector<std::pair<double, T>> &pts)
Constructs a Scatter instance from a vector of data points.
- Parameters:
pts – A vector of (x, y) pairs to initialize the Scatter instance.
-
inline bool add(double x, const T &y)
Adds a data point to the scatter collection.
- Parameters:
x – The x-coordinate.
y – The y-coordinate.
- Returns:
true if the point was inserted, false if it already exists.
-
inline bool finite() const
Checks if all stored points are finite.
- Returns:
true if all points have finite values, false otherwise.
-
inline const T &first(const T &default_value) const
Retrieves the first stored value or a default value if empty.
- Parameters:
default_value – Value to return if no points are stored.
- Returns:
The first value or the provided default.
-
inline const T &last(const T &default_value) const
Retrieves the last stored value or a default value if empty.
- Parameters:
default_value – Value to return if no points are stored.
- Returns:
The last value or the provided default.
-
inline double min_space_x() const
Computes the minimum spacing between stored x-values.
- Returns:
The smallest distance between consecutive x-values, or NaN if undefined.
-
inline std::ostream &print(std::ostream &out) const
Prints the Scatter contents to an output stream.
- Parameters:
out – The output stream.
- Returns:
Reference to the output stream.
-
inline std::vector<double> get_xs() const
Retrieves all stored x-values.
- Returns:
A vector of x-values.