Link to home
Start Free TrialLog in
Avatar of DrewAllan
DrewAllan

asked on

How to use a nested TreeMap

Hi,

I have data in the following form: Library Case Study example

String borrower, Object loanstate, Object loanitem.

I have many borrowers, loanstate is either borrowed or returned and the loanitem
would be say a bookitem.

What I would like to do is output in the form:

Borrower:      Borrowed       Book1
                              Book2
                              Book3
                              ..etc
               Returned       Book1
                              Book3

I thought maybe a nested TreeMap would allow me to do this i.e.

Key, (key, value)

borrower (loanstate, loanitem) would allow me to do this.

Any suggestions on how to code this up ?

Thanks

Drew
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DrewAllan
DrewAllan

ASKER

Can you give me an example of how to code it ?

Thanks
Sorry - no. This is clearly class work and as such, it's against the Member Agreement to do this. We can certainly help with code you have already produced.
Ok I can appreciate that but it was more an example of how to constuct it I was after.

How me suggesting an example of how to construct the Nested TreeMap

would it be

Map(index,[indexOuter,[[indexInner1, [value1, value2,... ],[indexInner22, [value22, value23,... ], [indexInner3, [value31, value32,... ],[indexInner4, [value42, value43,... ]..etc])

where index would be string object called Borrower and the outer nest value [index,[values]] would be say an ArrayList and then the inner nest values would be another ArrayList.

Do you think this would work or would there be a better way of doing it?