You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2006/03/02 19:11:11 UTC
Re: [Collections] Facing Design Issue
Think about what is most important, then next important and so on.
It seems that time is most important to you.
Then the grouping by id.
But its not clear what kind of qery you will make
There doesn't seem to be one collection that will fit.
Try looking at
- MultiHashMap to hold a list of objects against a single key
- MultiKeyMap to use multiple keys to lookup a single value
- MultiKey or an array to hold multiple objects as one object
- TreeMap to keep the keys sorted
Stephen
Rajat Sharma wrote:
> Hi,
>
> I have the following strings....which are currently in an arraylist.
>
> Instance Date Time Var-1 Var-2
> 65793 02/24/2006 00:00:00 1 1
> 66049 02/24/2006 00:00:00 1 1
> 66305 02/24/2006 00:00:00 0 0
> 66561 02/24/2006 00:00:00 1 3
> 66817 02/24/2006 00:00:00 7 4
> 67073 02/24/2006 00:00:00 0 0
> 67329 02/24/2006 00:00:00 9 16
> 68353 02/24/2006 00:00:00 1 1
> 66817 02/24/2006 00:02:30 2 2
> 67073 02/24/2006 00:02:30 0 0
> 67329 02/24/2006 00:02:30 9 9
> 68353 02/24/2006 00:02:30 1 1
> 68609 02/24/2006 00:02:30 7 7
> 68865 02/24/2006 00:02:30 0 0
> 69121 02/24/2006 00:02:30 0 0
> 69377 02/24/2006 00:02:30 1 1
> 69633 02/24/2006 00:02:30 0 0
> 65793 02/24/2006 00:03:00 1 0
>
> One thing unique in the above table is the time on a per instance basis. Var-1, and Var-2 are the attributes of the instance at any given time.
>
> What I need is a very clean way to wrap these under collections framework,
>
> a) Such that all the instances having the same ID are in their own Collections
> b) Most importantly, I could sort them with time.
>
> So all the unique instances help create separate tables each having the same ID, which can then be sorted on Date\Time such that sub-lists could be created which fall under the range of time given.
>
> I am almost a beginner in collections and don't know if this is possible. Please note that, the above is not simly key-pair values but key-value-value....
>
> Could someone help me.
>
> Regards,
> Raj
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org