DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
Queue.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/InvalidOperationException.h
"
7
#include "
System/Collections/Generic/List.h
"
8
9
namespace
DotNetDupe
{
10
namespace
System
{
11
namespace
Collections
{
12
namespace
Generic
{
13
20
template
<
typename
T>
21
class
Queue
:
public
Object
{
22
private
:
23
List<T>
m_lstItems;
24
25
public
:
27
Queue
() =
default
;
28
31
int
GetCount
()
const
{
return
m_lstItems.GetCount(); }
32
35
void
Enqueue
(
const
T& item) {
36
m_lstItems.Add(item);
37
}
38
42
T
Dequeue
() {
43
if
(m_lstItems.GetCount() == 0) {
44
throw
System::InvalidOperationException
(
"Queue is empty."
);
45
}
46
T item = m_lstItems[0];
47
m_lstItems.RemoveAt(0);
48
return
item;
49
}
50
54
T
Peek
()
const
{
55
if
(m_lstItems.GetCount() == 0) {
56
throw
System::InvalidOperationException
(
"Queue is empty."
);
57
}
58
return
m_lstItems[0];
59
}
60
64
bool
TryDequeue
(T& result) {
65
if
(m_lstItems.GetCount() == 0) {
66
return
false
;
67
}
68
result = m_lstItems[0];
69
m_lstItems.RemoveAt(0);
70
return
true
;
71
}
72
76
bool
TryPeek
(T& result)
const
{
77
if
(m_lstItems.GetCount() == 0) {
78
return
false
;
79
}
80
result = m_lstItems[0];
81
return
true
;
82
}
83
85
void
Clear
() {
86
m_lstItems.Clear();
87
}
88
92
bool
Contains
(
const
T& item)
const
{
93
return
m_lstItems.Contains(item);
94
}
95
98
Array<T>
ToArray
()
const
{
99
return
m_lstItems.ToArray();
100
}
101
};
102
103
}
104
}
105
}
106
}
Array.h
Provides methods for creating, manipulating, searching, and sorting arrays.
Common.h
Defines common cross-platform macros, export decorators, and fundamental types.
InvalidOperationException.h
Defines the exception thrown when a method call is invalid for the object's current state.
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::Queue::TryDequeue
bool TryDequeue(T &result)
Removes the object at the beginning of the Queue, and copies it to the result parameter.
Definition
Queue.h:64
DotNetDupe::System::Collections::Generic::Queue::Peek
T Peek() const
Returns the object at the beginning of the Queue without removing it.
Definition
Queue.h:54
DotNetDupe::System::Collections::Generic::Queue::Dequeue
T Dequeue()
Removes and returns the object at the beginning of the Queue.
Definition
Queue.h:42
DotNetDupe::System::Collections::Generic::Queue::Enqueue
void Enqueue(const T &item)
Adds an object to the end of the Queue.
Definition
Queue.h:35
DotNetDupe::System::Collections::Generic::Queue::Queue
Queue()=default
Initializes a new instance of the Queue class that is empty.
DotNetDupe::System::Collections::Generic::Queue::Clear
void Clear()
Removes all objects from the Queue.
Definition
Queue.h:85
DotNetDupe::System::Collections::Generic::Queue::GetCount
int GetCount() const
Gets the number of elements contained in the Queue.
Definition
Queue.h:31
DotNetDupe::System::Collections::Generic::Queue::TryPeek
bool TryPeek(T &result) const
Returns a value that indicates whether there is an object at the beginning of the Queue,...
Definition
Queue.h:76
DotNetDupe::System::Collections::Generic::Queue::ToArray
Array< T > ToArray() const
Copies the Queue elements to a new array.
Definition
Queue.h:98
DotNetDupe::System::Collections::Generic::Queue::Contains
bool Contains(const T &item) const
Determines whether an element is in the Queue.
Definition
Queue.h:92
DotNetDupe::System::InvalidOperationException
The exception that is thrown when a method call is invalid for the object's current state.
Definition
InvalidOperationException.h:16
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
Queue.h
Generated by
1.18.0