60#include "vtkABINamespace.h"
130VTK_ABI_NAMESPACE_BEGIN
133struct DenseScatterer;
134struct SparseScatterer;
141VTK_ABI_NAMESPACE_BEGIN
148template <
typename TKey,
typename TElementId,
typename TKeyId>
156 static_assert(std::is_integral_v<ElementIdType>,
"ElementIdType must be an integer type");
203template <
typename TKey = vtkIdType,
typename TElementId = vtkIdType>
210 static_assert(std::is_integral_v<KeyType> && !std::is_same_v<KeyType, bool>,
211 "The KeyType of DenseKeys must be an integer type: a key id is its difference with the "
229 this->MinKey = this->MaxKey = 0;
233 friend struct detail::DenseScatterer;
234 friend struct detail::Reducer;
235 friend struct detail::Grouper;
241 void CopyKeysFrom(
const DenseKeys& other)
244 this->MinKey = other.MinKey;
245 this->MaxKey = other.MaxKey;
258template <
typename TKey = vtkIdType,
typename TElementId = vtkIdType>
265 static_assert(std::is_signed_v<TElementId>,
"ElementIdType must be signed, see FindKeyId()");
283 friend struct detail::SparseScatterer;
284 friend struct detail::Reducer;
285 friend struct detail::Grouper;
291 this->Keys = other.Keys;
294 std::shared_ptr<KeyType[]> Keys;
300template <
typename Input>
302template <
typename Input>
304template <
typename Element,
typename ElementIdType>
306template <
typename Element,
typename ElementIdType>
316template <
typename InputMapper>
326template <
typename Input,
typename Output>
328template <
typename Input,
typename Output>
337template <
typename Element,
typename ElementIdType>
339 const Element* elements, ElementIdType numberOfElements, Element* scattered);
340template <
typename Element,
typename ElementIdType>
352template <
typename Input,
typename Output>
354template <
typename Element,
typename ElementIdType>
356 const Element* elements, ElementIdType numberOfElements, Element* scattered);
367template <
typename TKeys,
typename Output,
typename Functor,
typename... Args>
380template <
typename TKeys>
391template <
typename TKeys,
typename Output,
typename Functor>
400template <
typename TKeys,
typename Output,
typename = std::enable_if_t<!std::is_po
inter_v<Output>>>
403template <
typename TKeys,
typename Element>
413 template <
typename Element,
typename KeyIdType,
typename ElementIdType>
414 void operator()(Element* elements, KeyIdType beginKeyId, KeyIdType endKeyId,
415 const ElementIdType* offsets, ElementIdType* counts)
const;
425template <
typename TKeys>
445 return this->GroupOffsets[group + 1] - this->GroupOffsets[group];
453 this->NumberOfGroups = 0;
454 this->GroupOffsets.reset();
458 friend struct detail::Grouper;
461 std::unique_ptr<ElementIdType[]> GroupOffsets;
475template <
typename TKeys>
490template <
typename TKeys,
typename Output,
typename Functor>
499template <
typename TKeys,
typename Output,
typename = std::enable_if_t<!std::is_po
inter_v<Output>>>
502template <
typename TKeys,
typename Element>
512 template <
typename Element,
typename KeyIdType,
typename ElementIdType>
513 void operator()(Element* elements, KeyIdType beginKeyId, KeyIdType endKeyId,
514 const ElementIdType* offsets, uint8_t* groupStarts)
const;
521#include "vtkKeys.txx"
The dense keys of the elements, returned by ScatterDense(): every key of the key range [GetMinKey(),...
KeyType GetMinKey() const
KeyType GetKey(KeyIdType keyId) const
The key of a key id, and the key id of a key of [GetMinKey(), GetMaxKey()].
void Reset()
Release the memory.
KeyType GetMaxKey() const
KeyIdType GetKeyId(KeyType key) const
The groups of equal elements of Group(), ordered by key: the elements of group g are at [GetGroupOffs...
ElementIdType GetGroupOffset(ElementIdType group) const
The first element of a group, 0 <= group <= GetNumberOfGroups().
const ElementIdType * GetGroupOffsets() const
The first element of every group, GetNumberOfGroups() + 1 values, nullptr without grouping.
ElementIdType GetNumberOfGroups() const
typename TKeys::ElementIdType ElementIdType
ElementIdType GetGroupSize(ElementIdType group) const
void Reset()
Release the memory.
What DenseKeys and SparseKeys share, and all that Reduce(), Group(), Compact() and ForEachKeyRange() ...
ElementIdType GetOffset(KeyIdType keyId) const
The first element of a key id, 0 <= keyId <= GetNumberOfKeys().
vtkIdType GetNumberOfRecords() const
vtkIdType NumberOfRecords
KeyIdType GetNumberOfKeys() const
void CopyBaseFrom(const KeysBase &other)
const ElementIdType * GetOffsets() const
The first element of every key id, GetNumberOfKeys() + 1 values, nullptr without element.
ElementIdType GetNumberOfElementsOfKey(KeyIdType keyId) const
vtkIdType GetNumberOfElements() const
vtkIdType NumberOfElements
std::unique_ptr< ElementIdType[]> Offsets
The keys of the surviving elements of Reduce(), or of the groups of Group(): the keys of the scattere...
The sparse keys of the elements, returned by ScatterSparse(): the distinct keys, in increasing order ...
void Reset()
Release the memory, the distinct keys once no reduction shares them.
KeyIdType FindKeyId(KeyType key) const
KeyType GetKey(KeyIdType keyId) const
The key of a key id, and the key id of a key, -1 if absent, by a binary search.
typename ElementIdTypeOf< In >::type ElementIdTypeOfT
std::decay_t< decltype(std::declval< const T & >().GetKey())> ElementKeyOf
typename KeyTypeOf< In >::type KeyTypeOfT
SparseKeys< detail::ElementKeyOf< Element >, ElementIdType > SparseArrayKeys
SparseKeys< detail::KeyTypeOfT< Input >, detail::ElementIdTypeOfT< Input > > SparseKeysOf
vtkIdType CountElements(const InputMapper &mapper)
The number of elements of an InputMapper, without storing them, e.g., to choose its ElementIdType.
DenseKeysOf< Input > ScatterDense(const Input &input, Output &output)
Scatter the elements of an Input or an InputMapper to an Output by a counting sort over the key range...
Grouping< TKeys > Group(const TKeys &keys, Output &&output, Functor &&functor)
Group the equal elements of every key of the Output with a group functor called as functor(output,...
SparseKeysOf< Input > ScatterSparse(const Input &input, Output &output)
Scatter the elements of an Input or an InputMapper, or an array of elements, to an Output by a parall...
TKeys::ElementIdType Compact(const TKeys &keys, const ReducedKeys< TKeys > &reduced, const Output &input, Output &output)
Copy the survivors of the reduced Output input contiguously into output, another Output that implemen...
ReducedKeys< TKeys > Reduce(const TKeys &keys, Output &&output, Functor &&functor)
Keep the surviving elements of every key of the Output at its front with a reduce functor called as f...
DenseKeys< detail::KeyTypeOfT< Input >, detail::ElementIdTypeOfT< Input > > DenseKeysOf
The keys of the scatters of an input, with its KeyType and ElementIdType, and of an array.
DenseKeys< detail::ElementKeyOf< Element >, ElementIdType > DenseArrayKeys
void ForEachKeyRange(const TKeys &keys, Output &&output, Functor &functor, Args... args)
Call functor(output, beginKeyId, endKeyId, offsets, args...) on disjoint ranges of key ids,...
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
The result of Group(): the groups, and the keys of the groups, i.e., the groups of key id k are [Keys...
GroupedElements< TKeys > Groups
ReducedKeys< TKeys > Keys
The group functor of an array of elements, with operator< and operator!=: it sorts the elements of ev...
void operator()(Element *elements, KeyIdType beginKeyId, KeyIdType endKeyId, const ElementIdType *offsets, uint8_t *groupStarts) const
The reduce functor of an array of elements that keeps one element of every set of equal ones,...
void operator()(Element *elements, KeyIdType beginKeyId, KeyIdType endKeyId, const ElementIdType *offsets, ElementIdType *counts) const
the traits and checks of the concepts of vtk::keys, see vtkKeys.h