TTK
Loading...
Searching...
No Matches
ArrayLinkedList.h
Go to the documentation of this file.
1
13
14#include <array>
15#include <list>
16
17#pragma once
18
19namespace ttk {
20 template <typename datatype, int size>
22 public:
23 std::list<std::array<datatype, size>> list_;
25 // In order to prevent false sharing when creating a
26 // std::vector of ArrayLinkedList objects (one element
27 // of the std::vector for each thread), it is necessary
28 // that one ArrayLinkedList object be bigger than one cache
29 // line. Here, we assume a cache line to be 64 bytes.
30 std::array<unsigned char, 32> padding_{};
32 : list_(std::list<std::array<datatype, size>>({})), numberOfElements_(0) {
33 }
34
35 datatype *addArrayElement(datatype element) {
37 if(numberOfElements_ == 0) {
38 this->list_.push_back(std::array<datatype, size>({}));
39 }
40 this->list_.back().at(numberOfElements_) = element;
41 this->numberOfElements_++;
42 return &(this->list_.back().at(numberOfElements_ - 1));
43 }
44 };
45} // namespace ttk
This class describes a dynamic size data structure for thread safe computation. It is a linked list o...
datatype * addArrayElement(datatype element)
std::list< std::array< datatype, size > > list_
std::array< unsigned char, 32 > padding_
The Topology ToolKit.