38 |
|
* tie-breaking to comparable elements. To use it, you would insert a |
39 |
|
* <tt>new FIFOEntry(anEntry)</tt> instead of a plain entry object. |
40 |
|
* |
41 |
< |
* <pre> |
42 |
< |
* class FIFOEntry<E extends Comparable<? super E>> |
43 |
< |
* implements Comparable<FIFOEntry<E>> { |
41 |
> |
* <pre> {@code |
42 |
> |
* class FIFOEntry<E extends Comparable<? super E>> |
43 |
> |
* implements Comparable<FIFOEntry<E>> { |
44 |
|
* final static AtomicLong seq = new AtomicLong(); |
45 |
|
* final long seqNum; |
46 |
|
* final E entry; |
49 |
|
* this.entry = entry; |
50 |
|
* } |
51 |
|
* public E getEntry() { return entry; } |
52 |
< |
* public int compareTo(FIFOEntry<E> other) { |
52 |
> |
* public int compareTo(FIFOEntry<E> other) { |
53 |
|
* int res = entry.compareTo(other.entry); |
54 |
< |
* if (res == 0 && other.entry != this.entry) |
55 |
< |
* res = (seqNum < other.seqNum ? -1 : 1); |
54 |
> |
* if (res == 0 && other.entry != this.entry) |
55 |
> |
* res = (seqNum < other.seqNum ? -1 : 1); |
56 |
|
* return res; |
57 |
|
* } |
58 |
< |
* }</pre> |
58 |
> |
* }}</pre> |
59 |
|
* |
60 |
|
* <p>This class is a member of the |
61 |
|
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> |