DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::Array< T > Class Template Reference

Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime. More...

#include <Array.h>

Inheritance diagram for DotNetDupe::System::Array< T >:

Public Member Functions

 Array ()=default
 Initializes an empty Array instance.
 Array (Array &&other) noexcept
 Move constructor.
 Array (const Array &other)
 Copy constructor. Performs a deep copy of elements.
 Array (const std::initializer_list< T > &vItems)
 Initializes an Array from an initializer list of elements.
 Array (const T *pData, int iLength)
 Initializes an Array by copying elements from a raw pointer buffer.
 Array (int iLength)
 Initializes an Array of the specified length with default-constructed elements.
 ~Array () override
 Destroys array elements and releases allocated storage.
T * begin ()
 Returns an iterator to the first element of the array.
const T * begin () const
 Returns a const iterator to the first element of the array.
void Clear ()
 Sets a range of elements in the Array to the default value of each element type.
void CopyTo (Array< T > &arrTarget, int iIndex)
 Copies all elements of the current Array to the specified destination Array starting at the specified destination index.
T * end ()
 Returns an iterator to the element following the last element of the array.
const T * end () const
 Returns a const iterator to the element following the last element of the array.
bool Exists (const Predicate< T > &fnPredicate) const
 Determines whether the specified array contains elements that match the conditions defined by the specified predicate.
Find (const Predicate< T > &fnPredicate) const
 Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence.
Array< T > FindAll (const Predicate< T > &fnPredicate) const
 Retrieves all the elements that match the conditions defined by the specified predicate.
int FindIndex (const Predicate< T > &fnPredicate) const
 Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence.
FindLast (const Predicate< T > &fnPredicate) const
 Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence.
int FindLastIndex (const Predicate< T > &fnPredicate) const
 Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence.
void ForEach (const Action< T > &fnAction)
 Performs the specified action on each element of the specified array.
T * GetData ()
 Gets a pointer to the contiguous internal element buffer.
const T * GetData () const
 Gets a const pointer to the contiguous internal element buffer.
int GetLength () const
 Gets the total number of elements in all dimensions of the Array.
int IndexOf (const T &value) const
 Searches for the specified object and returns the index of its first occurrence.
bool IsNull () const
 Checks whether the array has zero length.
int LastIndexOf (const T &value) const
 Searches for the specified object and returns the index of the last occurrence.
Arrayoperator= (Array &&other) noexcept
 Move assignment operator.
Arrayoperator= (const Array &other)
 Copy assignment operator.
T & operator[] (int iIndex)
 Accesses the element at the specified index.
const T & operator[] (int iIndex) const
 Accesses the const element at the specified index.
void Reverse ()
 Reverses the sequence of the elements in the entire Array.
void Sort ()
 Sorts the elements in an entire Array using the default comparison.
bool TrueForAll (const Predicate< T > &fnPredicate) const
 Determines whether every element in the array matches the conditions defined by the specified predicate.
Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Static Public Member Functions

static void Copy (Array< T > &arrSource, Array< T > &arrDestination, int iLength)
 Copies a range of elements from an Array starting at the first element and pastes them to another Array starting at the first element.
Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Detailed Description

template<class T>
class DotNetDupe::System::Array< T >

Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.

Template Parameters
TThe element type contained in the array.
Note
Conforms to ECMA-335 Partition IV Section 5.20 (System.Array).

Definition at line 29 of file Array.h.

Constructor & Destructor Documentation

◆ Array() [1/6]

template<class T>
DotNetDupe::System::Array< T >::Array ( )
default

Initializes an empty Array instance.

Referenced by Array(), Array(), Copy(), CopyTo(), FindAll(), operator=(), and operator=().

◆ Array() [2/6]

template<class T>
DotNetDupe::System::Array< T >::Array ( int iLength)
inline

Initializes an Array of the specified length with default-constructed elements.

Parameters
iLengthThe number of elements in the array.

Definition at line 64 of file Array.h.

◆ Array() [3/6]

template<class T>
DotNetDupe::System::Array< T >::Array ( const T * pData,
int iLength )
inline

Initializes an Array by copying elements from a raw pointer buffer.

Parameters
pDataPointer to the source elements buffer.
iLengthThe number of elements to copy.

Definition at line 74 of file Array.h.

◆ Array() [4/6]

template<class T>
DotNetDupe::System::Array< T >::Array ( const std::initializer_list< T > & vItems)
inline

Initializes an Array from an initializer list of elements.

