this sounds hugely dangerous - the javadocs for List#equals(Object) for
example stipulate:
Compares the specified object with this list for equality. Returns true if
and only if the specified object is also a list, both lists have the same
size, and all corresponding pairs of elements in the two lists are equal.
(Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).)
In other words, two lists are defined to be equal if they contain the same
elements in the same order. This definition ensures that the equals method
works properly across different implementations of the List interface.
You do have a point. Then how about this?
class Singleton implements List {
}ResetableIterator i = new Singleton ("hello, world").iterator ();
ListIterator li = new Singleton ("hello, world").listIterator ();
ListIterator li = new Singleton ("hello, world").listIterator (10);To me, this solution sounds good. There is no tricky choice whether SingletonIterator or SingletonListIterator. And we can avoid a big xxxUtil classes instead of small objects and classes, resembling traditional imperative languages such as C.
I am not sure if it is valid with the contract of interfaces to implement both Set and List because ListIterator doesn't make sense with listIterator but it doesn't look elegant to have two SingletonList and SingletonSet classes.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
