View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic.turbo.lru;
15  
16  public class T_Entry<K> implements Comparable<T_Entry<?>> {
17  
18      K k;
19      long sequenceNumber;
20  
21      T_Entry(K k, long sn) {
22          this.k = k;
23          this.sequenceNumber = sn;
24      }
25  
26      public int compareTo(T_Entry<?> o) {
27          if (!(o instanceof T_Entry)) {
28              throw new IllegalArgumentException("arguments must be of type " + T_Entry.class);
29          }
30  
31          T_Entry<?> other = o;
32          if (sequenceNumber > other.sequenceNumber) {
33              return 1;
34          }
35          if (sequenceNumber == other.sequenceNumber) {
36              return 0;
37          }
38          return -1;
39      }
40  
41      @Override
42      public String toString() {
43          return "(" + k + "," + sequenceNumber + ")";
44          // return "("+k+")";
45      }
46  }