NumCpp  2.16.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
find_duplicates.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <complex>
31#include <unordered_set>
32
36#include "NumCpp/NdArray.hpp"
37
38namespace nc
39{
40 //============================================================================
41 // Method Description:
52 template<typename dtype>
54 {
56
57 auto repeats = std::unordered_set<dtype>{};
58 auto count = std::unordered_set<dtype>{};
59
60 for (const auto& value : inArray)
61 {
62 if (count.count(value) > 0)
63 {
64 repeats.insert(value);
65 }
66 else
67 {
68 count.insert(value);
69 }
70 }
71
72 return sort(NdArray<dtype>{ repeats.begin(), repeats.end() });
73 }
74
75 //============================================================================
76 // Method Description:
87 template<typename dtype>
89 {
91
92 auto repeats = std::unordered_set<std::complex<dtype>, ComplexHash<dtype>>{};
93 auto count = std::unordered_set<std::complex<dtype>, ComplexHash<dtype>>{};
94
95 for (const auto& value : inArray)
96 {
97 if (count.count(value) > 0)
98 {
99 repeats.insert(value);
100 }
101 else
102 {
103 count.insert(value);
104 }
105 }
106
107 return sort(NdArray<std::complex<dtype>>{ repeats.begin(), repeats.end() });
108 }
109} // namespace nc
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
iterator begin() noexcept
Definition NdArrayCore.hpp:1315
Definition Cartesian.hpp:40
NdArray< dtype > find_duplicates(const NdArray< dtype > &inArray)
Definition find_duplicates.hpp:53
NdArray< dtype > sort(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition sort.hpp:46
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
Definition StdComplexOperators.hpp:125