System::Collections::Generic::LinkedList class
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
| Parameter | Description |
|---|---|
| T | Contained value type. |
Nested classes
- Class Enumerator
Methods
| Method | Description |
|---|---|
| Add(const T&) override | Adds element to the end of the list. |
| AddAfter(const SharedPtr<LinkedListNode<T>>&, const T&) | Adds element after node of the list. |
| AddAfter(const SharedPtr<LinkedListNode<T>>&, const SharedPtr<LinkedListNode<T>>&) | Adds newNode after node of the list. |
| AddBefore(const SharedPtr<LinkedListNode<T>>&, const T&) | Adds element before node of the list. |
| AddBefore(const SharedPtr<LinkedListNode<T>>&, const SharedPtr<LinkedListNode<T>>&) | Adds newNode before node of the list. |
| AddFirst(const T&) | Adds element to the beginning of the list. |
| AddFirst(const SharedPtr<LinkedListNode<T>>&) | Adds newNode to the beginning of the list. |
| AddLast(const T&) | Adds element to the end of the list. |
| AddLast(const SharedPtr<LinkedListNode<T>>&) | Adds newNode to the end of the list. |
| begin() | Gets iterator to the first element of collection. |
| begin() const | Gets iterator to the first element of the const-qualified collection. |
| cbegin() const | Gets iterator to the first const-qualified element of collection. |
| cend() const | Gets iterator for a non-existent const-qualified element behind the end of the collection. |
| Clear() override | Deletes all elements in list. |
| Contains(const T&) const override | Checks if element is present in list. |
| CopyTo(ArrayPtr<T>, int) override | Copies container data into existing array elements. |
| crbegin() const | Gets a reverse iterator to the last const-qualified element of collection (first in reverse). |
| crend() const | Gets a reverse iterator for a non-existent const-qualified element before the start of the collection. |
| end() | Gets iterator for a non-existent element behind the end of the collection. |
| end() const | Gets iterator for a non-existent element behind the end of the const-qualified collection. |
| Find(const T&) const | Performs forward direction find of an element in the list. |
| FindLast(const T&) const | Performs reverse direction find of an element in the list. |
| get_Count() const override | Gets number of elements in list. |
| get_First() const | Gets pointer to the first element in the list. |
| get_Last() const | Gets pointer to the last element in the list. |
| GetEnumerator() override | Gets enumerator to iterate through current LinkedList. |
| LinkedList() | Creates empty LinkedList. |
| LinkedList(const SharedPtr<IEnumerable<T>>&) | Copy constructor. |
| rbegin() | Gets a reverse iterator to the last element of collection (first in reverse). |
| rbegin() const | Gets a reverse iterator to the last element of the const-qualified collection (first in reverse). |
| Remove(const T&) override | Removes first occurance of the specified element from list. |
| Remove(const SharedPtr<LinkedListNode<T>>&) | Removes node from list. |
| RemoveFirst() | Removes first node from list. |
| RemoveLast() | Removes last node from list. |
| rend() | Gets a reverse iterator for a non-existent element before the start of the collection. |
| rend() const | Gets a reverse iterator for a non-existent element before the start of the const-qualified collection. |
| virtualizeBeginConstIterator() const override | Gets the implementation of begin const iterator for the current container. |
| virtualizeBeginIterator() override | Gets the implementation of begin iterator for the current container. |
| virtualizeEndConstIterator() const override | Gets the implementation of end const iterator for the current container. |
| virtualizeEndIterator() override | Gets the implementation of end iterator for the current container. |
Typedefs
| Typedef | Description |
|---|---|
| const_iterator | Const iterator type. |
| const_reverse_iterator | Const reverse iterator type. |
| iterator | Iterator type. |
| list_t | Underlying data type. |
| reverse_iterator | 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.PDF for C++