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
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL