TreeSet problem: last() returns with NoSuchElementException
I have a small problem using TreeSet.
I am using a TreeSet with a comparator. While I have debugged my application I found that I have some elements in this set but I got a NoSuchElementException when I try to get the last element.
SortedSet<TimeBarSection> elementsBefore = sections.headSet(section);
return elementsBefore.isEmpty() ? null : elementsBefore.last();
where sections is the TreeSet I mnetioned above.
Thank you for your comments.
I found a solution (workaround?!):
TreeSet<TimeBarSection> elementsBefore = new TreeSet<TimeBarSection>(TimeBarSection.BY_START_COMPARATOR);
In this case I could see the whole structutre of the tree (root, left, right,...).
Does anyone have any idea why it works in this way?
By Michael in forum ASP.NET
Last Post: 02-24-2006, 08:54 AM
By aesoprock00 in forum Java
Last Post: 01-28-2006, 06:18 PM
By JohnsonGPS in forum C++
Last Post: 11-16-2005, 06:15 PM
Last Post: 12-13-2001, 12:06 PM
By Wade Balzer in forum VB Classic
Last Post: 06-23-2000, 02:17 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center