You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jeff Varszegi <jv...@yahoo.com> on 2002/11/15 17:23:03 UTC

[collections][SUBMIT]A faster linked list

NodeCachingLinkedList is identical to LinkedList except in that it maintains an internal node
cache so it doesn't have to create new ones as often.

Jeff


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

Re: [collections] Trying to test the linked list, a question

Posted by Jeff Varszegi <jv...@yahoo.com>.
I was just wondering if you happened to look at the speed improvements I suggested for
FastArrayList.  I know you're busy, just wondering.  If it's not seen as important I won't
continue on with my plan of performance-tuning some of the other classes in Collections.  (That's
not a huffy statement, but sincere-- I don't want to waste everyone's time, and I'd rather help
out in a valuable way.)  I just like to tinker with things to make them fast, and I thought maybe
I could have a good impact on a few projects at once by speeding up some of the Collections
classes that are reused.

Jeff

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections] Trying to test the linked list, a question

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Jeff Varszegi" <jv...@yahoo.com>
> I looked all through the script of my class and I can't find anywhere it
can construct a blank
> string.  I also couldn't find anything wrong in general; I checked over
the logic pretty well, but
> I guess it's always possible to miss something.  Can anyone help me?

TestCollection.getFullNonNullElements() contains the values that are
failing. At some point they get added to a reference collection (ArrayList)
and your collection (NodeCachingLinkedList) - testList.makeFullList().

This uses addAll() to add and the testRemoveByIndex uses an iterator(). One
of those two must be failing. All I can suggest is following the path of the
data from the getFullNonNullElements() to the failure.

Stephen


> Jeff
>
> P.S.  I also attached the NodeCachingLinkedList class, latest version.  It
throws
> NoSuchElementException everywhere that it should. JKV
>
> --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > From: "Jeff Varszegi" <jv...@yahoo.com>
> > > Can you tell me more about the unit testing?
> > See the JUnit website if you've never used it before. However its easy
to
> > get to grips with.
> >
> > Collections uses JUnit with an abstract superclass. The superclass aims
to
> > test compliance with the List interface spec (for example), leaving the
> > individual test class to just test for the differences in that
particular
> > implementation. You'll need to have a look at some of the classes in the
> > test package to figure it out (as I wasn't involved with the test
structure
> > that was created) I believe that BulkTest is a significant class, but
don't
> > hold me to it ;-)
> >
> > Stephen
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[collections] Trying to test the linked list, a question

Posted by Jeff Varszegi <jv...@yahoo.com>.
All right, I have JUnit 3.8 installed.  I read all the documentation on it and compiled and ran
some simple tests, but I'm having a minor problem.

I made a class named TestNodeCachingLinkedList that extends TestList (I attached it).  It fails
twice with the same error, and I can't tell why it's happening.  I know you're busy, but if you
could look at it I'd be much obliged.  I don't know enough to tell if it's a fault in the test
script or not...

Here's the output of the script:

................F........................F.
.........................................
..................
Time: 0.3
There were 2 failures:
1) testListRemoveByIndex(TestNodeCachingLinkedList.testListRemoveByIndex)
junit.framework.AssertionFailedError: remove should return correct element expected:<null> but
was:<>
	at org.apache.commons.collections.TestList.testListRemoveByIndex(TestList.java:699)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at
org.apache.commons.collections.TestNodeCachingLinkedList.main(TestNodeCachingLinkedList.java:32)
2) testListRemoveByIndex(TestNodeCachingLinkedList.bulkTestSubList.testListRemoveByIndex)
junit.framework.AssertionFailedError: remove should return correct element expected:<null> but
was:<Three>
	at org.apache.commons.collections.TestList.testListRemoveByIndex(TestList.java:699)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at
org.apache.commons.collections.TestNodeCachingLinkedList.main(TestNodeCachingLinkedList.java:32)

FAILURES!!!
Tests run: 100,  Failures: 2,  Errors: 0


I looked all through the script of my class and I can't find anywhere it can construct a blank
string.  I also couldn't find anything wrong in general; I checked over the logic pretty well, but
I guess it's always possible to miss something.  Can anyone help me?

Jeff

P.S.  I also attached the NodeCachingLinkedList class, latest version.  It throws
NoSuchElementException everywhere that it should. JKV

--- Stephen Colebourne <sc...@btopenworld.com> wrote:
> From: "Jeff Varszegi" <jv...@yahoo.com>
> > Can you tell me more about the unit testing?
> See the JUnit website if you've never used it before. However its easy to
> get to grips with.
> 
> Collections uses JUnit with an abstract superclass. The superclass aims to
> test compliance with the List interface spec (for example), leaving the
> individual test class to just test for the differences in that particular
> implementation. You'll need to have a look at some of the classes in the
> test package to figure it out (as I wasn't involved with the test structure
> that was created) I believe that BulkTest is a significant class, but don't
> hold me to it ;-)
> 
> Stephen
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 



__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

Re: [collections][SUBMIT]A faster linked list

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Jeff Varszegi" <jv...@yahoo.com>
> Can you tell me more about the unit testing?
See the JUnit website if you've never used it before. However its easy to
get to grips with.

Collections uses JUnit with an abstract superclass. The superclass aims to
test compliance with the List interface spec (for example), leaving the
individual test class to just test for the differences in that particular
implementation. You'll need to have a look at some of the classes in the
test package to figure it out (as I wasn't involved with the test structure
that was created) I believe that BulkTest is a significant class, but don't
hold me to it ;-)

Stephen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections][SUBMIT]A faster linked list

Posted by Jeff Varszegi <jv...@yahoo.com>.
I think it can be used as a direct LL substitute now.  I don't agree that it needs to extend
LinkedList.  My reason is that someone would have to change at least one line of code, where the
thing is declared and/or allocated, anyway.  Also, if someone is using a LinkedList as a
LinkedList (instead of a List) they're doing things wrong anyway.  The main point of the
Collections API is the interfaces.  I dunno if that makes me a prig or a purist...  ;0)  I will
make a new version that extends LinkedList and see how I like it.

Actually, it looks like I lied earlier when I said that it was exactly like LinkedList except for
the node caching.  It looks like somewhere along the way I changed the contract of the getXXX
methods to stop throwing NoSuchElementException.  I agree that that should be changed back to
support better integration into existing code.

Can you tell me more about the unit testing?

Thanks,

Jeff

--- Stephen Colebourne <sc...@btopenworld.com> wrote:
> I am broadly in favour of this class. However,
> - I would like to see it extend LinkedList, so it can be used as a direct LL
> substitute
> - This then implies changes to the logic in certain methods (eg.getFirst(),
> getLast())
> - I would like to see unit tests (There is a structure for unit tests, that
> means that you need to write very little as the superclass of the test does
> all the work of comparing against the List spec.)
> 
> Stephen
> 
> ----- Original Message -----
> From: "Jeff Varszegi" <jv...@yahoo.com>
> To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>;
> <mi...@mikebryant.com>
> Sent: Friday, November 15, 2002 4:23 PM
> Subject: [collections][SUBMIT]A faster linked list
> 
> 
> > NodeCachingLinkedList is identical to LinkedList except in that it
> maintains an internal node
> > cache so it doesn't have to create new ones as often.
> >
> > Jeff
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Web Hosting - Let the expert host your site
> > http://webhosting.yahoo.com
> 
> 
> ----------------------------------------------------------------------------
> ----
> 
> 
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections][SUBMIT]A faster linked list

Posted by Stephen Colebourne <sc...@btopenworld.com>.
I am broadly in favour of this class. However,
- I would like to see it extend LinkedList, so it can be used as a direct LL
substitute
- This then implies changes to the logic in certain methods (eg.getFirst(),
getLast())
- I would like to see unit tests (There is a structure for unit tests, that
means that you need to write very little as the superclass of the test does
all the work of comparing against the List spec.)

Stephen

----- Original Message -----
From: "Jeff Varszegi" <jv...@yahoo.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>;
<mi...@mikebryant.com>
Sent: Friday, November 15, 2002 4:23 PM
Subject: [collections][SUBMIT]A faster linked list


> NodeCachingLinkedList is identical to LinkedList except in that it
maintains an internal node
> cache so it doesn't have to create new ones as often.
>
> Jeff
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>