title: compareTo and equals in PriorityQueues
body: <p>i'm a little confused with all the "If the ordering imposed by c on S is inconsistent with equals, the sorted set (or sorted map) will behave strangely." warnings in the Javadoc.
  I'm not even sure anymore a PriorityQueue is what i need...</p>
  
  <p>My situation is this:
  I have a class Event with an integer timestamp and some other fields.
  I'm looking for a datastructure, in which I can insert these events and which sorts the events by timestamp.
  Different events can have the same timestamp, so - if I understand correctly - compareTo and equals would be inconsistent.</p>
  
  <p>My first approach was to let the Event implement Comparable and provide compareTo like this:
  public int compareTo(Event e) {
    return this.timestamp - e.getTimestamp();
  }</p>
  
  <p>I don't understand how I'm supposed to solve this. I thought about creating a custom Comparator, but the same warning about strange behaviour pops up in the Comparator's javadoc as well.
  I don' want to insert multiple equal instances of an event, i just want them to be sorted by timestamp.</p>
  
  <p>Thanks in advance for your help :)</p>
  
  <p>Edit:<br>
  I just want the Events to be sorted by timestamp. It could very well be, that two different events have the same timestamp. So compareTo would return 0, because they have the same timestamp and are equal for the purpose of sorting. But equals() would not return true, because they are different events.<br>
  I'm not sure, a PriorityQueue is the right thing to use. I looked at SortedSet, but it had the same warnings about the consistency of compareTo and equals.<br>
  Maybe I'm tackling this from the wrong angle, I don't know...</p>