commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections ReferenceMap.java
Date Mon, 29 Dec 2003 15:35:54 GMT
scolebourne    2003/12/29 07:35:54

  Modified:    collections/src/java/org/apache/commons/collections
                        ReferenceMap.java
  Log:
  Ensure that the keySet and values views handle removed elements
  bug 25551, from Joe Raysa
  
  Revision  Changes    Path
  1.20      +27 -4     jakarta-commons/collections/src/java/org/apache/commons/collections/ReferenceMap.java
  
  Index: ReferenceMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/ReferenceMap.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ReferenceMap.java	6 Dec 2003 13:03:15 -0000	1.19
  +++ ReferenceMap.java	29 Dec 2003 15:35:54 -0000	1.20
  @@ -706,7 +706,7 @@
           if (keySet != null) return keySet;
           keySet = new AbstractSet() {
               public int size() {
  -                return size;
  +                return ReferenceMap.this.size();
               }
   
               public Iterator iterator() {
  @@ -727,6 +727,17 @@
                   ReferenceMap.this.clear();
               }
   
  +            public Object[] toArray() {
  +                return toArray(new Object[0]);
  +            }
  +
  +            public Object[] toArray(Object[] array) {
  +                Collection c = new ArrayList(size());
  +                for (Iterator it = iterator(); it.hasNext(); ) {
  +                    c.add(it.next());
  +                }
  +                return c.toArray(array);
  +            }
           };
           return keySet;
       }
  @@ -741,7 +752,7 @@
           if (values != null) return values;
           values = new AbstractCollection()  {
               public int size() {
  -                return size;
  +                return ReferenceMap.this.size();
               }
   
               public void clear() {
  @@ -750,6 +761,18 @@
   
               public Iterator iterator() {
                   return new ValueIterator();
  +            }
  +
  +            public Object[] toArray() {
  +                return toArray(new Object[0]);
  +            }
  +
  +            public Object[] toArray(Object[] array) {
  +                Collection c = new ArrayList(size());
  +                for (Iterator it = iterator(); it.hasNext(); ) {
  +                    c.add(it.next());
  +                }
  +                return c.toArray(array);
               }
           };
           return values;
  
  
  

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


Mime
View raw message