LinkedList<T>.Remove 方法
定义
从 LinkedList<T> 中移除节点或值的第一个匹配项。Removes the first occurrence of a node or value from the LinkedList<T>.
重载
| Remove(LinkedListNode<T>) |
从 LinkedList<T> 中移除指定的节点。Removes the specified node from the LinkedList<T>. |
| Remove(T) |
从 LinkedList<T> 中移除指定值的第一个匹配项。Removes the first occurrence of the specified value from the LinkedList<T>. |
Remove(LinkedListNode<T>)
从 LinkedList<T> 中移除指定的节点。Removes the specified node from the LinkedList<T>.
public:
void Remove(System::Collections::Generic::LinkedListNode<T> ^ node);
public void Remove (System.Collections.Generic.LinkedListNode<T> node);
member this.Remove : System.Collections.Generic.LinkedListNode<'T> -> unit
Public Sub Remove (node As LinkedListNode(Of T))
参数
- node
- LinkedListNode<T>
要从 LinkedListNode<T> 移除的 LinkedList<T>。The LinkedListNode<T> to remove from the LinkedList<T>.
例外
node 为 null。node is null.
node 不在当前 LinkedList<T> 中。node is not in the current LinkedList<T>.
示例
有关包括此方法的示例,请参阅 LinkedList<T> 类。For an example that includes this method, see the LinkedList<T> class.
注解
此方法是 O (1) 操作。This method is an O(1) operation.
另请参阅
适用于
Remove(T)
从 LinkedList<T> 中移除指定值的第一个匹配项。Removes the first occurrence of the specified value from the LinkedList<T>.
public:
virtual bool Remove(T value);
public bool Remove (T value);
abstract member Remove : 'T -> bool
override this.Remove : 'T -> bool
Public Function Remove (value As T) As Boolean
参数
- value
- T
要从 LinkedList<T> 中移除的值。The value to remove from the LinkedList<T>.
返回
如果成功移除包含 value 的元素,则为 true;否则为 false。true if the element containing value is successfully removed; otherwise, false. 如果在原始 false 中没有找到 value,此方法也会返回 LinkedList<T>。This method also returns false if value was not found in the original LinkedList<T>.
实现
示例
有关包括此方法的示例,请参阅 LinkedList<T> 类。For an example that includes this method, see the LinkedList<T> class.
注解
此方法执行线性搜索;因此,此方法是 O (n) 操作,其中 n 是 Count 。This method performs a linear search; therefore, this method is an O(n) operation, where n is Count.