RLib  5.7
RLib - an opensource, lightweight and multi-platform framework for cpp programming
System::Collections::Generic::Array< R, disposer, allocator > Class Template Reference

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

Public Types

typedef R Type
 Represents the Type of the current instance More...
 

Public Member Functions

 Array (intptr_t length=RLIB_DEFAULT_CAPACITY)
 
 Array (const Standard::initializer_list< const R > &data)
 Initializes Array<Of R> using initializer-list More...
 
 Array (const R items[], intptr_t length)
 
 Array (const Array &array_from)
 
Arrayoperator= (const Array &obj)
 
Arrayoperator+= (const R &item)
 
RLIB_FORCE_INLINE R * GetType () const
 Gets the Type of the current instance More...
 
void InitStorage (intptr_t n)
 Requests that the Array<Of R> be at least enough to contain n elements More...
 
template<class... P>
intptr_t Add (P &&...args)
 Adds specified item and returns the index of the added. More...
 
template<typename... P>
intptr_t AddRange (const R &item, const P &...args)
 Adds the specified items and returns the index of the first added. More...
 
intptr_t AddRange (const R items[], intptr_t count)
 Adds the specified items and returns the index of the first added. More...
 
template<intptr_t N>
intptr_t AddRange (const R(&items)[N])
 Adds the specified items and returns the index of the first added. More...
 
void Clear ()
 Removes all elements from the Array<Of R> More...
 
R & operator[] (intptr_t index) const
 Gets the element at the specified location More...
 
R & GetValue (intptr_t index) const
 Gets the element at the specified location More...
 
bool Contains (const R &item) const
 确定某元素是否在当前 Array<Of R> 中 More...
 
intptr_t IndexOf (const R &item, typename IComparer< R >::EqualsDelegate equals, intptr_t begin=0) const
 搜索指定的对象,并返回整个 Array<Of R> 中第一个匹配项的索引 More...
 
template<typename IComparer< R >::EqualsDelegate equals = IComparer<R>::Equals>
intptr_t IndexOf (const R &item, intptr_t begin=0) const
 搜索指定的对象,并返回整个 Array<Of R> 中第一个匹配项的索引 More...
 
intptr_t LastIndexOf (const R &item, typename IComparer< R >::EqualsDelegate equals, intptr_t rbegin=0) const
 搜索指定的对象,并返回整个 Array<Of R> 中最后一个匹配项的索引 More...
 
template<typename IComparer< R >::EqualsDelegate equals = IComparer<R>::Equals>
intptr_t LastIndexOf (const R &item, intptr_t rbegin=0) const
 搜索指定的对象,并返回整个 Array<Of R> 中最后一个匹配项的索引 More...
 
void Remove (const R &item, typename IComparer< R >::EqualsDelegate equals)
 移除特定元素的第一个匹配项 More...
 
template<typename IComparer< R >::EqualsDelegate equals = IComparer<R>::Equals>
void Remove (const R &item)
 移除特定元素的第一个匹配项 More...
 
void RemoveAll (const R &item)
 移除特定元素的所有匹配项 More...
 
void RemoveAt (intptr_t index)
 移除指定索引处的元素 More...
 
intptr_t BinarySearch (const R &item, typename IComparer< R >::Delegate comparer, intptr_t begin=0) const
 Searches an entire one-dimensional sorted array for a value using the specified IComparer interface. More...
 
template<typename IComparer< R >::Delegate comparer = IComparer<R>::Compare>
intptr_t BinarySearch (const R &item, intptr_t begin=0) const
 Searches an entire one-dimensional sorted array for a value using the specified IComparer interface. More...
 
void Sort (typename IComparer< R >::Delegate comparer, intptr_t begin=0, intptr_t count=-1)
 Sorts the elements in the entire Array<Of R> using the IComparable generic interface implementation. This method uses the QuickSort algorithm, which on average, is an O(n log n) operation; in the worst case it is an O(n ^ 2) operation More...
 
void Sort (intptr_t begin=0, intptr_t count=-1)
 Sorts the elements in the entire Array<Of R> O(N·log(N)) More...
 
void Unique (typename IComparer< R >::EqualsDelegate equals)
 删除 Array<Of R> 中所有重复的相邻元素 More...
 
template<typename IComparer< R >::EqualsDelegate equals = IComparer<R>::Equals>
void Unique ()
 删除 Array<Of R> 中所有重复的相邻元素 More...
 
