TTK
Loading...
Searching...
No Matches
core
base
common
ArrayLinkedList.h
Go to the documentation of this file.
1
13
14
#include <array>
15
#include <list>
16
17
#pragma once
18
19
namespace
ttk
{
20
template
<
typename
datatype,
int
size>
21
class
ArrayLinkedList
{
22
public
:
23
std::list<std::array<datatype, size>>
list_
;
24
int
numberOfElements_
;
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_
{};
31
ArrayLinkedList
()
32
:
list_
(std::list<std::array<datatype, size>>({})),
numberOfElements_
(0) {
33
}
34
35
datatype *
addArrayElement
(datatype element) {
36
numberOfElements_
=
numberOfElements_
% size;
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
ttk::ArrayLinkedList
This class describes a dynamic size data structure for thread safe computation. It is a linked list o...
Definition
ArrayLinkedList.h:21
ttk::ArrayLinkedList::addArrayElement
datatype * addArrayElement(datatype element)
Definition
ArrayLinkedList.h:35
ttk::ArrayLinkedList::list_
std::list< std::array< datatype, size > > list_
Definition
ArrayLinkedList.h:23
ttk::ArrayLinkedList::ArrayLinkedList
ArrayLinkedList()
Definition
ArrayLinkedList.h:31
ttk::ArrayLinkedList::numberOfElements_
int numberOfElements_
Definition
ArrayLinkedList.h:24
ttk::ArrayLinkedList::padding_
std::array< unsigned char, 32 > padding_
Definition
ArrayLinkedList.h:30
ttk
The Topology ToolKit.
Definition
AbstractTriangulation.h:51
Generated on Thu Sep 26 2024 06:50:17 for TTK by
1.9.8