1 package com.daffodilwoods.daffodildb.server.datasystem.persistentsystem; 2 3 import java.util.Comparator ; 4 import com.daffodilwoods.database.resource.DException; 5 import com.daffodilwoods.database.utility.P; 6 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference; 7 8 9 14 public class ClusterCharacteristics implements Comparable ,Comparator { 15 16 19 private int startAddress; 20 21 24 boolean isBtreeCluster; 25 28 private int hashCode; 29 30 31 public ClusterCharacteristics(int startAddress0, boolean isBtreeCluster0) { 32 startAddress = startAddress0; 33 isBtreeCluster = isBtreeCluster0; 34 long value = startAddress*11; 35 hashCode = (int)(value ^ (value >> 32)); 36 } 37 38 public int hashCode() { 39 return hashCode; 40 } 41 45 public void setStartAddress(int add) { 46 startAddress = add; 47 } 48 56 public boolean equals(Object object) { 57 try { 58 ClusterCharacteristics cc = (ClusterCharacteristics) object; 59 return cc.startAddress == startAddress; 60 } 61 catch (ClassCastException ex) { 62 return false; 63 } 64 } 65 78 public int compareTo(Object key1) { 79 int diff = startAddress-((ClusterCharacteristics)key1).startAddress; 80 int cmp = diff < 0 ? -1 : diff > 0 ? 1 : 0; 81 return cmp; 82 } 83 98 99 public int compare(Object o1, Object o2) { 100 int diff = (((ClusterCharacteristics)o1).startAddress-((ClusterCharacteristics)o2).startAddress); 101 int cmp = diff < 0 ? -1 : diff > 0 ? 1 : 0; 102 return cmp; 103 } 104 105 109 110 public int getStartAddress(){ 111 return startAddress; 112 } 113 114 public String toString() { 115 return "["+startAddress+"] --- ["+hashCode+"]"; 116 } 117 } 118 | Popular Tags |