Add SkTDArray.contains(), which is just a wrapper around find()
authorepoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 13 Jul 2012 14:53:18 +0000 (14:53 +0000)
committerepoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 13 Jul 2012 14:53:18 +0000 (14:53 +0000)
Review URL: https://codereview.appspot.com/6349103

git-svn-id: http://skia.googlecode.com/svn/trunk@4595 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkTDArray.h

index 1afd3d0..60c987d 100644 (file)
@@ -229,6 +229,13 @@ public:
     }
 
     /**
+     * Returns true iff the array contains this element.
+     */
+    bool contains(const T& elem) const {
+        return (this->find(elem) >= 0);
+    }
+
+    /**
      * Copies up to max elements into dst. The number of items copied is
      * capped by count - index. The actual number copied is returned.
      */
@@ -333,4 +340,3 @@ private:
 };
 
 #endif
-