# commons-user mailing list archives

##### Site index · List index
Message view
Top
From "rinke hoekstra" <rin...@home.nl>
Subject Re: [commons-collections]: how to do reverse iteration in TreeBidiMap
Date Wed, 30 Mar 2005 12:59:13 GMT
```On 30 Mar 2005 at 14:25, José Antonio Pérez Testa wrote:

> Maybe I am confused, but the inverseMap is not ordered in inverse order??
> In that case greatest value is first ant lowest is last.
>

No, that is not the case (sorry for not explaining clear enough).

The inverse map is switching keys and values.

So when the original map has ("1", "one"), the inversed map has ("one", "1").

I'm getting the reversed map because I want to order on values. But I also want the
greatest value first, in stead of last.

Rinke

> rinke hoekstra wrote:
>
> >Hi list,
> >
> >maybe a stupid question, or maybe I am missing something, but I cannot sort out how
to
> >do a reverse iteration over the values of a TreeBidiMap, and couldn't find much about
it
> >on the web.
> >I want to retrieve the 10 greatest values from a HashMap, and thought it best to
use a
> >TreeBidiMap for it.
> >
> >I have this:
> >
> >TreeBidiMap bidiMap = new TreeBidiMap(myHashMap);
> >OrderedBidiMap invMap = bidiMap.inverseOrderedBidiMap(); //creates inversed map
> >OrderedMapIterator oit = invMap.orderedMapIterator();
> >while (oit.hasPrevious()) {
> >      Float value = (Float)oit.previous();
> >      .....
> >}
> >
> >
> >The iterator however seems to be initialized at the first element, so hasPrevious()
is
> >usually false, and the loop isn't run.
> >
> >How to initialize the iterator at the last element, so you can start iterating using

> >hasPrevious()?
> >
> >thanks,
> >Rinke
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> >
>
> --
>
> José Antonio Pérez Testa
> Ingeniería de Servicios e Innovación técnologica.
>
> Telémaco 3
> Tel: +34-91-480.81.12
>
> japtesta@indra.es
> www.indra.es
>
>
> ---------------------------------------------------------------------
> 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