Commit 06e3b913 by Bryce McKinlay Committed by Bryce McKinlay

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
parent a6845c56
......@@ -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 <bryce@albatross.co.nz>
......
......@@ -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.
......
/* 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 <warrenl@cygnus.com>
* @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 <EM>total</EM>, such that two objects only compare equal if they are
* equal by the equals method, or <EM>partial</EM> 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.
* <P>
* 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:
* <UL>
* <LI>if compare(a, b) &lt; 0 then compare(b, a) &gt; 0</LI>
* <LI>if compare(a, b) throws an exception, so does compare(b, a)</LI>
* <LI>if compare(a, b) &lt; 0 and compare(b, c) &lt; 0 then compare(a, c)
* &lt; 0</LI>
* <LI>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 <EM>total</EM> ordering.</LI>
* </UL>
*
* @throws ClassCastException if the elements are not of types that can be
* compared by this ordering.
*/
int compare(Object o1, Object o2);
}
/* 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 <warrenl@cygnus.com>
* @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; <i>how</i> 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 <pre>Map</pre> 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();
}
/* 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 <warrenl@cygnus.com>
* @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();
}
/* 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 <warrenl@cygnus.com>
* @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);
}
......@@ -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);
}
}
/* 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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment