commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: [COLLECTIONS] Some more lobbying for the OrderedSet class
Date Tue, 29 Apr 2003 19:57:56 GMT

I am working on a project for which I had a need for a specialized type of
collection that would support the following features:
- Elements stored in the collection are ordered
  (cardinal order, similar to List)
- Element duplicates are typically not accepted
  (although in some cases, it might make sense to have duplicates)
- In addition to their cardinal orders, elements can be searched by their
name property
  (in my case, element names are unique, but it is plausible that in some
cases, two distinct elements might have the same name, i.e. a Person)

I have dug through the Java Collections API as well as the Jakarta Commons
Collection library, but I did not find a single class that does what I want.

Basically, I need to keep two arrays in sync, one, which has the list of
names and the other which has the actual objects. This way, I can access an
object directly by its index, through the object array - or - I can search
for a name (String) in the name array and use the resulting index to return
the object from the object array.

In any case, I went ahead and created an implementation that fits my
particular needs. I believe it is a genuinely useful and reusable
implementation and I would like to contribute it to the Jakarta Commons
project, quite possibly to be integrated into the Collections project.
Certainly, the idea is not new and it sounds like the List/Set combination
mentioned in the message below, but my implementation is somewhat different.

What I have so far is a small, stand-alone project, which includes:
- 3 java source files (java/src) for the solution implementation (1 class
and 2 interfaces, with full javadoc comments)
- 7 java source files (java/test) for the junit test cases, 5 of which are
directly taken from the Commons Collections project (BulkTest, TestAll,
TestCollection, TestList and TestObject).
- A build.xml file which is basically a subset of the Commons Collections
Ant build file

Basically, I have one class, called Catalog, which implements a custom
extension of the List interface.

The Catalog class successfully completes all the test cases from (it implements an interface which itself extends the List
interface), however I have not yet defined test cases for the specialized
methods of the custom interface.

Do you have any interest for this code, and if so, what should I do? Can I
post it to this list?


Eric Trepanier

-----Original Message-----
Sent: April 29, 2003 1:39 PM
Subject: Re: [COLLECTIONS] Some more lobbying for the OrderedSet class

I strongly agree that a ListSet interface that extends both List and Set is
the most intuitive way to go.  "List" and "Set" are understood by Java
developers anywhere and to have a "ListSet" interface would make it very
clear what it means.

Eric Pabst

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message