This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
No, I don't think so. I think you're pretty stuck there without writing your own Map-like structure. Generic restrictions are designed to apply to all objects in the collection, whereas you want to have the restriction depend on the position in the collection.
You could always write your own wrapper class. I'm not sure how complicated it would get, but it would start off something like this:
Whether that's worth the trouble, I'm unsure.
Joined: Feb 23, 2009
thanks for your reply ...
the structure is fully encapsulated so there is no real problem. i just figured it would be a nicer way to do it like that :-)