Queue.Contains(Object) 方法
定义
public:
virtual bool Contains(System::Object ^ obj);
public virtual bool Contains (object obj);
public virtual bool Contains (object? obj);
abstract member Contains : obj -> bool
override this.Contains : obj -> bool
Public Overridable Function Contains (obj As Object) As Boolean
参数
- obj
- Object
要在 Object 中定位的 Queue。The Object to locate in the Queue. 该值可以为 null。The value can be null.
返回
如果在 true 中找到 obj,则为 Queue;否则为 false。true if obj is found in the Queue; otherwise, false.
注解
此方法通过调用来确定相等性 Object.Equals 。This method determines equality by calling Object.Equals.
此方法执行线性搜索;因此,此方法是一个 O(n) 操作,其中 n 是 Count 。This method performs a linear search; therefore, this method is an O(n) operation, where n is Count.
从 .NET Framework 2.0 开始,此方法使用集合的对象的 Equals 和 CompareTo 方法 obj 来确定是否 item 存在。Starting with the .NET Framework 2.0, this method uses the collection's objects' Equals and CompareTo methods on obj to determine whether item exists. 在 .NET Framework 的早期版本中,此决定是通过对 Equals CompareTo obj 集合中的对象使用参数的和方法进行的。In the earlier versions of the .NET Framework, this determination was made by using the Equals and CompareTo methods of the obj parameter on the objects in the collection.