SF.net SVN: jython:[7234] trunk/jython/src/org/python/core/PyTuple.java

[email protected] Mon, 14 Mar 2011 03:34:15 +0000
Newsgroups gmane.comp.lang.jython.cvs
Message-ID <[email protected]>
Revision: 7234
          http://jython.svn.sourceforge.net/jython/?rev=7234&view=rev
Author:   pjenvey
Date:     2011-03-14 03:34:15 +0000 (Mon, 14 Mar 2011)

Log Message:
-----------
add tuple.count

Modified Paths:
--------------
    trunk/jython/src/org/python/core/PyTuple.java

Modified: trunk/jython/src/org/python/core/PyTuple.java
===================================================================
--- trunk/jython/src/org/python/core/PyTuple.java	2011-03-14 03:32:44 UTC (rev 7233)
+++ trunk/jython/src/org/python/core/PyTuple.java	2011-03-14 03:34:15 UTC (rev 7234)
@@ -471,6 +471,21 @@
         }
     }
 
+    public int count(PyObject obj) {
+        return tuple_count(obj);
+    }
+
+    @ExposedMethod(doc = BuiltinDocs.tuple_count_doc)
+    final int tuple_count(PyObject obj) {
+        int count = 0;
+        for (PyObject item : array) {
+            if (item.equals(obj)) {
+                count++;
+            }
+        }
+        return count;
+    }
+
     @Override
     public boolean equals(Object other) {
         if (this == other) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d