void Insert (intptr_t index, const R &item)
 插入新元素到指定位置 More...
 
void Reverse (intptr_t begin=0)
 将指定范围中元素的顺序反转 More...
 
template<class collection_t >
void CopyTo (collection_t &obj) const
 Array<Of R> 完全拷贝至指定集合处 More...
 
void MoveTo (Array &obj)
 Array<Of R> 完全转移至另一 Array<Of R> 处 More...
 
void WriteToEnd (const R *data, intptr_t count)
 将指定数组浅拷贝至当前 Array<Of R> More...
 
R * ToByteArray ()
 获取 Array<Of R> 数据存储区指针 More...
 
intptr_t GetByteArrayLength ()
 获取 Array<Of R> 数据存储区有效数据段大小(in bytes) More...
 
intptr_t GetByteArraySize ()
 获取 Array<Of R> 数据存储区总可读写大小(in bytes) More...
 
RLIB_INLINE intptr_t GetByteArrayItemSize ()
 获取 Array<Of R> 数据存储区每个有效数据元素大小(in bytes) More...
 
R * begin ()
 Returns an iterator to the first element of the container. If the container is empty or nothing, the returned iterator will be equal to end() More...
 
const R * begin () const
 
R * end ()
 Returns an iterator to the element following the last element of the container. This element acts as a placeholder; attempting to access it results in undefined behavior. More...
 
const R * end () const
 

Public Attributes

intptr_t Length
 Gets the total number of elements of the Array<Of R> More...
 
intptr_t MaxLength
 Gets the maximum capacity of the Array<Of R> without reallocating memory More...
 
 RLIB_DECLARE_DYNCREATE
 

Protected Attributes

R * m_pItems
 

Detailed Description

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
class System::Collections::Generic::Array< R, disposer, allocator >

Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays

Member Typedef Documentation

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
typedef R System::Collections::Generic::Array< R, disposer, allocator >::Type

Represents the Type of the current instance

Constructor & Destructor Documentation

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
System::Collections::Generic::Array< R, disposer, allocator >::Array ( const Standard::initializer_list< const R > &  data)
inline

Initializes Array<Of R> using initializer-list

Member Function Documentation

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<class... P>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::Add ( P &&...  args)
inline

Adds specified item and returns the index of the added.

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<typename... P>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::AddRange ( const R &  item,
const P &...  args 
)
inline

Adds the specified items and returns the index of the first added.

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::AddRange ( const R  items[],
intptr_t  count 
)
inline

Adds the specified items and returns the index of the first added.

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<intptr_t N>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::AddRange ( const R(&)  items[N])
inline

Adds the specified items and returns the index of the first added.

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
R* System::Collections::Generic::Array< R, disposer, allocator >::begin ( )
inline

Returns an iterator to the first element of the container. If the container is empty or nothing, the returned iterator will be equal to end()

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::BinarySearch ( const R &  item,
typename IComparer< R >::Delegate  comparer,
intptr_t  begin = 0 
) const
inline

Searches an entire one-dimensional sorted array for a value using the specified IComparer interface.

Warning
undefined behaviour if the array is unsorted or contains duplicate values
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<typename IComparer< R >::Delegate comparer = IComparer<R>::Compare>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::BinarySearch ( const R &  item,
intptr_t  begin = 0 
) const
inline

Searches an entire one-dimensional sorted array for a value using the specified IComparer interface.

Warning
undefined behaviour if the array is unsorted or contains duplicate values
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::Clear ( )
inline

Removes all elements from the Array<Of R>

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
bool System::Collections::Generic::Array< R, disposer, allocator >::Contains ( const R &  item) const
inline

确定某元素是否在当前 Array<Of R> 中

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<class collection_t >
void System::Collections::Generic::Array< R, disposer, allocator >::CopyTo ( collection_t &  obj) const
inline

Array<Of R> 完全拷贝至指定集合处

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
R* System::Collections::Generic::Array< R, disposer, allocator >::end ( )
inline

Returns an iterator to the element following the last element of the container. This element acts as a placeholder; attempting to access it results in undefined behavior.

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
RLIB_INLINE intptr_t System::Collections::Generic::Array< R, disposer, allocator >::GetByteArrayItemSize ( )
inline

获取 Array<Of R> 数据存储区每个有效数据元素大小(in bytes)

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::GetByteArrayLength ( )
inline

获取 Array<Of R> 数据存储区有效数据段大小(in bytes)

