System::Collections::Generic::LinkedList 类
内容
[
隐藏
]LinkedList class
LinkedList forward declaration.
template<typename T>class LinkedList : public virtual System::Object,
public System::Collections::Generic::ICollection<T>,
private System::Collections::Invalidatable
| 参数 | 描述 |
|---|---|
| T | 包含的值类型。 |
Nested classes
- Class Enumerator
方法
| 方法 | 描述 |
|---|---|
| Add(const T&) override | 将 element 添加到列表的末尾。 |
| AddAfter(const SharedPtr<LinkedListNode<T>>&, const T&) | 在列表的 node 之后添加 element。 |
| AddAfter(const SharedPtr<LinkedListNode<T>>&, const SharedPtr<LinkedListNode<T>>&) | 在列表的 node 之后添加 newNode。 |
| AddBefore(const SharedPtr<LinkedListNode<T>>&, const T&) | 在列表的 node 之前添加 element。 |
| AddBefore(const SharedPtr<LinkedListNode<T>>&, const SharedPtr<LinkedListNode<T>>&) | 在列表的 node 之前添加 newNode。 |
| AddFirst(const T&) | 将 element 添加到列表的开头。 |
| AddFirst(const SharedPtr<LinkedListNode<T>>&) | 将 newNode 添加到列表的开头。 |
| AddLast(const T&) | 将 element 添加到列表的末尾。 |
| AddLast(const SharedPtr<LinkedListNode<T>>&) | 将 newNode 添加到列表的末尾。 |
| begin() | 获取集合中第一个元素的迭代器。 |
| begin() const | 获取指向 const 限定集合的第一个元素的迭代器。 |
| cbegin() const | 获取指向集合的第一个 const 限定元素的迭代器。 |
| cend() const | 获取指向集合末尾之后的不存在的 const 限定元素的迭代器。 |
| Clear() override | 删除列表中的所有元素。 |
| Contains(const T&) const override | 检查列表中是否存在 element。 |
| CopyTo(ArrayPtr<T>, int) override | 将容器数据复制到现有数组元素中。 |
| crbegin() const | 获取指向集合中最后一个 const 限定元素的逆向迭代器(逆向的第一个)。 |
| crend() const | 获取指向集合起始之前的不存在的 const 限定元素的逆向迭代器。 |
| end() | 获取指向集合末尾之后的不存在的元素的迭代器。 |
| end() const | 获取指向 const 限定集合末尾之后的不存在的元素的迭代器。 |
| Find(const T&) const | 在列表中执行 element 的正向查找。 |
| FindLast(const T&) const | 在列表中执行 element 的反向查找。 |
| get_Count() const override | 获取列表中元素的数量。 |
| get_First() const | 获取列表中第一个元素的指针。 |
| get_Last() const | 获取列表中最后一个元素的指针。 |
| GetEnumerator() override | 获取枚举器以遍历当前的 LinkedList。 |
| LinkedList() | 创建空的 LinkedList。 |
| LinkedList(const SharedPtr<IEnumerable<T>>&) | 拷贝构造函数。 |
| rbegin() | 获取指向集合中最后一个元素的逆向迭代器(逆向的第一个)。 |
| rbegin() const | 获取指向 const 限定集合中最后一个元素的逆向迭代器(逆向的第一个)。 |
| Remove(const T&) override | 从列表中移除指定 element 的第一次出现。 |
| Remove(const SharedPtr<LinkedListNode<T>>&) | 从列表中移除节点。 |
| RemoveFirst() | 从列表中移除第一个节点。 |
| RemoveLast() | 从列表中移除最后一个节点。 |
| rend() | 获取指向集合起始之前的不存在的元素的逆向迭代器。 |
| rend() const | 获取指向 const 限定集合起始之前的不存在的元素的逆向迭代器。 |
| virtualizeBeginConstIterator() const override | 获取当前容器的 begin const 迭代器的实现。 |
| virtualizeBeginIterator() override | 获取当前容器的 begin 迭代器的实现。 |
| virtualizeEndConstIterator() const override | 获取当前容器的 end const 迭代器的实现。 |
| virtualizeEndIterator() override | 获取当前容器的 end 迭代器的实现。 |
Typedefs
| 类型定义 | 描述 |
|---|---|
| const_iterator | 常量迭代器类型。 |
| const_reverse_iterator | 常量反向迭代器类型。 |
| iterator | 迭代器类型。 |
| list_t | 底层数据类型。 |
| reverse_iterator | 反向迭代器类型。 |
备注
链表容器。实现了对 std::list 的包装。此类的对象只能使用 System::MakeObject() 函数分配。切勿在栈上或使用 operator new 创建此类型的实例,因为这会导致运行时错误和/或断言故障。始终将此类包装到 System::SmartPtr 指针中,并使用该指针将其作为参数传递给函数。
#include <system/collections/linkedlist.h>
#include <system/smart_ptr.h>
using namespace System;
using namespace System::Collections::Generic;
int main()
{
// 创建 LinkedList 类的实例。
auto list = MakeObject<LinkedList<int>>();
// 填充链表。
list->AddFirst(1);
list->AddLast(30);
list->AddAfter(list->get_First(), 15);
list->AddBefore(list->get_Last(), 25);
// 打印链表项。
for (const auto item: list)
{
std::cout << item << ' ';
}
return 0;
}
/*
This code example produces the following output:
1 15 25 30
*/
另见
- Class Object
- Class ICollection
- Class Invalidatable
- Namespace System::Collections::Generic
- Library Aspose.Font for C++