Parameters
vItemsInitializer list containing array elements.

Definition at line 89 of file Array.h.

◆ Array() [5/6]

template<class T>
DotNetDupe::System::Array< T >::Array ( const Array< T > & other)
inline

Copy constructor. Performs a deep copy of elements.

Definition at line 98 of file Array.h.

References Array().

◆ Array() [6/6]

template<class T>
DotNetDupe::System::Array< T >::Array ( Array< T > && other)
inlinenoexcept

Move constructor.

Definition at line 118 of file Array.h.

References Array().

◆ ~Array()

template<class T>
DotNetDupe::System::Array< T >::~Array ( )
inlineoverride

Destroys array elements and releases allocated storage.

Definition at line 136 of file Array.h.

Member Function Documentation

◆ begin() [1/2]

template<class T>
T * DotNetDupe::System::Array< T >::begin ( )
inline

Returns an iterator to the first element of the array.

Definition at line 153 of file Array.h.

◆ begin() [2/2]

template<class T>
const T * DotNetDupe::System::Array< T >::begin ( ) const
inline

Returns a const iterator to the first element of the array.

Definition at line 159 of file Array.h.

◆ Clear()

template<class T>
void DotNetDupe::System::Array< T >::Clear ( )
inline

Sets a range of elements in the Array to the default value of each element type.

Definition at line 217 of file Array.h.

◆ Copy()

template<class T>
void DotNetDupe::System::Array< T >::Copy ( Array< T > & arrSource,
Array< T > & arrDestination,
int iLength )
inlinestatic

Copies a range of elements from an Array starting at the first element and pastes them to another Array starting at the first element.

Guard: Validate length boundary against source and destination capacities.

Copy elements across array bounds.

Definition at line 320 of file Array.h.

References DotNetDupe::System::ArgumentException::ArgumentException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), Array(), and GetLength().

◆ CopyTo()

template<class T>
void DotNetDupe::System::Array< T >::CopyTo ( Array< T > & arrTarget,
int iIndex )
inline

Copies all elements of the current Array to the specified destination Array starting at the specified destination index.

Guard: Validate target index boundary.

Copy elements sequentially into target buffer.

Definition at line 308 of file Array.h.

References DotNetDupe::System::ArgumentException::ArgumentException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), Array(), and GetLength().

◆ end() [1/2]

template<class T>
T * DotNetDupe::System::Array< T >::end ( )
inline

Returns an iterator to the element following the last element of the array.

Definition at line 156 of file Array.h.

◆ end() [2/2]

template<class T>
const T * DotNetDupe::System::Array< T >::end ( ) const
inline

Returns a const iterator to the element following the last element of the array.

Definition at line 162 of file Array.h.

◆ Exists()

template<class T>
bool DotNetDupe::System::Array< T >::Exists ( const Predicate< T > & fnPredicate) const
inline

Determines whether the specified array contains elements that match the conditions defined by the specified predicate.

Definition at line 230 of file Array.h.

◆ Find()

template<class T>
T DotNetDupe::System::Array< T >::Find ( const Predicate< T > & fnPredicate) const
inline

Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence.

Definition at line 238 of file Array.h.

◆ FindAll()

template<class T>
Array< T > DotNetDupe::System::Array< T >::FindAll ( const Predicate< T > & fnPredicate) const
inline

Retrieves all the elements that match the conditions defined by the specified predicate.

Definition at line 246 of file Array.h.

References Array().

◆ FindIndex()

template<class T>
int DotNetDupe::System::Array< T >::FindIndex ( const Predicate< T > & fnPredicate) const
inline

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence.

Definition at line 262 of file Array.h.

◆ FindLast()

template<class T>
T DotNetDupe::System::Array< T >::FindLast ( const Predicate< T > & fnPredicate) const
inline

Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence.

Definition at line 270 of file Array.h.

◆ FindLastIndex()

template<class T>
int DotNetDupe::System::Array< T >::FindLastIndex ( const Predicate< T > & fnPredicate) const
inline

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence.

Definition at line 278 of file Array.h.

◆ ForEach()

template<class T>
void DotNetDupe::System::Array< T >::ForEach ( const Action< T > & fnAction)
inline

Performs the specified action on each element of the specified array.

Definition at line 286 of file Array.h.

◆ GetData() [1/2]

template<class T>
T * DotNetDupe::System::Array< T >::GetData ( )
inline

Gets a pointer to the contiguous internal element buffer.

Returns
A pointer to the element array.

