From 06e3b913b388b770222e5467069c5d98872760a0 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Thu, 15 Feb 2001 06:43:00 +0000 Subject: [PATCH] AbstractSequentialList.java: Synchronize with Classpath. * java/util/AbstractSequentialList.java: Synchronize with Classpath. * java/util/Collection.java: Likewise. * java/util/Comparator.java: Likewise. * java/util/Dictionary.java: Likewise. * java/util/Iterator.java: Likewise. * java/util/ListIterator.java: Likewise. * java/util/Map.java: Likewise. * java/util/Set.java: Likewise. From-SVN: r39708 --- libjava/ChangeLog | 9 + libjava/java/util/AbstractSequentialList.java | 1 - libjava/java/util/Collection.java | 253 ++++++++++++++++-- libjava/java/util/Comparator.java | 68 ++++- libjava/java/util/Dictionary.java | 95 +++++-- libjava/java/util/Iterator.java | 73 +++-- libjava/java/util/ListIterator.java | 158 +++++++++-- libjava/java/util/Map.java | 47 ++-- libjava/java/util/Set.java | 7 +- 9 files changed, 585 insertions(+), 126 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 1de5ea454fe..bb56489a572 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -10,6 +10,15 @@ Rectangle.clone(), not Object.clone(). * java/util/HashSet.java (clone): Remove try/catch. + + * java/util/AbstractSequentialList.java: Synchronize with Classpath. + * java/util/Collection.java: Likewise. + * java/util/Comparator.java: Likewise. + * java/util/Dictionary.java: Likewise. + * java/util/Iterator.java: Likewise. + * java/util/ListIterator.java: Likewise. + * java/util/Map.java: Likewise. + * java/util/Set.java: Likewise. 2001-02-14 Bryce McKinlay diff --git a/libjava/java/util/AbstractSequentialList.java b/libjava/java/util/AbstractSequentialList.java index b9b8e63d1f6..81481be0466 100644 --- a/libjava/java/util/AbstractSequentialList.java +++ b/libjava/java/util/AbstractSequentialList.java @@ -38,7 +38,6 @@ package java.util; */ public abstract class AbstractSequentialList extends AbstractList { - /** * Returns a ListIterator over the list, starting from position index. * Subclasses must provide an implementation of this method. diff --git a/libjava/java/util/Collection.java b/libjava/java/util/Collection.java index 46da71b1dc7..b7dbb69b1f7 100644 --- a/libjava/java/util/Collection.java +++ b/libjava/java/util/Collection.java @@ -1,37 +1,236 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Collection.java -- Interface that represents a collection of objects + Copyright (C) 1998 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +// TO DO: +// ~ Maybe some more @see clauses would be helpful. package java.util; /** - * @author Warren Levy - * @date March 16, 2000. - */ -/* Written using on-line Java Platform 1.2 API Specification. - * Status: Believed complete and correct. + * Interface that represents a collection of objects. This interface is the + * root of the collection hierarchy, and does not provide any guarantees about + * the order of its elements or whether or not duplicate elements are + * permitted. + *

+ * All methods of this interface that are defined to modify the collection are + * defined as optional. An optional operation may throw an + * UnsupportedOperationException if the data backing this collection does not + * support such a modification. This may mean that the data structure is + * immutable, or that it is read-only but may change ("unmodifiable"), or + * that it is modifiable but of fixed size (such as an array), or any number + * of other combinations. + *

+ * A class that wishes to implement this interface should consider subclassing + * AbstractCollection, which provides basic implementations of most of the + * methods of this interface. Classes that are prepared to make guarantees + * about ordering or about absence of duplicate elements should consider + * implementing List or Set respectively, both of which are subinterfaces of + * Collection. + *

+ * A general-purpose implementation of the Collection interface should in most + * cases provide at least two constructors: One which takes no arguments and + * creates an empty collection, and one which takes a Collection as an argument + * and returns a collection containing the same elements (that is, creates a + * copy of the argument using its own implementation). + * + * @see java.util.List + * @see java.util.Set + * @see java.util.AbstractCollection */ - -// JDK1.2 public interface Collection { - public int size(); - public boolean isEmpty(); - public boolean contains(Object o); - public Iterator iterator(); - public Object[] toArray(); - public Object[] toArray(Object[] a); - public boolean add(Object o); - public boolean remove(Object o); - public boolean containsAll(Collection c); - public boolean addAll(Collection c); - public boolean removeAll(Collection c); - public boolean retainAll(Collection c); - public void clear(); - public boolean equals(Object o); - public int hashCode(); + /** + * Add an element to this collection. + * + * @param o the object to add. + * @returns true if the collection was modified as a result of this action. + * @exception UnsupportedOperationException if this collection does not + * support the add operation. + * @exception ClassCastException if o cannot be added to this collection due + * to its type. + * @exception IllegalArgumentException if o cannot be added to this + * collection for some other reason. + */ + boolean add(Object o); + + /** + * Add the contents of a given collection to this collection. + * + * @param c the collection to add. + * @returns true if the collection was modified as a result of this action. + * @exception UnsupportedOperationException if this collection does not + * support the addAll operation. + * @exception ClassCastException if some element of c cannot be added to this + * collection due to its type. + * @exception IllegalArgumentException if some element of c cannot be added + * to this collection for some other reason. + */ + boolean addAll(Collection c); + + /** + * Clear the collection, such that a subsequent call to isEmpty() would + * return true. + * + * @exception UnsupportedOperationException if this collection does not + * support the clear operation. + */ + void clear(); + + /** + * Test whether this collection contains a given object as one of its + * elements. + * + * @param o the element to look for. + * @returns true if this collection contains at least one element e such that + * o == null ? e == null : o.equals(e). + */ + boolean contains(Object o); + + /** + * Test whether this collection contains every element in a given collection. + * + * @param c the collection to test for. + * @returns true if for every element o in c, contains(o) would return true. + */ + boolean containsAll(Collection c); + + /** + * Test whether this collection is equal to some object. The Collection + * interface does not explicitly require any behaviour from this method, and + * it may be left to the default implementation provided by Object. The Set + * and List interfaces do, however, require specific behaviour from this + * method. + *

+ * If an implementation of Collection, which is not also an implementation of + * Set or List, should choose to implement this method, it should take care + * to obey the contract of the equals method of Object. In particular, care + * should be taken to return false when o is a Set or a List, in order to + * preserve the symmetry of the relation. + * + * @param o the object to compare to this collection. + * @returns true if the o is equal to this collection. + */ + boolean equals(Object o); + + /** + * Obtain a hash code for this collection. The Collection interface does not + * explicitly require any behaviour from this method, and it may be left to + * the default implementation provided by Object. The Set and List interfaces + * do, however, require specific behaviour from this method. + *

+ * If an implementation of Collection, which is not also an implementation of + * Set or List, should choose to implement this method, it should take care + * to obey the contract of the hashCode method of Object. Note that this + * method renders it impossible to correctly implement both Set and List, as + * the required implementations are mutually exclusive. + * + * @returns a hash code for this collection. + */ + int hashCode(); + + /** + * Test whether this collection is empty, that is, if size() == 0. + * + * @returns true if this collection contains no elements. + */ + boolean isEmpty(); + + /** + * Obtain an Iterator over this collection. + * + * @returns an Iterator over the elements of this collection, in any order. + */ + Iterator iterator(); + + /** + * Remove a single occurrence of an object from this collection. That is, + * remove an element e, if one exists, such that o == null ? e == null + * : o.equals(e). + * + * @param o the object to remove. + * @returns true if the collection changed as a result of this call, that is, + * if the collection contained at least one occurrence of o. + * @exception UnsupportedOperationException if this collection does not + * support the remove operation. + */ + boolean remove(Object o); + + /** + * Remove all elements of a given collection from this collection. That is, + * remove every element e such that c.contains(e). + * + * @returns true if this collection was modified as a result of this call. + * @exception UnsupportedOperationException if this collection does not + * support the removeAll operation. + */ + boolean removeAll(Collection c); + + /** + * Remove all elements of this collection that are not contained in a given + * collection. That is, remove every element e such that !c.contains(e). + * + * @returns true if this collection was modified as a result of this call. + * @exception UnsupportedOperationException if this collection does not + * support the retainAll operation. + */ + boolean retainAll(Collection c); + + /** + * Get the number of elements in this collection. + * + * @returns the number of elements in the collection. + */ + int size(); + + /** + * Copy the current contents of this collection into an array. + * + * @returns an array of type Object[] and length equal to the size of this + * collection, containing the elements currently in this collection, in + * any order. + */ + Object[] toArray(); + + /** + * Copy the current contents of this collection into an array. If the array + * passed as an argument has length less than the size of this collection, an + * array of the same run-time type as a, and length equal to the size of this + * collection, is allocated using Reflection. Otherwise, a itself is used. + * The elements of this collection are copied into it, and if there is space + * in the array, the following element is set to null. The resultant array is + * returned. + * Note: The fact that the following element is set to null is only useful + * if it is known that this collection does not contain any null elements. + * + * @param a the array to copy this collection into. + * @returns an array containing the elements currently in this collection, in + * any order. + * @exception ArrayStoreException if the type of any element of the + * collection is not a subtype of the element type of a. + */ + Object[] toArray(Object[] a); } diff --git a/libjava/java/util/Comparator.java b/libjava/java/util/Comparator.java index 8f114ee79b0..4b09e0fdab0 100644 --- a/libjava/java/util/Comparator.java +++ b/libjava/java/util/Comparator.java @@ -1,24 +1,64 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Comparator.java -- Interface for objects that specify an ordering + Copyright (C) 1998 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.util; /** - * @author Warren Levy - * @date March 16, 2000. - */ -/* Written using on-line Java Platform 1.2 API Specification. - * Status: Believed complete and correct. + * Interface for objects that specify an ordering between objects. The ordering + * can be total, such that two objects only compare equal if they are + * equal by the equals method, or partial such that this is not + * necessarily true. For example, a case-sensitive dictionary order comparison + * of Strings is total, but if it is case-insensitive it is partial, because + * "abc" and "ABC" compare as equal even though "abc".equals("ABC") returns + * false. + *

+ * In general, Comparators should be Serializable, because when they are passed + * to Serializable data structures such as SortedMap or SortedSet, the entire + * data structure will only serialize correctly if the comparator is + * Serializable. */ - -// JDK1.2 public interface Comparator { - public int compare(Object o1, Object o2); - public boolean equals(Object obj); + /** + * Return an integer that is negative, zero or positive depending on whether + * the first argument is less than, equal to or greater than the second + * according to this ordering. This method should obey the following contract: + *

    + *
  • if compare(a, b) < 0 then compare(b, a) > 0
  • + *
  • if compare(a, b) throws an exception, so does compare(b, a)
  • + *
  • if compare(a, b) < 0 and compare(b, c) < 0 then compare(a, c) + * < 0
  • + *
  • if a.equals(b) or both a and b are null, then compare(a, b) == 0. + * The converse need not be true, but if it is, this Comparator + * specifies a total ordering.
  • + *
+ * + * @throws ClassCastException if the elements are not of types that can be + * compared by this ordering. + */ + int compare(Object o1, Object o2); } diff --git a/libjava/java/util/Dictionary.java b/libjava/java/util/Dictionary.java index f127cc050fd..3319c9cde57 100644 --- a/libjava/java/util/Dictionary.java +++ b/libjava/java/util/Dictionary.java @@ -1,34 +1,85 @@ -/* Copyright (C) 1998, 1999 Free Software Foundation +/* Dictionary.java -- an abstract (and essentially worthless) + class which is Hashtable's superclass + Copyright (C) 1998 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.util; - + /** - * @author Warren Levy - * @date August 31, 1998. - */ -/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 - * "The Java Language Specification", ISBN 0-201-63451-1 - * plus online API docs for JDK 1.2 beta from http://www.javasoft.com. - * Status: Believed complete and correct - */ - -/* The JDK 1.2 beta doc indicates that Dictionary is obsolete and that the - * new java.util.Map interface should be used instead. + * A Dictionary maps keys to values; how it does that is + * implementation-specific. + * + * This is an abstract class which has really gone by the wayside. + * People at Javasoft are probably embarrassed by it. At this point, + * it might as well be an interface rather than a class, but it remains + * this poor, laugable skeleton for the sake of backwards compatibility. + * At any rate, this was what came before the
Map
interface + * in the Collections framework. + * + * @author Jon Zeppieri + * @version $Revision: 1.4 $ + * @modified $Id: Dictionary.java,v 1.4 2000/10/26 10:19:00 bryce Exp $ */ -public abstract class Dictionary +public abstract class Dictionary extends Object { + /** returns an Enumeration of the values in this Dictionary */ public abstract Enumeration elements(); - public abstract Object get(Object key) throws NullPointerException; + + /** + * returns the value associated with the supplied key, or null + * if no such value exists + * + * @param key the key to use to fetch the value + */ + public abstract Object get(Object key); + + /** returns true IFF there are no elements in this Dictionary (size() == 0) */ public abstract boolean isEmpty(); + + /** returns an Enumeration of the keys in this Dictionary */ public abstract Enumeration keys(); - public abstract Object put(Object key, Object elem) - throws NullPointerException; - public abstract Object remove(Object key) throws NullPointerException; + + /** + * inserts a new value into this Dictionary, located by the + * supllied key; note: Dictionary's subclasses (all 1 of them) + * do not support null keys or values (I can only assume this + * would have been more general) + * + * @param key the key which locates the value + * @param value the value to put into the Dictionary + */ + public abstract Object put(Object key, Object value); + + /** + * removes fro the Dictionary the value located by the given key + * + * @param key the key used to locate the value to be removed + */ + public abstract Object remove(Object key); + + /** returns the number of values currently in this Dictionary */ public abstract int size(); } diff --git a/libjava/java/util/Iterator.java b/libjava/java/util/Iterator.java index f6942fefa19..92620f8c0ac 100644 --- a/libjava/java/util/Iterator.java +++ b/libjava/java/util/Iterator.java @@ -1,25 +1,68 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Iterator.java -- Interface for iterating over collections + Copyright (C) 1998 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.util; /** - * @author Warren Levy - * @date March 16, 2000. + * An object which iterates over a collection. An Iterator is used to return the + * items once only, in sequence, by successive calls to the next method. It is + * also possible to remove elements from the underlying collection by using the + * optional remove method. Iterator is intended as a replacement for the + * Enumeration interface of previous versions of Java, which did not have the + * remove method and had less conveniently named methods. */ -/* Written using on-line Java Platform 1.2 API Specification. - * Status: Believed complete and correct. - */ - -// JDK1.2 public interface Iterator { - public boolean hasNext(); - public Object next(); - public void remove(); + /** + * Tests whether there are elements remaining in the collection. + * + * @return true if there is at least one more element in the collection, + * that is, if the next call to next will not throw NoSuchElementException. + */ + boolean hasNext(); + + /** + * Obtain the next element in the collection. + * + * @return the next element in the collection + * @exception NoSuchElementException if there are no more elements + */ + Object next(); + + /** + * Remove from the underlying collection the last element returned by next. + * This method can be called only once after each call to next. It does not + * affect what will be returned by subsequent calls to next. This operation is + * optional, it may throw an UnsupportedOperationException. + * + * @exception IllegalStateException if next has not yet been called or remove + * has already been called since the last call to next. + * @exception UnsupportedOperationException if this Iterator does not support + * the remove operation. + */ + void remove(); } diff --git a/libjava/java/util/ListIterator.java b/libjava/java/util/ListIterator.java index 8250e2ab01a..8a8d2c74e9d 100644 --- a/libjava/java/util/ListIterator.java +++ b/libjava/java/util/ListIterator.java @@ -1,31 +1,147 @@ -/* Copyright (C) 2000 Free Software Foundation +/* ListIterator.java -- Extended Iterator for iterating over ordered lists + Copyright (C) 1998, 1999 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.util; /** - * @author Warren Levy - * @date March 16, 2000. + * An extended version of Iterator to support the extra features of Lists. The + * elements may be accessed in forward or reverse order, elements may be + * replaced as well as removed, and new elements may be inserted, during the + * traversal of the list. */ -/* Written using on-line Java Platform 1.2 API Specification. - * Status: Believed complete and correct. - */ - -// JDK1.2 public interface ListIterator extends Iterator { - public boolean hasNext(); - public Object next(); - public boolean hasPrevious(); - public Object previous(); - public int nextIndex(); - public int previousIndex(); - public void remove(); - public void set(Object o); - public void add(Object o); + /** + * Tests whether there are elements remaining in the list in the forward + * direction. + * + * @return true if there is at least one more element in the list in the + * forward direction, that is, if the next call to next will not throw + * NoSuchElementException. + */ + boolean hasNext(); + + /** + * Tests whether there are elements remaining in the list in the reverse + * direction. + * + * @return true if there is at least one more element in the list in the + * reverse direction, that is, if the next call to previous will not throw + * NoSuchElementException. + */ + boolean hasPrevious(); + + /** + * Obtain the next element in the list in the forward direction. Repeated + * calls to next may be used to iterate over the entire list, or calls to next + * and previous may be used together to go forwards and backwards. Alternating + * calls to next and previous will return the same element. + * + * @return the next element in the list in the forward direction + * @exception NoSuchElementException if there are no more elements + */ + Object next(); + + /** + * Obtain the next element in the list in the reverse direction. Repeated + * calls to previous may be used to iterate backwards over the entire list, or + * calls to next and previous may be used together to go forwards and + * backwards. Alternating calls to next and previous will return the same + * element. + * + * @return the next element in the list in the reverse direction + * @exception NoSuchElementException if there are no more elements + */ + Object previous(); + + /** + * Find the index of the element that would be returned by a call to next. + * + * @return the index of the element that would be returned by a call to next, + * or list.size() if the iterator is at the end of the list. + */ + int nextIndex(); + + /** + * Find the index of the element that would be returned by a call to previous. + * + * @return the index of the element that would be returned by a call to + * previous, or -1 if the iterator is at the beginning of the list. + */ + int previousIndex(); + + /** + * Insert an element into the list at the current position of the iterator. + * The element is inserted in between the element that would be returned by + * previous and the element that would be returned by next. After the + * insertion, a subsequent call to next is unaffected, but a call to + * previous returns the item that was added. This operation is optional, it + * may throw an UnsupportedOperationException. + * + * @param o the object to insert into the list + * @exception ClassCastException the object is of a type which cannot be added + * to this list + * @exception IllegalArgumentException some other aspect of the object stops + * it being added to this list + * @exception UnsupportedOperationException if this ListIterator does not + * support the add operation + */ + void add(Object o); + + /** + * Remove from the list the element last returned by a call to next or + * previous. This method may only be called if neither add nor remove have + * been called since the last call to next or previous. This operation is + * optional, it may throw an UnsupportedOperationException. + * + * @exception IllegalStateException if neither next or previous have been + * called, or if add or remove has been called since the last call to next + * or previous. + * @exception UnsupportedOperationException if this ListIterator does not + * support the remove operation. + */ + void remove(); + + /** + * Replace the element last returned by a call to next or previous with a + * given object. This method may only be called if neither add nor remove have + * been called since the last call to next or previous. This operation is + * optional, it may throw an UnsupportedOperationException. + * + * @param o the object to replace the element with + * @exception ClassCastException the object is of a type which cannot be added + * to this list + * @exception IllegalArgumentException some other aspect of the object stops + * it being added to this list + * @exception IllegalStateException if neither next or previous have been + * called, or if add or remove has been called since the last call to next + * or previous. + * @exception UnsupportedOperationException if this ListIterator does not + * support the set operation. + */ + void set(Object o); } diff --git a/libjava/java/util/Map.java b/libjava/java/util/Map.java index c9d46dffb3e..b1d43269711 100644 --- a/libjava/java/util/Map.java +++ b/libjava/java/util/Map.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -30,28 +30,29 @@ executable file might be covered by the GNU General Public License. */ package java.util; -public interface Map +public interface Map { - public void clear(); - public boolean containsKey(Object key); - public boolean containsValue(Object value); - public Set entrySet(); - public boolean equals(Object o); - public Object get(Object key); - public Object put(Object key, Object value); + public void clear(); + public boolean containsKey(Object key); + public boolean containsValue(Object value); + public Set entrySet(); + public boolean equals(Object o); + public Object get(Object key); + public Object put(Object key, Object value); + public int hashCode(); + public boolean isEmpty(); + public Set keySet(); + public void putAll(Map m); + public Object remove(Object o); + public int size(); + public Collection values(); + + public static interface Entry + { + public Object getKey(); + public Object getValue(); + public Object setValue(Object value); public int hashCode(); - public boolean isEmpty(); - public Set keySet(); - public void putAll(Map m); - public Object remove(Object o); - public int size(); - public Collection values(); - - public static interface Entry { - public Object getKey(); - public Object getValue(); - public Object setValue(Object value); - public int hashCode(); - public boolean equals(Object o); - } + public boolean equals(Object o); + } } diff --git a/libjava/java/util/Set.java b/libjava/java/util/Set.java index 4eac12063e9..3c8c09be3d3 100644 --- a/libjava/java/util/Set.java +++ b/libjava/java/util/Set.java @@ -1,5 +1,5 @@ /* Set.java -- A collection that prohibits duplicates - Copyright (C) 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1998 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -30,7 +30,8 @@ executable file might be covered by the GNU General Public License. */ package java.util; -public interface Set extends Collection { +public interface Set extends Collection +{ boolean add(Object o); boolean addAll(Collection c); void clear(); -- 2.30.2