[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in GNU Classpath LinkedList implementation
From: |
Stuart Ballard |
Subject: |
Re: bug in GNU Classpath LinkedList implementation |
Date: |
Fri, 01 Dec 2000 16:46:42 -0500 |
Adam Welc wrote:
>
> Hi,
> I am currently working on the implementation of the open source Java
> Virtual Machine and we are using GNU Classpath libraries. I am using
> LinkedList.class as a queue and I found a bug in the implementation of
> methods providing this functionality - removeLast() and removeFirst().
> The problem is that the values of "last" and "first" variables
> (respectively) are not updated. Corrrected code is given below (added
> lines are ended with // ADDED):
I am forwarding this message to the Classpath list (address@hidden).
Since I last touched the code, LinkedList has been completely rewritten;
I don't know the new code at all. Could whoever it was that did this
rewrite (Tom?) take a look at these changes and reply to Adam?
Thanks,
Stuart.
>
> public Object removeFirst()
> {
> if (size == 0)
> throw new NoSuchElementException();
> size--;
> modCount++;
> Object r = first.data;
>
> if (first.next != null)
> first.next.previous = null;
>
> first = first.next; // ADDED
>
> return r;
> }
>
> public Object removeLast()
> {
> if (size == 0)
> throw new NoSuchElementException();
> size--;
> modCount++;
> Object r = last.data;
>
> if (last.previous != null)
> last.previous.next = null;
>
> last = last.previous; // ADDED
>
> return r;
> }
>
> Sincerely
>
> Adam Welc
>
> --
> Adam Welc
> Computer Science Building, room 274
> West Lafayette, IN 47906
> Telephone number (work): (765) 4947836
>
> http:// www.cs.purdue.edu/homes/welc
- Re: bug in GNU Classpath LinkedList implementation,
Stuart Ballard <=