Loading...
Searching...
No Matches
entry_constructors.h
Go to the documentation of this file.
1/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2 * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3 * Author(s): Hannah Schreiber
4 *
5 * Copyright (C) 2024 Inria
6 *
7 * Modification(s):
8 * - YYYY/MM Author: Description of the modification
9 */
10
16
17#ifndef PM_COLUMN_ENTRY_CONSTRUCTORS_H
18#define PM_COLUMN_ENTRY_CONSTRUCTORS_H
19
20#include <utility> //std::swap
21
22#include <gudhi/Simple_object_pool.h>
23
24namespace Gudhi {
25namespace persistence_matrix {
26
35template <class Entry>
36struct New_entry_constructor {
40 New_entry_constructor() = default;
41
48 template <class... U>
49 Entry* construct(U&&... u) const
50 {
51 return new Entry(std::forward<U>(u)...);
52 }
53
59 void destroy(Entry* entry) const { delete entry; }
60
64 friend void swap([[maybe_unused]] New_entry_constructor& col1,
65 [[maybe_unused]] New_entry_constructor& col2) noexcept {}
66};
67
77template <class Entry>
78struct Pool_entry_constructor {
79 public:
84 Pool_entry_constructor() : entryPool_() {}
85
86 // TODO: what does happen when the pool is copied?
87
94 template <class... U>
95 Entry* construct(U&&... u)
96 {
97 return entryPool_.construct(std::forward<U>(u)...);
98 }
99
105 void destroy(Entry* entry) { entryPool_.destroy(entry); }
106
110 friend void swap(Pool_entry_constructor& col1, Pool_entry_constructor& col2) noexcept
111 {
112 std::swap(col1.entryPool_, col2.entryPool_);
113 }
114
115 private:
116 Simple_object_pool<Entry> entryPool_;
117};
118
119} // namespace persistence_matrix
120} // namespace Gudhi
121
122#endif // PM_COLUMN_ENTRY_CONSTRUCTORS_H
Persistence matrix namespace.
Definition FieldOperators.h:18
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14