By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

why no bidirectional iterator exists for sets?

P: n/a
It seems very short sighted and silly that the bidirectional capabilities
of ListIterator have not been implemented for collections based upon sets,
but only those based upon lists.

I need reverse iteration for TreeSet!!!!

My algorithm searches the sorted set and looks for clustering of values.
Implementing this with only a forward iterator is a ridiculous amount of
extra work.

-Wiseguy

Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
nos

"Wiseguy" <no***@celeron.local> wrote in message news:40********@127.0.0.1...
It seems very short sighted and silly that the bidirectional capabilities
of ListIterator have not been implemented for collections based upon sets,
but only those based upon lists.

I need reverse iteration for TreeSet!!!!

My algorithm searches the sorted set and looks for clustering of values.
Implementing this with only a forward iterator is a ridiculous amount of
extra work.

-Wiseguy


So who's going to hire you then.
Jul 17 '05 #2

P: n/a
> "Wiseguy" <no***@celeron.local> wrote in message =
news:40********@127.0.0.1...
It seems very short sighted and silly that the bidirectional =

capabilities
of ListIterator have not been implemented for collections based upon =

sets,
but only those based upon lists.
=20
I need reverse iteration for TreeSet!!!!
=20
My algorithm searches the sorted set and looks for clustering of =

values.
Implementing this with only a forward iterator is a ridiculous amount =

of=20
extra work.
=20
-Wiseguy
=20


So who's going to hire you then.


I guess it's just another example of how C++ kicks JAVAs ass when it
comes to real algorithmic tasks. In fact, the only redeeming quality
of JAVA is Swing, and I will admit that Swing is quite a powerful redeemer...

Maybe it was a scent induced memory that surfaced the other day, but all
of the sudden while debugging a class I had this tremendous flashback/deja-vu
of the old days when I was playing in TRS-80 BASIC. You know before I got my
first real C compiler and learned to write real code. Every stinkin time
I attempt to do real tasks with JAVA its toy-like nature comes shining thru.

BTW: original problem solved...in typical (innefficient) java style I had to
go thru the overhead of translating the set to an array and then used
indexes to emulate the iterators...what bunch of crap this language is?!

-Wiseguy

PS: please don't post followups in HTML

Jul 17 '05 #3

P: n/a
nos

"Wiseguy" <no***@celeron.local> wrote in message
news:40********@127.0.0.1...
"Wiseguy" <no***@celeron.local> wrote in message =
news:40********@127.0.0.1...
It seems very short sighted and silly that the bidirectional = capabilities
of ListIterator have not been implemented for collections based upon =

sets,
but only those based upon lists.
=20
I need reverse iteration for TreeSet!!!!
=20
My algorithm searches the sorted set and looks for clustering of =

values.
Implementing this with only a forward iterator is a ridiculous amount =

of=20
extra work.
=20
-Wiseguy
=20


So who's going to hire you then.


I guess it's just another example of how C++ kicks JAVAs ass when it
comes to real algorithmic tasks. In fact, the only redeeming quality
of JAVA is Swing, and I will admit that Swing is quite a powerful

redeemer...
Maybe it was a scent induced memory that surfaced the other day, but all
of the sudden while debugging a class I had this tremendous flashback/deja-vu of the old days when I was playing in TRS-80 BASIC. You know before I got my first real C compiler and learned to write real code. Every stinkin time
I attempt to do real tasks with JAVA its toy-like nature comes shining thru.
BTW: original problem solved...in typical (innefficient) java style I had to go thru the overhead of translating the set to an array and then used
indexes to emulate the iterators...what bunch of crap this language is?!
So how come you still use it? Can't figure out how not to?

-Wiseguy

PS: please don't post followups in HTML

Jul 17 '05 #4

P: n/a

"Wiseguy" <no***@celeron.local> wrote in message
news:40********@127.0.0.1...
It seems very short sighted and silly that the bidirectional capabilities
of ListIterator have not been implemented for collections based upon sets,
but only those based upon lists.

I need reverse iteration for TreeSet!!!!

My algorithm searches the sorted set and looks for clustering of values.
Implementing this with only a forward iterator is a ridiculous amount of
extra work.
It would not if you thought some more. Iterating a tree is very inefficient.
Unless you do it recursively and perform actions inside the recursion each
move to the next position of the iterator takes log2(N) time. Using
iterators on a tree is not very smart, overusing them by wanting to step
back for such a trivial thing is even less smart.

Silvio Bierman

-Wiseguy

Jul 17 '05 #5

P: n/a
Wiseguy wrote:
It seems very short sighted and silly that the bidirectional capabilities
of ListIterator have not been implemented for collections based upon sets,
but only those based upon lists.

<snip>

I think they thought that, since a set is by definition unordered, and
as it says, "The elements are returned in no particular order (unless
this set is an instance of some class that provides a guarantee)."

But since TreeSet is a "class that provides a guarantee", I can see
where you're going. Maybe Sun'll get around to inventing
SortedSetIterator (fitting in the hierarchy between Iterator and
ListIterator) sometime. You go and suggest it to them.

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.
Jul 17 '05 #6

P: n/a
ignor this message - just testing reply to group
"Stewart Gordon" <sm*******@yahoo.com> wrote in message
news:c2**********@sun-cc204.lut.ac.uk...
Wiseguy wrote:
It seems very short sighted and silly that the bidirectional capabilities of ListIterator have not been implemented for collections based upon sets, but only those based upon lists.

<snip>

I think they thought that, since a set is by definition unordered, and
as it says, "The elements are returned in no particular order (unless
this set is an instance of some class that provides a guarantee)."

But since TreeSet is a "class that provides a guarantee", I can see
where you're going. Maybe Sun'll get around to inventing
SortedSetIterator (fitting in the hierarchy between Iterator and
ListIterator) sometime. You go and suggest it to them.

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.