From 69f1024887b27cdd0989c56b90238ac4cfc0f123 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 14 Nov 2007 09:32:36 -0700 Subject: [PATCH] add missing classpath methods --- classpath/java/lang/Enum.java | 2 +- classpath/java/util/Arrays.java | 4 ++++ classpath/java/util/LinkedList.java | 9 ++++++++- classpath/java/util/List.java | 2 ++ classpath/java/util/Vector.java | 4 ++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/classpath/java/lang/Enum.java b/classpath/java/lang/Enum.java index 7d8ab4fc71..8c86db2e13 100644 --- a/classpath/java/lang/Enum.java +++ b/classpath/java/lang/Enum.java @@ -2,7 +2,7 @@ package java.lang; import java.lang.reflect.Method; -public abstract class Enum> { +public abstract class Enum> implements Comparable { private final String name; private final int ordinal; diff --git a/classpath/java/util/Arrays.java b/classpath/java/util/Arrays.java index 204c18548e..ce59ec22b1 100644 --- a/classpath/java/util/Arrays.java +++ b/classpath/java/util/Arrays.java @@ -42,6 +42,10 @@ public class Arrays { return array[index]; } + public T set(int index, T value) { + throw new UnsupportedOperationException(); + } + public S[] toArray(S[] a) { return (S[])array; } diff --git a/classpath/java/util/LinkedList.java b/classpath/java/util/LinkedList.java index a78c42fa24..7d98ef847c 100644 --- a/classpath/java/util/LinkedList.java +++ b/classpath/java/util/LinkedList.java @@ -114,7 +114,7 @@ public class LinkedList implements List { addFirst(element); } else { Cell cell = find(index); - Cell newCell = new Cell(element, cell.prev, cell); + Cell newCell = new Cell(element, cell.prev, cell); cell.prev.next = newCell; } } @@ -131,6 +131,13 @@ public class LinkedList implements List { return find(index).value; } + public T set(int index, T value) { + Cell c = find(index); + T old = c.value; + c.value = value; + return old; + } + public T getFirst() { if (front != null) { return front.value; diff --git a/classpath/java/util/List.java b/classpath/java/util/List.java index 0c679415a8..40de8330cd 100644 --- a/classpath/java/util/List.java +++ b/classpath/java/util/List.java @@ -3,6 +3,8 @@ package java.util; public interface List extends Collection { public T get(int index); + public T set(int index, T value); + public T remove(int index); public boolean add(T element); diff --git a/classpath/java/util/Vector.java b/classpath/java/util/Vector.java index 6f3dfb1973..8b8a9970ab 100644 --- a/classpath/java/util/Vector.java +++ b/classpath/java/util/Vector.java @@ -42,6 +42,10 @@ public class Vector implements List { return list.get(index); } + public synchronized T set(int index, T value) { + return list.set(index, value); + } + public T elementAt(int index) { return get(index); }