14 std::vector<SimplexId> data_;
16 std::vector<SimplexId> offsets_;
26 inline void setData(std::vector<SimplexId> &&data,
27 std::vector<SimplexId> &&offsets) {
28 this->data_ = std::move(data);
29 this->offsets_ = std::move(offsets);
37 this->offsets_.clear();
48#ifndef TTK_ENABLE_KAMIKAZE
49 if(id < 0 || id > (
SimplexId)offsets_.size() - 1) {
53 return this->offsets_[
id + 1] - this->offsets_[id];
60#ifndef TTK_ENABLE_KAMIKAZE
61 if(id < 0 || id > (
SimplexId)offsets_.size()) {
65 return this->offsets_[id];
72#ifndef TTK_ENABLE_KAMIKAZE
73 if(
id >= this->len ||
ptr ==
nullptr) {
86 return this->ptr + this->len;
88 inline size_t size()
const {
100 return this->parent[this->id];
103 return this->
id != other.
id;
111 return {this->
size(), *
this};
115#ifndef TTK_ENABLE_KAMIKAZE
116 if(
id >= this->offsets_.size()) {
120 return {
static_cast<size_t>(this->
size(
id)), this->
get_ptr(
id, 0)};
127#ifndef TTK_ENABLE_KAMIKAZE
128 if(id < 0 || id > (
SimplexId)offsets_.size() - 1) {
131 if(local < 0 || local >= this->
size(
id)) {
135 return this->data_[this->offsets_[id] + local];
142#ifndef TTK_ENABLE_KAMIKAZE
143 if(id < 0 || id > (
SimplexId)offsets_.size() - 1) {
146 if(local < 0 || local >= this->
size(
id)) {
150 return &this->data_[this->offsets_[id] + local];
157 return offsets_.data();
167 return this->offsets_.size() - 1;
174 return this->data_.size();
181 return this->data_.empty() || this->offsets_.empty();
188 return (this->data_.size() + this->offsets_.size()) *
sizeof(
SimplexId);
200 template <
typename T>
201 void fillFrom(
const std::vector<T> &src,
int threadNumber = 1) {
202 this->offsets_.resize(src.size() + 1);
203 for(
size_t i = 0; i < src.size(); ++i) {
204 this->offsets_[i + 1] = this->offsets_[i] + src[i].size();
206 this->data_.resize(this->offsets_.back());
207#ifdef TTK_ENABLE_OPENMP
208#pragma omp parallel for num_threads(threadNumber)
210 for(
size_t i = 0; i < src.size(); ++i) {
211 for(
size_t j = 0; j < src[i].size(); ++j) {
212 this->data_[this->offsets_[i] + j] = src[i][j];
221 void copyTo(std::vector<std::vector<SimplexId>> &dst,
222 int threadNumber = 1)
const {
223 dst.resize(this->
size());
224 for(
size_t i = 0; i < this->
size(); ++i) {
225 dst[i].resize((*
this)[i].
size());
227#ifdef TTK_ENABLE_OPENMP
228#pragma omp parallel for num_threads(threadNumber)
230 for(
size_t i = 0; i < this->
size(); ++i) {
231 for(
size_t j = 0; j < dst[i].size(); ++j) {
232 dst[i][j] = (*this)[i][j];
246 std::ofstream out(fName);
247 for(
const auto slice : *
this) {
248 for(
const auto el : slice) {
260 const std::vector<std::vector<SimplexId>> &src) {
261 std::ofstream out(fName);
262 for(
const auto &vec : src) {
263 for(
const auto el : vec) {
#define TTK_FORCE_USE(x)
Force the compiler to use the function/method parameter.
Replacement for std::vector<std::vector<SimplexId>>
size_t dataSize() const
Returns the size of the data_ member.
void copyTo(std::vector< std::vector< SimplexId > > &dst, int threadNumber=1) const
Copy buffers to a std::vector<std::vector<SimplexId>>
Slice operator[](const size_t id) const
const SimplexId * offset_ptr() const
Returns a const pointer to the offset member.
SimplexId get(SimplexId id, SimplexId local) const
Returns the data inside the sub-vectors.
static void writeToFile(const std::string &fName, const std::vector< std::vector< SimplexId > > &src)
Also write std::vector<std::vector<SimplexId>> to disk.
size_t size() const
Returns the number of sub-vectors.
void setData(std::vector< SimplexId > &&data, std::vector< SimplexId > &&offsets)
Set internal data from pre-existing vectors.
const SimplexId * get_ptr(SimplexId id, SimplexId local) const
Returns a const pointer to the data inside the sub-vectors.
size_t footprint() const
Computes the memory footprint of the array.
void fillFrom(const std::vector< T > &src, int threadNumber=1)
Fill buffers from a std::vector<std::vector<SimplexId>>
void writeToFile(const std::string &fName) const
Write content into a file.
SimplexId size(SimplexId id) const
Get the size of a particular sub-vector.
SimplexId offset(SimplexId id) const
Get the offset of a particular sub-vector.
void clear()
Clear the underlying vectors.
bool empty() const
If the underlying buffers are empty.
TTK base package defining the standard types.
int SimplexId
Identifier type for simplices of any dimension.
const FlatJaggedArray & parent
bool operator!=(const Iterator &other) const
const SimplexId * begin() const
const SimplexId * data() const
const SimplexId *const ptr
SimplexId operator[](const size_t id) const
const SimplexId * end() const