KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > rbtreesizesequence > Entry


1 /**
2 * Copyright (c) 2003 Daffodil Software Ltd., India all rights reserved.
3 * This library is free software; you can redistribute it and/or modify
4 * it under the terms of version 2.1 of the GNU Lesser General Public License as
5 * published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public License
13 * along with this library; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 */

16
17
18 package com.daffodilwoods.rbtreesizesequence;
19
20 import com.daffodilwoods.rbtreesizesequence.utils.rbtree.RBTreeNode;
21 import java.util.Comparator JavaDoc;
22
23 public class Entry extends RBTreeNode implements Comparable JavaDoc{
24
25     int distanceFromParent;
26
27     public Entry(Object JavaDoc key, Entry parent, int distance){
28         super(key, parent);
29         this.distanceFromParent = distance;
30     }
31
32     public Entry(Object JavaDoc key, RBTreeNode parent, Comparator JavaDoc c, int distance) {
33         super(key, parent, c);
34         this.distanceFromParent = distance;
35     }
36
37     public void setDistancFromParent(int newDistanceFromParent){
38         distanceFromParent = newDistanceFromParent;
39     }
40
41     public int getDistanceFromParent(){
42     return distanceFromParent;
43     }
44
45     public void show(){
46     }
47
48     public String JavaDoc toString(){
49         return hashCode() + "-" + key + " [" + distanceFromParent + "]";
50     }
51
52     public int compareTo(Object JavaDoc obj){
53         if(key == ((Entry)obj).getKey()) return 0;
54         return super.compareTo(obj);
55     }
56 }
57
Popular Tags