db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r373115 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/IdentityArrayList.java
Date Sat, 28 Jan 2006 10:08:46 GMT
Author: arminw
Date: Sat Jan 28 02:08:41 2006
New Revision: 373115

URL: http://svn.apache.org/viewcvs?rev=373115&view=rev
Log:
fix bug (override remove-method too), add javadoc

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/IdentityArrayList.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/IdentityArrayList.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/IdentityArrayList.java?rev=373115&r1=373114&r2=373115&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/IdentityArrayList.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/IdentityArrayList.java
Sat Jan 28 02:08:41 2006
@@ -16,7 +16,15 @@
  */
 
 import java.util.ArrayList;
+import java.util.Iterator;
 
+/**
+ * Object identity based {@link java.util.List}, use <tt>"=="</tt> instead of
+ * <tt>element_1.equals(element_2)</tt> to compare objects.
+ *
+ * @author Guillaume Nodet
+ * @version $Id$
+ */
 public class IdentityArrayList extends ArrayList
 {
     public boolean contains(Object elem)
@@ -38,5 +46,33 @@
             if(elem == get(i))
                 return i;
         return -1;
+    }
+
+    public boolean remove(Object o)
+    {
+        Iterator e = iterator();
+        if(o == null)
+        {
+            while(e.hasNext())
+            {
+                if(e.next() == null)
+                {
+                    e.remove();
+                    return true;
+                }
+            }
+        }
+        else
+        {
+            while(e.hasNext())
+            {
+                if(o == e.next())
+                {
+                    e.remove();
+                    return true;
+                }
+            }
+        }
+        return false;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message