Definition at line 146 of file Array.h.

Referenced by DotNetDupe::System::IO::MemoryStream::MemoryStream(), DotNetDupe::System::IO::MemoryStream::MemoryStream(), DotNetDupe::System::IO::File::AppendAllLines(), DotNetDupe::System::IO::File::AppendAllText(), DotNetDupe::System::Buffer::BlockCopy(), DotNetDupe::System::Security::Cryptography::ComputeHmacDigests(), DotNetDupe::System::IdentityModel::Tokens::Jwt::ComputeJwtSignature(), DotNetDupe::System::Net::Http::HttpContent::CopyTo(), DotNetDupe::System::IdentityModel::Tokens::Jwt::DecodeBase64UrlToDict(), DotNetDupe::System::IdentityModel::Tokens::Jwt::EncodeDictToBase64Url(), DotNetDupe::System::Buffer::GetByte(), DotNetDupe::System::BitConverter::GetBytes(), DotNetDupe::System::BitConverter::GetBytes(), DotNetDupe::System::BitConverter::GetBytes(), DotNetDupe::System::BitConverter::GetBytes(), DotNetDupe::System::BitConverter::GetBytes(), DotNetDupe::System::BitConverter::GetBytes(), DotNetDupe::System::BitConverter::GetBytes(), DotNetDupe::System::BitConverter::GetBytes(), DotNetDupe::System::Text::UTF8Encoding::GetString(), DotNetDupe::System::Security::Cryptography::PrepareHmacPads(), DotNetDupe::System::IO::BinaryReader::Read(), DotNetDupe::System::Net::Http::ByteArrayContent::ReadAsByteArray(), DotNetDupe::System::Net::Http::StreamContent::ReadAsByteArray(), DotNetDupe::System::Net::Http::StreamContent::ReadAsString(), DotNetDupe::System::IO::BinaryReader::ReadString(), DotNetDupe::System::Net::WebSockets::WebSocket::SendBytes(), DotNetDupe::System::Buffer::SetByte(), DotNetDupe::System::String::Split(), DotNetDupe::System::IO::MemoryStream::ToArray(), DotNetDupe::System::Convert::ToBase64String(), DotNetDupe::System::BitConverter::ToDouble(), DotNetDupe::System::BitConverter::ToInt16(), DotNetDupe::System::BitConverter::ToInt32(), DotNetDupe::System::BitConverter::ToInt64(), DotNetDupe::System::BitConverter::ToSingle(), DotNetDupe::System::BitConverter::ToUInt16(), DotNetDupe::System::BitConverter::ToUInt32(), DotNetDupe::System::BitConverter::ToUInt64(), DotNetDupe::System::IdentityModel::Tokens::Jwt::JWTToken::Verify(), DotNetDupe::System::IO::BinaryWriter::Write(), DotNetDupe::System::IO::File::WriteAllLines(), and DotNetDupe::System::IO::File::WriteAllText().

◆ GetData() [2/2]

template<class T>
const T * DotNetDupe::System::Array< T >::GetData ( ) const
inline

Gets a const pointer to the contiguous internal element buffer.

Returns
A const pointer to the element array.

Definition at line 150 of file Array.h.

◆ GetLength()

template<class T>
int DotNetDupe::System::Array< T >::GetLength ( ) const
inline

Gets the total number of elements in all dimensions of the Array.

Returns
The total number of elements.

Definition at line 142 of file Array.h.

