LinkedList
Contents
[
Hide
]LinkedList class
LinkedList forward declaration.
template<typename T>class LinkedList : public virtual System::Object,
public System::Collections::Generic::ICollection<T>,
private System::Collections::Invalidatable
Template parameters
Parameter | Description |
---|---|
T | Contained value type. |
Methods
Method | Description |
---|---|
void Add(const T&) override | Adds element to the end of the list. |
SharedPtr<LinkedListNode<T>> AddAfter(const SharedPtr<LinkedListNode<T>>&, const T&) | Adds element after node of the list. |
void AddAfter(const SharedPtr<LinkedListNode<T>>&, const SharedPtr<LinkedListNode<T>>&) | Adds newNode after node of the list. |
SharedPtr<LinkedListNode<T>> AddBefore(const SharedPtr<LinkedListNode<T>>&, const T&) | Adds element before node of the list. |
void AddBefore(const SharedPtr<LinkedListNode<T>>&, const SharedPtr<LinkedListNode<T>>&) | Adds newNode before node of the list. |
SharedPtr<LinkedListNode<T>> AddFirst(const T&) | Adds element to the beginning of the list. |
void AddFirst(const SharedPtr<LinkedListNode<T>>&) | Adds newNode to the beginning of the list. |
SharedPtr<LinkedListNode<T>> AddLast(const T&) | Adds element to the end of the list. |
void AddLast(const SharedPtr<LinkedListNode<T>>&) | Adds newNode to the end of the list. |
iterator begin() | Gets iterator to the first element of collection. |
const_iterator begin() const | Gets iterator to the first element of the const-qualified collection. |
const_iterator cbegin() const | Gets iterator to the first const-qualified element of collection. |
const_iterator cend() const | Gets iterator for a non-existent const-qualified element behind the end of the collection. |
void Clear() override | Deletes all elements in list. |
bool Contains(const T&) const override | Checks if element is present in list. |
void CopyTo(ArrayPtr<T>, int) override | Copies container data into existing array elements. |
const_reverse_iterator crbegin() const | Gets a reverse iterator to the last const-qualified element of collection (first in reverse). |
const_reverse_iterator crend() const | Gets a reverse iterator for a non-existent const-qualified element before the start of the collection. |
iterator end() | Gets iterator for a non-existent element behind the end of the collection. |
const_iterator end() const | Gets iterator for a non-existent element behind the end of the const-qualified collection. |
virtual bool Equals(ptr) | Compares objects using C# Object.Equals semantics. |
static std::enable_if<IsSmartPtr<T1>::value&&IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&) | Compares reference type objects in C# style. |
static std::enable_if<!IsSmartPtr<T1>::value&&!IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&) | Compares value type objects in C# style. |
static bool Equals(float const&, float const&) | Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN. |
static bool Equals(double const&, double const&) | Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN. |
virtual bool FastCast(const Details::FastRttiBase&, void **) const | For internal purposes only. |
SharedPtr<LinkedListNode<T>> Find(const T&) const | Performs forward direction find of an element in the list. |
SharedPtr<LinkedListNode<T>> FindLast(const T&) const | Performs reverse direction find of an element in the list. |
int get_Count() const override | Gets number of elements in list. |
SharedPtr<LinkedListNode<T>> get_First() const | Gets pointer to the first element in the list. |
virtual bool get_IsReadOnly() const | Checks if collection is read only. |
SharedPtr<LinkedListNode<T>> get_Last() const | Gets pointer to the last element in the list. |
SharedPtr<Object> get_SyncRoot() const | Gets the object the collection is being synchronized through. |
Detail::SmartPtrCounter * GetCounter() | Gets reference counter data structure associated with the object. |
SharedPtr<IEnumerator<T>> GetEnumerator() override | Gets enumerator to iterate through current LinkedList. |
virtual int32_t GetHashCode() const | Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. |
virtual const TypeInfo& GetType() const | Gets actual type of object. Analog of C# System.Object.GetType() call. |
ICollection() | Default constructor. |
ICollection(const ICollection&) | Copy constructor. |
ICollection(ICollection&&) | Move constructor. |
virtual bool Is(const TypeInfo&) const | Check if object represents an instance of type described by targetType. Analog of C# ‘is’ operator. |
LinkedList() | Creates empty LinkedList. |
LinkedList(const SharedPtr<IEnumerable<T>>&) | Copy constructor. |
bool LINQ_All(std::function<bool(T)>) | Determines whether all elements of a sequence satisfy a condition. |
bool LINQ_Any() | Determines whether a sequence contains any elements. |
bool LINQ_Any(std::function<bool(T)>) | Determines whether any element of a sequence exists or satisfies a condition. |
SharedPtr<IEnumerable<ResultType>> LINQ_Cast() | Casts the elements to the specified type. |
SharedPtr<IEnumerable<Result>> LINQ_Cast() | |
SharedPtr<IEnumerable<T>> LINQ_Concat(SharedPtr<IEnumerable<T>>) | Concatenates two sequences. |
bool LINQ_Contains(T) | Determines if a sequence contains a specified value. |
int LINQ_Count() | Returns the number of elements in the sequence (calculated via direct counting). |
int LINQ_Count(const Func<T, bool>&) | Returns the number of elements in the sequence that satisfy the specified condition. |
T LINQ_ElementAt(int) | Returns the element at a specified index in a sequence. |
T LINQ_First() | Returns the first element of a sequence. |
T LINQ_First(const Func<T, bool>&) | Returns the first element of a sequence that satisfy the specified condition. |
T LINQ_FirstOrDefault() | Returns the first element of a sequence, or a default value if the sequence is empty. |
T LINQ_FirstOrDefault(std::function<bool(T)>) | Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. |
System::SharedPtr<IEnumerable<System::SharedPtr<System::Linq::IGrouping<Key, T>>>> LINQ_GroupBy(System::Func<T, Key>) | Groups the elements of a sequence. |
SharedPtr<IEnumerable<SharedPtr<System::Linq::IGrouping<Key, Source>>>> LINQ_GroupBy(System::Func<Source, Key>) | |
T LINQ_Last() | Returns the last element of a sequence. |
T LINQ_LastOrDefault() | Returns the last element of a sequence, or a default value if the sequence is empty. |
SharedPtr<IEnumerable<ResultType>> LINQ_OfType() | Filters the elements of the sequence based on the specified type. |
SharedPtr<IEnumerable<Result>> LINQ_OfType() | |
SharedPtr<IEnumerable<T>> LINQ_OrderBy(const Func<T, Key>&) | Sorts the elements of a sequence in ascending order according to the key values selected by keySelector. |
SharedPtr<IEnumerable<Source>> LINQ_OrderBy(const Func<Source, Key>&) | |
SharedPtr<IEnumerable<T>> LINQ_OrderByDescending(const Func<T, Key>&) | Sorts the elements of a sequence in descending order according to the key values selected by keySelector. |
SharedPtr<IEnumerable<Source>> LINQ_OrderByDescending(const Func<Source, Key>&) | |
SharedPtr<IEnumerable<ResultType>> LINQ_Select(const Func<T, ResultType>&) | Transforms elements of a sequence. |
SharedPtr<IEnumerable<ResultType>> LINQ_Select(const Func<T, int32_t, ResultType>&) | Transforms each element of a sequence into a new form by incorporating the element’s index. |
SharedPtr<IEnumerable<Result>> LINQ_Select(const Func<Source, Result>&) | |
SharedPtr<IEnumerable<Result>> LINQ_Select(const Func<Source, int32_t, Result>&) | |
SharedPtr<IEnumerable<ResultType>> LINQ_SelectMany(const Func<T, SharedPtr<IEnumerable<ResultType>>>&) | Projects each element of a sequence and combines the resulting sequences into one sequence. |
SharedPtr<IEnumerable<Result>> LINQ_SelectMany(const Func<Source, SharedPtr<IEnumerable<Result>>>&) | |
System::ArrayPtr<T> LINQ_ToArray() | Creates an array from a sequence. |
SharedPtr<List<T>> LINQ_ToList() | Creates a List |
SharedPtr<IEnumerable<T>> LINQ_Where(std::function<bool(T)>) | Filters a sequence based on the specified predicate. |
void Lock() | Implements C# lock() statement locking. Call directly or use LockContext sentry object. |
virtual ptr MemberwiseClone() const | Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. |
Object() | Creates object. Initializes all internal data structures. |
Object(Object const&) | Copy constructor. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses. |
Object& operator=(Object const&) | Assignment operator. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses. |
ICollection& operator=(ICollection&&) | Move assignment operator. |
ICollection& operator=(const ICollection&) | Move assignment operator. |
reverse_iterator rbegin() | Gets a reverse iterator to the last element of collection (first in reverse). |
const_reverse_iterator rbegin() const | Gets a reverse iterator to the last element of the const-qualified collection (first in reverse). |
static bool ReferenceEquals(ptr const&, ptr const&) | Compares objects by reference. |
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, T const&) | Compares objects by reference. |
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, std::nullptr_t) | Reference-compares value type object with nullptr. |
bool ReferenceEquals(String const&, std::nullptr_t) | Specialization of Object::ReferenceEquals for case of string and nullptr. |
bool ReferenceEquals(String const&, String const&) | Specialization of Object::ReferenceEquals for case of strings. |
bool Remove(const T&) override | Removes first occurance of the specified element from list. |
void Remove(const SharedPtr<LinkedListNode<T>>&) | Removes node from list. |
int RemovedSharedRefs(int) | Decreases shared reference count by specified value. |
void RemoveFirst() | Removes first node from list. |
void RemoveLast() | Removes last node from list. |
reverse_iterator rend() | Gets a reverse iterator for a non-existent element before the start of the collection. |
const_reverse_iterator rend() const | Gets a reverse iterator for a non-existent element before the start of the const-qualified collection. |
virtual void SetTemplateWeakPtr(uint32_t) | Set n’th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. |
int SharedCount() const | Gets current value of shared reference counter. |
Object * SharedRefAdded() | Increments shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
int SharedRefRemovedSafe() | Decrements and returns shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
virtual String ToString() const | Analog of C# Object.ToString() method. Enables converting custom objects to string. |
static const TypeInfo& Type() | Implements C# typeof(System.Object) construct. |
void Unlock() | Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. |
System::Details::VirtualizedIteratorBase<T> * virtualizeBeginConstIterator() const override | Gets the implementation of begin const iterator for the current container. |
System::Details::VirtualizedIteratorBase<T> * virtualizeBeginIterator() override | Gets the implementation of begin iterator for the current container. |
System::Details::VirtualizedIteratorBase<T> * virtualizeEndConstIterator() const override | Gets the implementation of end const iterator for the current container. |
System::Details::VirtualizedIteratorBase<T> * virtualizeEndIterator() override | Gets the implementation of end iterator for the current container. |
Detail::SmartPtrCounter * WeakRefAdded() | Increments weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
void WeakRefRemoved() | Decrements weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
virtual ~ICollection() | Destructor. |
virtual ~Object() | Destroys object. Frees all internal data structures. |
Typedefs
Typedef | Description |
---|---|
list_t | Underlying data type. |
iterator | Iterator type. |
const_iterator | Const iterator type. |
reverse_iterator | Reverse iterator type. |
const_reverse_iterator | Const reverse iterator type. |
Remarks
Linked list container. Implements a wrapper over std::list. 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.
#include <system/collections/linkedlist.h>
#include <system/smart_ptr.h>
using namespace System;
using namespace System::Collections::Generic;
int main()
{
// Create an instance of the LinkedList class.
auto list = MakeObject<LinkedList<int>>();
// Fill the linked list.
list->AddFirst(1);
list->AddLast(30);
list->AddAfter(list->get_First(), 15);
list->AddBefore(list->get_Last(), 25);
// Print the linked list items.
for (const auto item: list)
{
std::cout << item << ' ';
}
return 0;
}
/*
This code example produces the following output:
1 15 25 30
*/
See Also
- Class Object
- Class ICollection
- Class Invalidatable
- Namespace System::Collections::Generic
- Library Aspose.Slides