001package cnslab.cnsmath;
002public class KCelement implements Comparable<KCelement>
003{
004        public KCelement(int c ,int k) {
005                if(k>32)throw new RuntimeException("the k level is too deep");
006                this.c =c ;
007                this.k =k ;
008        }
009
010        public int k;
011        public int c;
012        /**
013         * @see java.lang.Comparable#compareTo(java.lang.Object) compareTo
014         */
015        public int compareTo(KCelement arg0) {
016                if((double)c/(double)(1<<k)==(double)arg0.c/((double)(1<<(arg0.k))))
017                {
018                        if(k<arg0.k)
019                                return -1;
020                        else if(k>arg0.k)
021                                return 1;
022                        else return 0;
023                }
024                else if((double)c/(double)(1<<k)<(double)arg0.c/((double)(1<<(arg0.k)))) 
025                {
026                        return -1;
027                }
028                else
029                {
030                        return 1;
031                }
032        }
033
034        /**
035         * @see java.lang.Object#toString() toString
036         */
037        public String toString() {
038                return new String("KC: c"+c+",k"+k+" interval:["+((double)c/((double)(1<<k)))+","+(((double)c+1)/((double)(1<<k)))+"]");
039        }
040}