DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
SortedSet.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Common.h
"
4
#include "
System/Object.h
"
5
#include "
System/Array.h
"
6
#include "
System/Collections/Generic/List.h
"
7
8
namespace
DotNetDupe
{
9
namespace
System
{
10
namespace
Collections
{
11
namespace
Generic
{
12
19
template
<
typename
T>
20
class
SortedSet
:
public
Object
{
21
private
:
22
List<T>
m_lstItems;
23
24
public
:
26
SortedSet
() =
default
;
27
30
int
GetCount
()
const
{
return
m_lstItems.GetCount(); }
31
35
bool
Add
(
const
T& item) {
36
int
index = m_lstItems.BinarySearch(item);
37
if
(index >= 0)
return
false
;
38
39
m_lstItems.Insert(~index, item);
40
return
true
;
41
}
42
46
bool
Remove
(
const
T& item) {
47
int
index = m_lstItems.BinarySearch(item);
48
if
(index < 0)
return
false
;
49
50
m_lstItems.RemoveAt(index);
51
return
true
;
52
}
53
57
bool
Contains
(
const
T& item)
const
{
58
return
m_lstItems.BinarySearch(item) >= 0;
59
}
60
62
void
Clear
() {
63
m_lstItems.Clear();
64
}
65
68
void
UnionWith
(
const
SortedSet<T>
& other) {
69
for
(
int
i = 0; i < other.m_lstItems.GetCount(); ++i) {
70
Add
(other.m_lstItems[i]);
71
}
72
}
73
76
void
IntersectWith
(
const
SortedSet<T>
& other) {
77
for
(
int
i = m_lstItems.GetCount() - 1; i >= 0; --i) {
78
if
(!other.
Contains
(m_lstItems[i])) {
79
Remove
(m_lstItems[i]);
80
}
81
}
82
}
83
86
void
ExceptWith
(
const
SortedSet<T>
& other) {
87
for
(
int
i = 0; i < other.m_lstItems.GetCount(); ++i) {
88
Remove
(other.m_lstItems[i]);
89
}
90
}
91
94
Array<T>
ToArray
()
const
{
95
return
m_lstItems.ToArray();
96
}
97
};
98
99
}
100
}
101
}
102
}
Array.h
Provides methods for creating, manipulating, searching, and sorting arrays.
Common.h
Defines common cross-platform macros, export decorators, and fundamental types.
List.h
Represents a strongly typed list of objects that can be accessed by index mirroring ....
Object.h
Base object class for DotNetDupe mirroring .NET System.Object.
DotNetDupe::System::Array
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition
Array.h:29
DotNetDupe::System::Collections::Generic::List
Represents a strongly typed list of objects accessible by index.
Definition
List.h:29
DotNetDupe::System::Collections::Generic::SortedSet::ToArray
Array< T > ToArray() const
Copies the elements of the SortedSet to a new array.
Definition
SortedSet.h:94
DotNetDupe::System::Collections::Generic::SortedSet::Clear
void Clear()
Removes all elements from the set.
Definition
SortedSet.h:62
DotNetDupe::System::Collections::Generic::SortedSet::UnionWith
void UnionWith(const SortedSet< T > &other)
Modifies the current SortedSet object so that it contains all elements that are present in either the...
Definition
SortedSet.h:68
DotNetDupe::System::Collections::Generic::SortedSet::GetCount
int GetCount() const
Gets the number of elements in the SortedSet.
Definition
SortedSet.h:30
DotNetDupe::System::Collections::Generic::SortedSet::IntersectWith
void IntersectWith(const SortedSet< T > &other)
Modifies the current SortedSet object so that it contains only elements that are also in a specified ...
Definition
SortedSet.h:76
DotNetDupe::System::Collections::Generic::SortedSet::ExceptWith
void ExceptWith(const SortedSet< T > &other)
Removes all elements that are in a specified collection from the current SortedSet object.
Definition
SortedSet.h:86
DotNetDupe::System::Collections::Generic::SortedSet::Add
bool Add(const T &item)
Adds an element to the set and returns a value that indicates if it was successfully added.
Definition
SortedSet.h:35
DotNetDupe::System::Collections::Generic::SortedSet::SortedSet
SortedSet()=default
Initializes a new instance of the SortedSet class.
DotNetDupe::System::Collections::Generic::SortedSet::Contains
bool Contains(const T &item) const
Determines whether the set contains a specific element.
Definition
SortedSet.h:57
DotNetDupe::System::Collections::Generic::SortedSet::Remove
bool Remove(const T &item)
Removes a specified item from the SortedSet.
Definition
SortedSet.h:46
DotNetDupe::System::Object
Supports all classes in the DotNetDupe class hierarchy.
Definition
Object.h:18
DotNetDupe::System::Collections::Generic
Definition
Dictionary.h:15
DotNetDupe::System::Collections
Definition
BlockingCollection.h:15
DotNetDupe::System
Definition
Action.h:11
DotNetDupe
Definition
IServiceCollection.h:7
Include
System
Collections
Generic
SortedSet.h
Generated by
1.18.0