Warning
不提供线程安全支持
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::GetByteArraySize ( )
inline

获取 Array<Of R> 数据存储区总可读写大小(in bytes)

Warning
不提供线程安全支持
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
RLIB_FORCE_INLINE R* System::Collections::Generic::Array< R, disposer, allocator >::GetType ( ) const
inline

Gets the Type of the current instance

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
R& System::Collections::Generic::Array< R, disposer, allocator >::GetValue ( intptr_t  index) const
inline

Gets the element at the specified location

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::IndexOf ( const R &  item,
typename IComparer< R >::EqualsDelegate  equals,
intptr_t  begin = 0 
) const
inline

搜索指定的对象,并返回整个 Array<Of R> 中第一个匹配项的索引

Returns
失败返回-1
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<typename IComparer< R >::EqualsDelegate equals = IComparer<R>::Equals>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::IndexOf ( const R &  item,
intptr_t  begin = 0 
) const
inline

搜索指定的对象,并返回整个 Array<Of R> 中第一个匹配项的索引

Returns
失败返回-1
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::InitStorage ( intptr_t  n)
inline

Requests that the Array<Of R> be at least enough to contain n elements

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::Insert ( intptr_t  index,
const R &  item 
)
inline

插入新元素到指定位置

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::LastIndexOf ( const R &  item,
typename IComparer< R >::EqualsDelegate  equals,
intptr_t  rbegin = 0 
) const
inline

搜索指定的对象,并返回整个 Array<Of R> 中最后一个匹配项的索引

Returns
失败返回-1
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<typename IComparer< R >::EqualsDelegate equals = IComparer<R>::Equals>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::LastIndexOf ( const R &  item,
intptr_t  rbegin = 0 
) const
inline

搜索指定的对象,并返回整个 Array<Of R> 中最后一个匹配项的索引

Returns
失败返回-1
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::MoveTo ( Array< R, disposer, allocator > &  obj)
inline

Array<Of R> 完全转移至另一 Array<Of R> 处

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
R& System::Collections::Generic::Array< R, disposer, allocator >::operator[] ( intptr_t  index) const
inline

Gets the element at the specified location

Warning
index is not validated against the number of elements in the array
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::Remove ( const R &  item,
typename IComparer< R >::EqualsDelegate  equals 
)
inline

移除特定元素的第一个匹配项

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<typename IComparer< R >::EqualsDelegate equals = IComparer<R>::Equals>
void System::Collections::Generic::Array< R, disposer, allocator >::Remove ( const R &  item)
inline

移除特定元素的第一个匹配项

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::RemoveAll ( const R &  item)
inline

移除特定元素的所有匹配项

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::RemoveAt ( intptr_t  index)
inline

移除指定索引处的元素

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::Reverse ( intptr_t  begin = 0)
inline

将指定范围中元素的顺序反转

Parameters
order从0开始的顺序位置
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::Sort ( typename IComparer< R >::Delegate  comparer,
intptr_t  begin = 0,
intptr_t  count = -1 
)
inline

Sorts the elements in the entire Array<Of R> using the IComparable generic interface implementation. This method uses the QuickSort algorithm, which on average, is an O(n log n) operation; in the worst case it is an O(n ^ 2) operation

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::Sort ( intptr_t  begin = 0,
intptr_t  count = -1 
)
inline

Sorts the elements in the entire Array<Of R> O(N·log(N))

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
R* System::Collections::Generic::Array< R, disposer, allocator >::ToByteArray ( )
inline

获取 Array<Of R> 数据存储区指针

Warning
不提供线程安全支持
template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::Unique ( typename IComparer< R >::EqualsDelegate  equals)
inline

删除 Array<Of R> 中所有重复的相邻元素

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
template<typename IComparer< R >::EqualsDelegate equals = IComparer<R>::Equals>
void System::Collections::Generic::Array< R, disposer, allocator >::Unique ( )
inline

删除 Array<Of R> 中所有重复的相邻元素

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
void System::Collections::Generic::Array< R, disposer, allocator >::WriteToEnd ( const R *  data,
intptr_t  count 
)
inline

将指定数组浅拷贝至当前 Array<Of R>

Member Data Documentation

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::Length

Gets the total number of elements of the Array<Of R>

template<class R, typename disposer = IDisposable<R>, class allocator = IO::IAllocator>
intptr_t System::Collections::Generic::Array< R, disposer, allocator >::MaxLength

Gets the maximum capacity of the Array<Of R> without reallocating memory


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