ClusterVector¶
-
template<typename T, typename CoordType = int16_t>
class ClusterVector¶ ClusterVector is a container for clusters of various sizes. It uses a contiguous memory buffer to store the clusters.
Note
push_back can invalidate pointers to elements in the container
- Template Parameters:
T – data type of the pixels in the cluster
CoordType – data type of the x and y coordinates of the cluster (normally int16_t)
Public Functions
-
inline ClusterVector(size_t cluster_size_x, size_t cluster_size_y, size_t capacity = 1024)¶
Construct a new ClusterVector object.
- Parameters:
cluster_size_x – size of the cluster in x direction
cluster_size_y – size of the cluster in y direction
capacity – initial capacity of the buffer in number of clusters
-
inline ~ClusterVector()¶
-
inline ClusterVector(ClusterVector &&other) noexcept¶
-
inline ClusterVector &operator=(ClusterVector &&other) noexcept¶
-
inline void reserve(size_t capacity)¶
Reserve space for at least capacity clusters.
Note
If capacity is less than the current capacity, the function does nothing.
- Parameters:
capacity – number of clusters to reserve space for
-
inline void push_back(CoordType x, CoordType y, const std::byte *data)¶
Add a cluster to the vector.
Warning
The data pointer must point to a buffer of size cluster_size_x * cluster_size_y * sizeof(T)
- Parameters:
x – x-coordinate of the cluster
y – y-coordinate of the cluster
data – pointer to the data of the cluster
-
inline std::vector<T> sum()¶
Sum the pixels in each cluster.
- Returns:
std::vector<T> vector of sums for each cluster
-
inline size_t size() const¶
-
inline size_t capacity() const¶
-
inline size_t element_offset() const¶
Return the offset in bytes for a single cluster.
-
inline size_t element_offset(size_t i) const¶
Return the offset in bytes for the i-th cluster.
-
inline std::byte *element_ptr(size_t i)¶
Return a pointer to the i-th cluster.
-
inline const std::byte *element_ptr(size_t i) const¶
-
inline size_t cluster_size_x() const¶
-
inline size_t cluster_size_y() const¶
-
inline std::byte *data()¶
-
inline std::byte const *data() const¶
-
inline const std::string_view fmt_base() const¶