Advanced Chunk Processing Library 0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
chunk_common.hpp
Go to the documentation of this file.
1#pragma once
2
3#if defined(_MSC_VER)
4#define CHUNK_EXPORT __declspec(dllexport)
5#else
6#define CHUNK_EXPORT __attribute__((visibility("default")))
7#endif
8
9#include <algorithm>
10#include <type_traits>
11#include <vector>
12
13namespace chunk_processing {
14
15// Type traits
16template <typename T>
17struct is_vector : std::false_type {};
18
19template <typename T, typename A>
20struct is_vector<std::vector<T, A>> : std::true_type {};
21
22// Helper function to check if a vector is jagged
23template <typename T>
24bool is_jagged(const std::vector<std::vector<T>>& data) {
25 if (data.empty())
26 return false;
27 const size_t expected_size = data[0].size();
28 return std::any_of(data.begin(), data.end(),
29 [expected_size](const auto& row) { return row.size() != expected_size; });
30}
31
32// Helper function for 3D jagged detection
33template <typename T>
34bool is_jagged_3d(const std::vector<std::vector<std::vector<T>>>& data) {
35 if (data.empty())
36 return false;
37
38 // Check first level consistency
39 const size_t first_size = data[0].size();
40 if (std::any_of(data.begin(), data.end(),
41 [first_size](const auto& matrix) { return matrix.size() != first_size; })) {
42 return true;
43 }
44
45 // Check second level consistency
46 const size_t second_size = data[0][0].size();
47 return std::any_of(data.begin(), data.end(), [second_size](const auto& matrix) {
48 return std::any_of(matrix.begin(), matrix.end(),
49 [second_size](const auto& row) { return row.size() != second_size; });
50 });
51}
52
53} // namespace chunk_processing
bool is_jagged(const std::vector< std::vector< T > > &data)
bool is_jagged_3d(const std::vector< std::vector< std::vector< T > > > &data)