Commit 887b528a authored by bryce's avatar bryce
Browse files

* java/util/BasicMapEntry.java: Re-added.

	* java/util/HashMap.java (Entry): Extend BasicMapEntry.
	(putAll): Test for BasicMapEntry.
	* java/util/Hashtable.java (Entry): Extend BasicMapEntry.
	(putAll): Test for BasicMapEntry.
	Change references from `HashMap.Entry' to `Entry' in various places.
	* Makefile.am: Add BasicMapEntry.java.
	* Makefile.in: Rebuilt.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38410 138bc75d-0d04-0410-961f-82ee72b054a4
parent 5ce8da41
2000-12-21 Bryce McKinlay <bryce@albatross.co.nz>
* java/util/BasicMapEntry.java: Re-added.
* java/util/HashMap.java (Entry): Extend BasicMapEntry.
(putAll): Test for BasicMapEntry.
* java/util/Hashtable.java (Entry): Extend BasicMapEntry.
(putAll): Test for BasicMapEntry.
Change references from `HashMap.Entry' to `Entry' in various places.
* Makefile.am: Add BasicMapEntry.java.
* Makefile.in: Rebuilt.
2000-12-18 Warren Levy <warrenl@redhat.com>
* java/util/GregorianCalendar.java (GregorianCalendar): Constructors
......
......@@ -929,6 +929,7 @@ java/util/AbstractSequentialList.java \
java/util/AbstractSet.java \
java/util/ArrayList.java \
java/util/Arrays.java \
java/util/BasicMapEntry.java \
java/util/BitSet.java \
java/util/Calendar.java \
java/util/Collection.java \
......
......@@ -120,43 +120,29 @@ here = @here@
libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign no-installinfo
@TESTSUBDIR_TRUE@SUBDIRS = \
@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = \
@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = \
@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = \
@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexecdir = \
@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
@NO_X_TRUE@cond_x_ltlibrary = \
@NO_X_FALSE@cond_x_ltlibrary = \
@NO_X_FALSE@libgcjx.la
@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
@NO_X_TRUE@cond_x_ltlibrary =
@NO_X_FALSE@cond_x_ltlibrary = @NO_X_FALSE@libgcjx.la
toolexeclib_LTLIBRARIES = libgcj.la $(cond_x_ltlibrary)
toolexeclib_DATA = libgcj.spec
data_DATA = libgcj.jar
@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = \
@NEEDS_DATA_START_TRUE@libgcjdata.a
@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = \
@NEEDS_DATA_START_TRUE@libgcjdata.c
@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = @NEEDS_DATA_START_TRUE@libgcjdata.a
@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = @NEEDS_DATA_START_TRUE@libgcjdata.c
@NATIVE_TRUE@bin_PROGRAMS = \
@NATIVE_TRUE@jv-convert gij
@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij
bin_SCRIPTS = addr2name.awk
@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = \
@CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = \
@CANADIAN_TRUE@@NULL_TARGET_FALSE@fastjar
@CANADIAN_FALSE@ZIP = \
@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
@CANADIAN_TRUE@GCJH = \
@CANADIAN_TRUE@gcjh
@CANADIAN_FALSE@GCJH = \
@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@fastjar
@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh
@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8
......@@ -173,10 +159,8 @@ AM_CXXFLAGS = -fno-rtti -fvtable-thunks -fasynchronous-exceptions \
-fdollars-in-identifiers \
@LIBGCJ_CXXFLAGS@ @EXCEPTIONSPEC@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE
@USING_GCC_TRUE@AM_CFLAGS = \
@USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
@USING_GCC_FALSE@AM_CFLAGS = \
@USING_GCC_FALSE@@LIBGCJ_CFLAGS@
@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@
JCFLAGS = -g
JC1FLAGS = -g @LIBGCJ_JAVAFLAGS@
......@@ -245,8 +229,7 @@ extra_headers = java/lang/Object.h java/lang/Class.h
NM = nm
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
CONVERT_DIR = gnu/gcj/convert
......@@ -695,6 +678,7 @@ java/util/AbstractSequentialList.java \
java/util/AbstractSet.java \
java/util/ArrayList.java \
java/util/Arrays.java \
java/util/BasicMapEntry.java \
java/util/BitSet.java \
java/util/Calendar.java \
java/util/Collection.java \
......@@ -1210,7 +1194,7 @@ libgcj-test.spec.in libgcj.spec.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
DIST_SUBDIRS = @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include
DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
......@@ -1691,9 +1675,10 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/util/AbstractCollection.P .deps/java/util/AbstractList.P \
.deps/java/util/AbstractMap.P .deps/java/util/AbstractSequentialList.P \
.deps/java/util/AbstractSet.P .deps/java/util/ArrayList.P \
.deps/java/util/Arrays.P .deps/java/util/BitSet.P \
.deps/java/util/Calendar.P .deps/java/util/Collection.P \
.deps/java/util/Collections.P .deps/java/util/Comparator.P \
.deps/java/util/Arrays.P .deps/java/util/BasicMapEntry.P \
.deps/java/util/BitSet.P .deps/java/util/Calendar.P \
.deps/java/util/Collection.P .deps/java/util/Collections.P \
.deps/java/util/Comparator.P \
.deps/java/util/ConcurrentModificationException.P \
.deps/java/util/Date.P .deps/java/util/Dictionary.P \
.deps/java/util/EmptyStackException.P .deps/java/util/Enumeration.P \
......@@ -2111,7 +2096,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
......
/* BasicMapEntry.java -- a class providing a plain-vanilla implementation of
the Map.Entry interface; could be used anywhere in java.util
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
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. */
package java.util;
/**
* A class which implements Map.Entry. It is shared by HashMap, TreeMap, and
* Hashtable.
*
* @author Jon Zeppieri
* @version $Revision: 1.5 $
* @modified $Id: BasicMapEntry.java,v 1.5 2000/10/26 10:19:00 bryce Exp $
*/
class BasicMapEntry implements Map.Entry
{
Object key;
Object value;
BasicMapEntry(Object newKey, Object newValue)
{
key = newKey;
value = newValue;
}
public final boolean equals(Object o)
{
if (!(o instanceof Map.Entry))
return false;
Map.Entry e = (Map.Entry) o;
return (key == null ? e.getKey() == null : key.equals(e.getKey())
&& value == null ? e.getValue() == null
: value.equals(e.getValue()));
}
public final Object getKey()
{
return key;
}
public final Object getValue()
{
return value;
}
public final int hashCode()
{
int kc = (key == null ? 0 : key.hashCode());
int vc = (value == null ? 0 : value.hashCode());
return kc ^ vc;
}
/**
* sets the value of this Map.Entry. Note that this is overriden by
* Hashtable.Entry, which does not permit a null value.
*/
public Object setValue(Object newVal)
{
Object r = value;
value = newVal;
return r;
}
public final String toString()
{
return key + "=" + value;
}
}
......@@ -60,8 +60,8 @@ import java.io.ObjectOutputStream;
* @author Jon Zeppieri
* @author Jochen Hoenicke
* @author Bryce McKinlay
* @version $Revision: 1.2 $
* @modified $Id: HashMap.java,v 1.2 2000/12/11 03:47:47 bryce Exp $
* @version $Revision: 1.3 $
* @modified $Id: HashMap.java,v 1.3 2000/12/17 09:15:51 bryce Exp $
*/
public class HashMap extends AbstractMap
implements Map, Cloneable, Serializable
......@@ -69,7 +69,7 @@ public class HashMap extends AbstractMap
/** Default number of buckets. This is the value the JDK 1.3 uses. Some
* early documentation specified this value as 101. That is incorrect. */
private static final int DEFAULT_CAPACITY = 11;
/** The defaulty load factor; this is explicitly specified by Sun */
/** The defaulty load factor; this is explicitly specified by the spec. */
private static final float DEFAULT_LOAD_FACTOR = 0.75f;
private static final long serialVersionUID = 362498820763181265L;
......@@ -104,56 +104,14 @@ public class HashMap extends AbstractMap
* Class to represent an entry in the hash table. Holds a single key-value
* pair.
*/
static class Entry implements Map.Entry
static class Entry extends BasicMapEntry
{
Object key;
Object value;
Entry next;
Entry(Object key, Object value)
{
this.key = key;
this.value = value;
super(key, value);
}
public boolean equals(Object o)
{
if (!(o instanceof Map.Entry))
return false;
Map.Entry e = (Map.Entry) o;
return (key == null ? e.getKey() == null : key.equals(e.getKey())
&& value == null ? e.getValue() == null :
value.equals(e.getValue()));
}
public Object getKey()
{
return key;
}
public Object getValue()
{
return value;
}
public int hashCode()
{
int kc = (key == null ? 0 : key.hashCode());
int vc = (value == null ? 0 : value.hashCode());
return kc ^ vc;
}
public Object setValue(Object newVal)
{
Object r = value;
value = newVal;
return r;
}
public String toString()
{
return key + "=" + value;
}
}
/**
......@@ -368,9 +326,9 @@ public class HashMap extends AbstractMap
{
Map.Entry e = (Map.Entry) itr.next();
// Optimize in case the Entry is one of our own.
if (e instanceof Entry)
if (e instanceof BasicMapEntry)
{
Entry entry = (Entry) e;
BasicMapEntry entry = (BasicMapEntry) e;
put(entry.key, entry.value);
}
else
......@@ -660,8 +618,8 @@ public class HashMap extends AbstractMap
* as per the Javasoft spec.
*
* @author Jon Zeppieri
* @version $Revision: 1.2 $
* @modified $Id: HashMap.java,v 1.2 2000/12/11 03:47:47 bryce Exp $
* @version $Revision: 1.3 $
* @modified $Id: HashMap.java,v 1.3 2000/12/17 09:15:51 bryce Exp $
*/
class HashIterator implements Iterator
{
......
......@@ -64,8 +64,8 @@ import java.io.ObjectOutputStream;
* @author Jon Zeppieri
* @author Warren Levy
* @author Bryce McKinlay
* @version $Revision: 1.8 $
* @modified $Id: Hashtable.java,v 1.8 2000/12/11 04:54:55 bryce Exp $
* @version $Revision: 1.9 $
* @modified $Id: Hashtable.java,v 1.9 2000/12/17 09:15:51 bryce Exp $
*/
public class Hashtable extends Dictionary
implements Map, Cloneable, Serializable
......@@ -73,7 +73,7 @@ public class Hashtable extends Dictionary
/** Default number of buckets. This is the value the JDK 1.3 uses. Some
* early documentation specified this value as 101. That is incorrect. */
private static final int DEFAULT_CAPACITY = 11;
/** The defaulty load factor; this is explicitly specified by Sun */
/** The defaulty load factor; this is explicitly specified by the spec. */
private static final float DEFAULT_LOAD_FACTOR = 0.75f;
private static final long serialVersionUID = 1421746759512286392L;
......@@ -93,7 +93,7 @@ public class Hashtable extends Dictionary
/**
* Array containing the actual key-value mappings
*/
transient HashMap.Entry[] buckets;
transient Entry[] buckets;
/**
* counts the number of modifications this Hashtable has undergone, used
......@@ -109,14 +109,16 @@ public class Hashtable extends Dictionary
* pair. A Hashtable Entry is identical to a HashMap Entry, except that
* `null' is not allowed for keys and values.
*/
static class Entry extends HashMap.Entry
static class Entry extends BasicMapEntry
{
Entry next;
Entry(Object key, Object value)
{
super(key, value);
}
public Object setValue(Object newVal)
public final Object setValue(Object newVal)
{
if (newVal == null)
throw new NullPointerException();
......@@ -195,7 +197,6 @@ public class Hashtable extends Dictionary
return size == 0;
}
/** */
public synchronized Enumeration keys()
{
return new Enumerator(Enumerator.KEYS);
......@@ -222,7 +223,7 @@ public class Hashtable extends Dictionary
{
for (int i = 0; i < buckets.length; i++)
{
HashMap.Entry e = buckets[i];
Entry e = buckets[i];
while (e != null)
{
if (value.equals(e.value))
......@@ -255,7 +256,7 @@ public class Hashtable extends Dictionary
public synchronized boolean containsKey(Object key)
{
int idx = hash(key);
HashMap.Entry e = buckets[idx];
Entry e = buckets[idx];
while (e != null)
{
if (key.equals(e.key))
......@@ -274,7 +275,7 @@ public class Hashtable extends Dictionary
public synchronized Object get(Object key)
{
int idx = hash(key);
HashMap.Entry e = buckets[idx];
Entry e = buckets[idx];
while (e != null)
{
if (key.equals(e.key))
......@@ -294,7 +295,7 @@ public class Hashtable extends Dictionary
{
modCount++;
int idx = hash(key);
HashMap.Entry e = buckets[idx];
Entry e = buckets[idx];
// Hashtable does not accept null values. This method doesn't dereference
// `value' anywhere, so check for it explicitly.
......@@ -342,8 +343,8 @@ public class Hashtable extends Dictionary
{
modCount++;
int idx = hash(key);
HashMap.Entry e = buckets[idx];
HashMap.Entry last = null;
Entry e = buckets[idx];
Entry last = null;
while (e != null)
{
......@@ -371,9 +372,9 @@ public class Hashtable extends Dictionary
{
Map.Entry e = (Map.Entry) itr.next();
// Optimize in case the Entry is one of our own.
if (e instanceof Entry)
if (e instanceof BasicMapEntry)
{
Entry entry = (Entry) e;
BasicMapEntry entry = (BasicMapEntry) e;
put(entry.key, entry.value);
}
else
......@@ -411,8 +412,8 @@ public class Hashtable extends Dictionary
for (int i=0; i < buckets.length; i++)
{
HashMap.Entry e = buckets[i];
HashMap.Entry last = null;
Entry e = buckets[i];
Entry last = null;
while (e != null)
{
......@@ -536,7 +537,7 @@ public class Hashtable extends Dictionary
if (!(o instanceof Map.Entry))
return false;
Map.Entry me = (Map.Entry) o;
HashMap.Entry e = getEntry(me);
Entry e = getEntry(me);
return (e != null);
}
......@@ -545,7 +546,7 @@ public class Hashtable extends Dictionary
if (!(o instanceof Map.Entry))
return false;
Map.Entry me = (Map.Entry) o;
HashMap.Entry e = getEntry(me);
Entry e = getEntry(me);
if (e != null)
{
Hashtable.this.remove(e.key);
......@@ -609,10 +610,10 @@ public class Hashtable extends Dictionary
return Math.abs(key.hashCode() % buckets.length);
}
private HashMap.Entry getEntry(Map.Entry me)
private Entry getEntry(Map.Entry me)
{
int idx = hash(me.getKey());
HashMap.Entry e = buckets[idx];
Entry e = buckets[idx];
while (e != null)
{
if (e.equals(me))
......@@ -630,7 +631,7 @@ public class Hashtable extends Dictionary
*/
protected void rehash()
{
HashMap.Entry[] oldBuckets = buckets;
Entry[] oldBuckets = buckets;
int newcapacity = (buckets.length * 2) + 1;
threshold = (int) (newcapacity * loadFactor);
......@@ -638,11 +639,11 @@ public class Hashtable extends Dictionary
for (int i = 0; i < oldBuckets.length; i++)
{
HashMap.Entry e = oldBuckets[i];
Entry e = oldBuckets[i];
while (e != null)
{
int idx = hash(e.key);
HashMap.Entry dest = buckets[idx];
Entry dest = buckets[idx];
if (dest != null)
{
......@@ -655,7 +656,7 @@ public class Hashtable extends Dictionary
buckets[idx] = e;
}
HashMap.Entry next = e.next;
Entry next = e.next;
e.next = null;
e = next;
}
......@@ -720,8 +721,8 @@ public class Hashtable extends Dictionary
* as per the Javasoft spec.
*
* @author Jon Zeppieri
* @version $Revision: 1.8 $
* @modified $Id: Hashtable.java,v 1.8 2000/12/11 04:54:55 bryce Exp $
* @version $Revision: 1.9 $
* @modified $Id: Hashtable.java,v 1.9 2000/12/17 09:15:51 bryce Exp $
*/
class HashIterator implements Iterator
{
......@@ -739,11 +740,11 @@ public class Hashtable extends Dictionary
// Current index in the physical hash table.
int idx;
// The last Entry returned by a next() call.
HashMap.Entry last;
Entry last;
// The next entry that should be returned by next(). It is set to something
// if we're iterating through a bucket that contains multiple linked
// entries. It is null if next() needs to find a new bucket.
HashMap.Entry next;
Entry next;
/* Construct a new HashIterator with the supplied type:
KEYS, VALUES, or ENTRIES */
......@@ -771,7 +772,7 @@ public class Hashtable extends Dictionary
if (count == size)
throw new NoSuchElementException();
count++;
HashMap.Entry e = null;
Entry e = null;
if (next != null)
e = next;
......@@ -825,8 +826,8 @@ public class Hashtable extends Dictionary
* hashtable during enumeration causes indeterminate results. Don't do it!
*
* @author Jon Zeppieri
* @version $Revision: 1.8 $
* @modified $Id: Hashtable.java,v 1.8 2000/12/11 04:54:55 bryce Exp $ */
* @version $Revision: 1.9 $
* @modified $Id: Hashtable.java,v 1.9 2000/12/17 09:15:51 bryce Exp $ */
class Enumerator implements Enumeration
{
static final int KEYS = 0;
......@@ -839,7 +840,7 @@ public class Hashtable extends Dictionary
// current index in the physical hash table.
int idx;
// the last Entry returned.
HashMap.Entry last;
Entry last;
Enumerator(int type)
{
......@@ -858,7 +859,7 @@ public class Hashtable extends Dictionary
if (count >= size)
throw new NoSuchElementException();
count++;
HashMap.Entry e = null;
Entry e = null;
if (last != null)
e = last.next;
......
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