This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

annoying problems with sets

 
Matthew Fyffe
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey, I didn't want to ask here for help but this problem is driving me insane. Here's my code:


The code works perfectly except for one gigantic problem; the time is not removed. The program finds the two lines that are equal to one another and then goes to remove the found line but reports that it was not there, even though it just found that very line. How could that be?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Donno what's happening, but maybe you should look into Iterator.remove instead of Set.remove. Here's a quote from the Iterator.remove doc. The last sentence is a bit scary.

Removes from the underlying collection the last element returned by the iterator (optional operation). This method can be called only once per call to next. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method.
 
Matthew Fyffe
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah yep, seems you were right. Silly me, I thought that only ListIterator had a remove method and thus, went the route I did :-\. Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic