CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
search_values.h
1
2#pragma once
3
4#include <cstdint>
5
6#include <system/object.h>
7#include <system/array.h>
8#include <system/span.h>
9#include <system/shared_ptr.h>
10
11#include <unordered_set>
12
13namespace System {
14namespace Buffers {
15
19template <typename T>
20class SearchValues final : public System::Object
21{
24
25 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
26 RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
27
28public:
30 SearchValues() = default;
31
36 {
37 System::SharedPtr<SearchValues<T>> result = System::MakeObject<SearchValues<T>>();
38 result->_values.reserve(static_cast<size_t>(values.get_Length()));
39 for (int32_t i = 0; i < values.get_Length(); i++)
40 {
41 result->_values.insert(values[i]);
42 }
43 return result;
44 }
45
49 bool Contains(T value) const
50 {
51 return _values.find(value) != _values.end();
52 }
53
54private:
55 std::unordered_set<T> _values;
56};
57
58} // namespace Buffers
59} // namespace System
Provides an immutable, read-only set of values optimized for efficient searching. Values are stored i...
Definition: search_values.h:21
static System::SharedPtr< SearchValues< T > > Create(const ReadOnlySpan< T > &values)
Creates a SearchValues instance from the specified set of values.
Definition: search_values.h:35
bool Contains(T value) const
Determines whether the specified value is contained in the set.
Definition: search_values.h:49
SearchValues()=default
Constructs an empty SearchValues instance.
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:51
Forward to use within Span class.
Definition: span.h:415
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9