voidstar69 commented on code in PR #41539:
URL: https://github.com/apache/arrow/pull/41539#discussion_r1598017801


##########
csharp/src/Apache.Arrow/Arrays/PrimitiveArray.cs:
##########
@@ -86,5 +86,29 @@ IEnumerator IEnumerable.GetEnumerator()
                 yield return IsValid(index) ? Values[index] : null;
             }
         }
+
+        int ICollection<T?>.Count => Length;
+        bool ICollection<T?>.IsReadOnly => true;
+        void ICollection<T?>.Add(T? item) => throw new 
NotSupportedException("Collection is read-only.");
+        bool ICollection<T?>.Remove(T? item) => throw new 
NotSupportedException("Collection is read-only.");
+        void ICollection<T?>.Clear() => throw new 
NotSupportedException("Collection is read-only.");
+
+        bool ICollection<T?>.Contains(T? item)
+        {
+            if (item == null)
+            {
+                return NullCount > 0;
+            }
+
+            return Values.IndexOf(item.Value) >= 0;

Review Comment:
   Okay, I have added a test to catch this bug in my implementation, and 
switched to the implementation that you recommended.
   I have only optimised `Contains` for `PrimitiveArray` for now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to