Referenced by DotNetDupe::System::Net::Http::ByteArrayContent::ByteArrayContent(), DotNetDupe::System::Guid::Guid(), DotNetDupe::System::IO::MemoryStream::MemoryStream(), DotNetDupe::System::IO::MemoryStream::MemoryStream(), DotNetDupe::System::Collections::Generic::List< T >::AddRange(), DotNetDupe::System::IO::File::AppendAllLines(), DotNetDupe::System::IO::File::AppendAllText(), DotNetDupe::System::Buffer::BlockCopy(), DotNetDupe::System::Buffer::ByteLength(), DotNetDupe::System::Security::Cryptography::ComputeHmacDigests(), Copy(), CopyTo(), DotNetDupe::System::Net::Http::HttpContent::CopyTo(), DotNetDupe::System::IdentityModel::Tokens::Jwt::DecodeBase64UrlToDict(), DotNetDupe::System::Collections::Generic::HashSet< T >::ExceptWith(), DotNetDupe::System::Diagnostics::Process::GetProcessesByName(), DotNetDupe::System::Text::UTF8Encoding::GetString(), DotNetDupe::System::Collections::Generic::HashSet< T >::IntersectWith(), DotNetDupe::System::IdentityModel::Tokens::Jwt::JWTToken::Parse(), DotNetDupe::System::Security::Cryptography::PrepareHmacPads(), DotNetDupe::System::IO::BinaryReader::Read(), DotNetDupe::System::Net::Http::StringContent::ReadAsByteArray(), DotNetDupe::System::Net::Http::StreamContent::ReadAsString(), DotNetDupe::System::Net::WebSockets::WebSocket::SendBytes(), DotNetDupe::System::String::Split(), DotNetDupe::System::String::Split(), DotNetDupe::System::Convert::ToBase64String(), DotNetDupe::System::BitConverter::ToBoolean(), DotNetDupe::System::BitConverter::ToChar(), DotNetDupe::System::BitConverter::ToDouble(), DotNetDupe::System::BitConverter::ToInt16(), DotNetDupe::System::BitConverter::ToInt32(), DotNetDupe::System::BitConverter::ToInt64(), DotNetDupe::System::BitConverter::ToSingle(), DotNetDupe::System::BitConverter::ToString(), DotNetDupe::System::BitConverter::ToString(), DotNetDupe::System::BitConverter::ToString(), DotNetDupe::System::BitConverter::ToUInt16(), DotNetDupe::System::BitConverter::ToUInt32(), DotNetDupe::System::BitConverter::ToUInt64(), DotNetDupe::System::Collections::Generic::HashSet< T >::UnionWith(), DotNetDupe::System::IO::BinaryWriter::Write(), DotNetDupe::System::IO::BinaryWriter::Write(), DotNetDupe::System::IO::File::WriteAllLines(), and DotNetDupe::System::IO::File::WriteAllText().

◆ IndexOf()

template<class T>
int DotNetDupe::System::Array< T >::IndexOf ( const T & value) const
inline

Searches for the specified object and returns the index of its first occurrence.

Parameters
valueThe object to locate in the Array.
Returns
The zero-based index of the first occurrence of value, if found; otherwise, -1.

Definition at line 177 of file Array.h.

◆ IsNull()

template<class T>
bool DotNetDupe::System::Array< T >::IsNull ( ) const
inline

Checks whether the array has zero length.

Returns
true if length is 0; otherwise, false.

Definition at line 166 of file Array.h.

Referenced by DotNetDupe::System::Buffer::BlockCopy(), and DotNetDupe::System::Buffer::ByteLength().

◆ LastIndexOf()

template<class T>
int DotNetDupe::System::Array< T >::LastIndexOf ( const T & value) const
inline

Searches for the specified object and returns the index of the last occurrence.

Parameters
valueThe object to locate in the Array.
Returns
The zero-based index of the last occurrence of value, if found; otherwise, -1.

Definition at line 187 of file Array.h.

◆ operator=() [1/2]

template<class T>
Array & DotNetDupe::System::Array< T >::operator= ( Array< T > && other)
inlinenoexcept

Move assignment operator.

Definition at line 124 of file Array.h.

References Array().

◆ operator=() [2/2]

template<class T>
Array & DotNetDupe::System::Array< T >::operator= ( const Array< T > & other)
inline

Copy assignment operator.

Definition at line 106 of file Array.h.

References Array().

◆ operator[]() [1/2]

template<class T>
T & DotNetDupe::System::Array< T >::operator[] ( int iIndex)
inline

Accesses the element at the specified index.

Definition at line 169 of file Array.h.

◆ operator[]() [2/2]

template<class T>
const T & DotNetDupe::System::Array< T >::operator[] ( int iIndex) const
inline

Accesses the const element at the specified index.

Definition at line 172 of file Array.h.

◆ Reverse()

template<class T>
void DotNetDupe::System::Array< T >::Reverse ( )
inline

Reverses the sequence of the elements in the entire Array.

Definition at line 206 of file Array.h.

◆ Sort()

template<class T>
void DotNetDupe::System::Array< T >::Sort ( )
inline

Sorts the elements in an entire Array using the default comparison.

Definition at line 195 of file Array.h.

◆ TrueForAll()

template<class T>
bool DotNetDupe::System::Array< T >::TrueForAll ( const Predicate< T > & fnPredicate) const
inline

Determines whether every element in the array matches the conditions defined by the specified predicate.

Definition at line 293 of file Array.h.


The documentation for this class was generated from the following file: