-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac88fbd
commit 779f1b0
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Created by forma on 20/06/23. | ||
// | ||
|
||
#ifndef EXAMPLES_HEAPVIEWTRAITS_HPP | ||
#define EXAMPLES_HEAPVIEWTRAITS_HPP | ||
#include <vector> | ||
#include <optional> | ||
|
||
|
||
namespace apsc | ||
{ | ||
|
||
/*! | ||
@brief Traits for the heapView class | ||
@tparam DataElementType The type of the elements stored in the heap | ||
*/ | ||
template <class DataElementType> | ||
struct heapViewTraits | ||
{ | ||
//! The type of the index | ||
using Index = typename std::vector<DataElementType>::size_type; | ||
//! The type of the vector storing the data | ||
using DataVector = std::vector<DataElementType>; | ||
//! The type of the indixes of the heap (it is the same as the type of the indexes of the data vector) | ||
using DataIndex = Index; | ||
/*! The type of the elements stored in the heap. | ||
* It is the same as the type of the elements stored in the data vector | ||
* @note We need a comparison operator on this type | ||
*/ | ||
using ElementType = DataElementType; | ||
/*! The internal structure keeping the indexes of the heap | ||
* | ||
* HeapIndex(i) returns the index of the i-th element in the heap | ||
*/ | ||
using HeapIndex = std::vector<Index>; | ||
/*! An internal structure storing the indexes of the data vector | ||
* HeapIter(i) returns the index of the i-th heap element in the data vector | ||
* We have HeapIndex(HeapIter(i))=i if i is a valid index of the heap | ||
*/ | ||
using HeapIter = std::vector<std::optional<Index>>; | ||
}; | ||
|
||
} // namespace apsc | ||
#endif // EXAMPLES_HEAPVIEWTRAITS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters