System::Collections::Generic::LinkedList< T > Class Template Reference

LinkedList forward declaration. More...

Inherits System::Object, and System::Collections::Generic::ICollection< T >.

Classes

class  iterator_prototype
 

Public Types

typedef iterator_prototype< T, T &, &LinkedListNode< T >::m_next, &LinkedListNode< T >::m_previous > iterator
 
typedef iterator_prototype< T, T &, &LinkedListNode< T >::m_previous, &LinkedListNode< T >::m_next > reverse_iterator
 
typedef iterator_prototype< T, T, &LinkedListNode< T >::m_next, &LinkedListNode< T >::m_previous > const_iterator
 
typedef iterator_prototype< T, T, &LinkedListNode< T >::m_previous, &LinkedListNode< T >::m_next > const_reverse_iterator
 
- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 
typedef System::Details::SharedMembersType shared_members_type
 structure to keep list of shared pointers contained in object. More...
 
- Public Types inherited from System::Collections::Generic::ICollection< T >
typedef T ValueType
 Value type name. More...
 
typedef ICollection< T > ThisType
 Collection type name. More...
 
- Public Types inherited from System::Collections::Generic::IEnumerable< T >
typedef IEnumerator< T > IEnumeratorType
 Enumerator type. More...
 
using ValueType = T
 

Public Member Functions

 LinkedList ()
 Creates empty LinkedList. More...
 
 LinkedList (const SharedPtr< IEnumerable< T >> &collection)
 
SharedPtr< IEnumerator< T > > GetEnumerator () override
 
virtual int get_Count () const override
 
iterator begin () noexcept
 
iterator end () noexcept
 
const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
reverse_iterator rbegin () noexcept
 
reverse_iterator rend () noexcept
 
const_reverse_iterator rbegin () const noexcept
 
const_reverse_iterator rend () const noexcept
 
const_reverse_iterator crbegin () const noexcept
 
const_reverse_iterator crend () const noexcept
 
SharedPtr< LinkedListNode< T > > get_First ()
 
SharedPtr< LinkedListNode< T > > get_Last ()
 
virtual void Add (const T &item) override
 
virtual void Clear () override
 Deletes all elements in list. More...
 
virtual bool Contains (const T &item) const override
 
virtual bool Remove (const T &item) override
 
void Remove (const SharedPtr< LinkedListNode< T >> &item)
 
void RemoveFirst ()
 Removes first node from list. More...
 
void RemoveLast ()
 Removes last node from list. More...
 
void AddAfter (const SharedPtr< LinkedListNode< T >> &node, const SharedPtr< LinkedListNode< T >> &newNode)
 
SharedPtr< LinkedListNode< T > > AddAfter (const SharedPtr< LinkedListNode< T >> &node, const T &item)
 
void AddBefore (const SharedPtr< LinkedListNode< T >> &node, const SharedPtr< LinkedListNode< T >> &newNode)
 
SharedPtr< LinkedListNode< T > > AddBefore (const SharedPtr< LinkedListNode< T >> &node, const T &item)
 
void AddFirst (const SharedPtr< LinkedListNode< T >> &item)
 
SharedPtr< LinkedListNode< T > > AddFirst (const T &item)
 
void AddLast (const SharedPtr< LinkedListNode< T >> &item)
 
SharedPtr< LinkedListNode< T > > AddLast (const T &item)
 
virtual void CopyTo (ArrayPtr< T > arr, int index) override
 
void SetTemplateWeakPtr (unsigned int argument) override
 Makes list treat stored pointers as weak (not implemented). More...
 
- Public Member Functions inherited from System::Object
 Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ~Object ()
 Destroys object. Frees all internal data structures. More...
 
 Object (Object const &x)
 Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int SharedRefRemovedSafe ()
 Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int RemovedSharedRefs (int count)
 Decreases shared reference count by specified value. More...
 
Detail::SmartPtrCounter * WeakRefAdded ()
 Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
void WeakRefRemoved ()
 Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
Detail::SmartPtrCounter * GetCounter ()
 Gets reference counter data structure associated with the object. More...
 
int SharedCount () const
 Gets current value of shared refernce counter. More...
 
void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual int GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual String ToString () const
 Analog of C# Object.ToString() method. Enables converting custom objects to string. More...
 
virtual ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
template<>
bool Equals (float const &objA, float const &objB)
 
template<>
bool Equals (double const &objA, double const &objB)
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 
- Public Member Functions inherited from System::Collections::Generic::ICollection< T >
virtual bool get_IsReadOnly () const
 
ICollectionoperator= (ICollection &&)
 
ICollectionoperator= (const ICollection &)
 
 ICollection ()
 Default constructor. More...
 
 ICollection (const ICollection &)
 Copy constructor. More...
 
 ICollection (ICollection &&)
 Move constructor. More...
 
virtual ~ICollection ()
 Destructor. More...
 
- Public Member Functions inherited from System::Collections::Generic::IEnumerable< T >
LINQ_ElementAt (int index)
 
LINQ_First ()
 
LINQ_FirstOrDefault ()
 
LINQ_FirstOrDefault (std::function< bool(T)> predicate)
 
LINQ_Last ()
 
LINQ_LastOrDefault ()
 
SharedPtr< List< T > > LINQ_ToList ()
 
int LINQ_Count ()
 
System::ArrayPtr< T > LINQ_ToArray ()
 
bool LINQ_All (std::function< bool(T)> predicate)
 
bool LINQ_Any ()
 
bool LINQ_Any (std::function< bool(T)> predicate)
 
SharedPtr< IEnumerable< T > > LINQ_Where (std::function< bool(T)> predicate)
 
bool LINQ_Contains (T value)
 
template<typename ResultType >
SharedPtr< IEnumerable< ResultType > > LINQ_Cast ()
 
template<typename ResultType >
SharedPtr< IEnumerable< ResultType > > LINQ_OfType ()
 
template<typename ResultType >
SharedPtr< IEnumerable< ResultType > > LINQ_Select (const Func< T, ResultType > &selector)
 
EnumeratorBasedIterator< T, IEnumerator< T > > begin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > end () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cbegin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cend () noexcept
 
template<typename Result >
SharedPtr< IEnumerable< Result > > LINQ_Cast ()
 
template<typename Result >
SharedPtr< IEnumerable< Result > > LINQ_OfType ()
 
template<typename Result >
SharedPtr< IEnumerable< Result > > LINQ_Select (const Func< Source, Result > &selector)
 

Protected Member Functions

 ~LinkedList () override
 Destructor. More...
 
- Protected Member Functions inherited from System::Collections::Generic::IEnumerable< T >
 ~IEnumerable () override
 Destructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from System::Object
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 Reference-compares value type object with nullptr. More...
 
template<typename T1 , typename T2 >
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares reference type objects in C# style. More...
 
template<typename T1 , typename T2 >
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares value type objects in C# style. More...
 
static const TypeInfoType ()
 Impleemnts C# typeof(System.Object) construct. More...
 

Detailed Description

template<typename T>
class System::Collections::Generic::LinkedList< T >

LinkedList forward declaration.

Linked list container. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

Template Parameters
TContained value type.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef iterator_prototype<T, T, &LinkedListNode<T>::m_next, &LinkedListNode<T>::m_previous> System::Collections::Generic::LinkedList< T >::const_iterator

◆ const_reverse_iterator

template<typename T >
typedef iterator_prototype<T, T, &LinkedListNode<T>::m_previous, &LinkedListNode<T>::m_next> System::Collections::Generic::LinkedList< T >::const_reverse_iterator

◆ iterator

template<typename T >
typedef iterator_prototype<T, T&, &LinkedListNode<T>::m_next, &LinkedListNode<T>::m_previous> System::Collections::Generic::LinkedList< T >::iterator

◆ reverse_iterator

template<typename T >
typedef iterator_prototype<T, T&, &LinkedListNode<T>::m_previous, &LinkedListNode<T>::m_next> System::Collections::Generic::LinkedList< T >::reverse_iterator

Constructor & Destructor Documentation

◆ LinkedList() [1/2]

template<typename T >
System::Collections::Generic::LinkedList< T >::LinkedList ( )
inline

Creates empty LinkedList.

◆ LinkedList() [2/2]

template<typename T >
System::Collections::Generic::LinkedList< T >::LinkedList ( const SharedPtr< IEnumerable< T >> &  collection)
inline

Copy constructor.

Parameters
collectionCollection to copy data from.

◆ ~LinkedList()

template<typename T >
System::Collections::Generic::LinkedList< T >::~LinkedList ( )
inlineoverrideprotected

Destructor.

Member Function Documentation

◆ Add()

template<typename T >
virtual void System::Collections::Generic::LinkedList< T >::Add ( const T &  item)
inlineoverridevirtual

Adds item into LinkedList end.

Parameters
itemItem to add into list.

Implements System::Collections::Generic::ICollection< T >.

◆ AddAfter() [1/2]

template<typename T >
void System::Collections::Generic::LinkedList< T >::AddAfter ( const SharedPtr< LinkedListNode< T >> &  node,
const SharedPtr< LinkedListNode< T >> &  newNode 
)
inline

Adds node after another one (not implemented).

Parameters
nodenode after which to insert
newNodenew node to add

◆ AddAfter() [2/2]

template<typename T >
SharedPtr<LinkedListNode<T> > System::Collections::Generic::LinkedList< T >::AddAfter ( const SharedPtr< LinkedListNode< T >> &  node,
const T &  item 
)
inline

Adds item after one (not implemented).

Parameters
nodenode after which to insert
itemItem to add

◆ AddBefore() [1/2]

template<typename T >
void System::Collections::Generic::LinkedList< T >::AddBefore ( const SharedPtr< LinkedListNode< T >> &  node,
const SharedPtr< LinkedListNode< T >> &  newNode 
)
inline

Adds node before another one (not implemented).

Parameters
nodenode before which to insert
newNodenew node to add

◆ AddBefore() [2/2]

template<typename T >
SharedPtr<LinkedListNode<T> > System::Collections::Generic::LinkedList< T >::AddBefore ( const SharedPtr< LinkedListNode< T >> &  node,
const T &  item 
)
inline

Adds item before one (not implemented).

Parameters
nodenode before which to insert
itemItem to add

◆ AddFirst() [1/2]

template<typename T >
void System::Collections::Generic::LinkedList< T >::AddFirst ( const SharedPtr< LinkedListNode< T >> &  item)
inline

Adds node to the beginning of list.

Parameters
itemItem to add.

◆ AddFirst() [2/2]

template<typename T >
SharedPtr<LinkedListNode<T> > System::Collections::Generic::LinkedList< T >::AddFirst ( const T &  item)
inline

Adds item to the beginning of list.

Parameters
itemItem to add.

◆ AddLast() [1/2]

template<typename T >
void System::Collections::Generic::LinkedList< T >::AddLast ( const SharedPtr< LinkedListNode< T >> &  item)
inline

Adds node to the beginning of list.

Parameters
itemItem to add.

◆ AddLast() [2/2]

template<typename T >
SharedPtr<LinkedListNode<T> > System::Collections::Generic::LinkedList< T >::AddLast ( const T &  item)
inline

Adds item to the beginning of list.

Parameters
itemItem to add.

◆ begin() [1/2]

template<typename T >
iterator System::Collections::Generic::LinkedList< T >::begin ( )
inlinenoexcept

Gets iterator to the first element of collection.

Returns
An iterator pointing to the first element in the linked list.

◆ begin() [2/2]

template<typename T >
const_iterator System::Collections::Generic::LinkedList< T >::begin ( ) const
inlinenoexcept

Gets iterator to the first element of the const-qualified collection.

Returns
An iterator pointing to the first element in the const-qualified instance of the linked list.

◆ cbegin()

template<typename T >
const_iterator System::Collections::Generic::LinkedList< T >::cbegin ( ) const
inlinenoexcept

Gets iterator to the first const-qualified element of collection.

Returns
An iterator pointing to the first const-qualified element in the linked list.

◆ cend()

template<typename T >
const_iterator System::Collections::Generic::LinkedList< T >::cend ( ) const
inlinenoexcept

Gets iterator for a non-existent const-qualified element behind the end of the collection.

Returns
An iterator pointing to the theoretical const-qualified element placed after the end element in the linked list.

◆ Clear()

template<typename T >
virtual void System::Collections::Generic::LinkedList< T >::Clear ( )
inlineoverridevirtual

Deletes all elements in list.

Implements System::Collections::Generic::ICollection< T >.

◆ Contains()

template<typename T >
virtual bool System::Collections::Generic::LinkedList< T >::Contains ( const T &  item) const
inlineoverridevirtual

Checks if element is present in list.

Parameters
itemItem to look for.
Returns
True if item is found, false otherwise.

Implements System::Collections::Generic::ICollection< T >.

◆ CopyTo()

template<typename T >
virtual void System::Collections::Generic::LinkedList< T >::CopyTo ( ArrayPtr< T >  arr,
int  index 
)
inlineoverridevirtual

Copies container data into existing array elements (not implemented).

Parameters
arrthe destination
indexzero-based index in array at which copying begins.

Implements System::Collections::Generic::ICollection< T >.

◆ crbegin()

template<typename T >
const_reverse_iterator System::Collections::Generic::LinkedList< T >::crbegin ( ) const
inlinenoexcept

Gets a reverse iterator to the last const-qualified element of collection (first in reverse).

Returns
A reverse iterator pointing to the last const-qualified element in the linked list (first in reverse).

◆ crend()

template<typename T >
const_reverse_iterator System::Collections::Generic::LinkedList< T >::crend ( ) const
inlinenoexcept

Gets a reverse iterator for a non-existent const-qualified element before the start of the collection.

Returns
A reverse iterator pointing to the theoretical const-qualified element preceeding the first element in the linked list (last in reverse).

◆ end() [1/2]

template<typename T >
iterator System::Collections::Generic::LinkedList< T >::end ( )
inlinenoexcept

Gets iterator for a non-existent element behind the end of the collection.

Returns
An iterator pointing to the theoretical element placed after the end element in the linked list.

◆ end() [2/2]

template<typename T >
const_iterator System::Collections::Generic::LinkedList< T >::end ( ) const
inlinenoexcept

Gets iterator for a non-existent element behind the end of the const-qualified collection.

Returns
An iterator pointing to the theoretical element placed after the end element in the const-qualified instance of the linked list.

◆ get_Count()

template<typename T >
virtual int System::Collections::Generic::LinkedList< T >::get_Count ( ) const
inlineoverridevirtual

Gets number of elements in list.

Returns
Actual number of elements in list.

Implements System::Collections::Generic::ICollection< T >.

◆ get_First()

template<typename T >
SharedPtr<LinkedListNode<T> > System::Collections::Generic::LinkedList< T >::get_First ( )
inline

Gets pointer to the first element in the list.

Returns
First element in the list.

◆ get_Last()

template<typename T >
SharedPtr<LinkedListNode<T> > System::Collections::Generic::LinkedList< T >::get_Last ( )
inline

Gets pointer to the last element in the list.

Returns
Last element in the list.

◆ GetEnumerator()

template<typename T >
SharedPtr<IEnumerator<T> > System::Collections::Generic::LinkedList< T >::GetEnumerator ( )
inlineoverridevirtual

Gets enumerator to iterate through current LinkedList.

Returns
Newly created enumerator object.

Implements System::Collections::Generic::IEnumerable< T >.

◆ rbegin() [1/2]

template<typename T >
reverse_iterator System::Collections::Generic::LinkedList< T >::rbegin ( )
inlinenoexcept

Gets a reverse iterator to the last element of collection (first in reverse).

Returns
A reverse iterator pointing to the last element in the linked list (first in reverse).

◆ rbegin() [2/2]

template<typename T >
const_reverse_iterator System::Collections::Generic::LinkedList< T >::rbegin ( ) const
inlinenoexcept

Gets a reverse iterator to the last element of the const-qualified collection (first in reverse).

Returns
A reverse iterator pointing to the last element in the const-qualified linked list (first in reverse).

◆ Remove() [1/2]

template<typename T >
virtual bool System::Collections::Generic::LinkedList< T >::Remove ( const T &  item)
inlineoverridevirtual

Removes first occurance of the specified item from list.

Parameters
itemItem to remove.
Returns
True if item was found and removed, false otherwise.

Implements System::Collections::Generic::ICollection< T >.

◆ Remove() [2/2]

template<typename T >
void System::Collections::Generic::LinkedList< T >::Remove ( const SharedPtr< LinkedListNode< T >> &  item)
inline

Removes node from list

Parameters
itemItem to remove.

◆ RemoveFirst()

template<typename T >
void System::Collections::Generic::LinkedList< T >::RemoveFirst ( )
inline

Removes first node from list.

◆ RemoveLast()

template<typename T >
void System::Collections::Generic::LinkedList< T >::RemoveLast ( )
inline

Removes last node from list.

◆ rend() [1/2]

template<typename T >
reverse_iterator System::Collections::Generic::LinkedList< T >::rend ( )
inlinenoexcept

Gets a reverse iterator for a non-existent element before the start of the collection.

Returns
A reverse iterator pointing to the theoretical element preceeding the first element in the linked list (last in reverse).

◆ rend() [2/2]

template<typename T >
const_reverse_iterator System::Collections::Generic::LinkedList< T >::rend ( ) const
inlinenoexcept

Gets a reverse iterator for a non-existent element before the start of the const-qualified collection.

Returns
A reverse iterator pointing to the theoretical element preceeding the first element in the const-qualified linked list (last in reverse).

◆ SetTemplateWeakPtr()

template<typename T >
void System::Collections::Generic::LinkedList< T >::SetTemplateWeakPtr ( unsigned int  argument)
inlineoverridevirtual

Makes list treat stored pointers as weak (not implemented).

Reimplemented from System::Object.