All Downloads are FREE. Search and download functionalities are using the official Maven repository.

toxgene.util.IntObjectPair Maven / Gradle / Ivy

/**
 * Implements a pair (int, Object) which is the building block for the
 * Dictionary
 */

package toxgene.util;

import java.lang.Comparable;

public class IntObjectPair implements Comparable{
  private int key;
  private Object value;

  public IntObjectPair(int k, Object v){
	key = k;
	value = v;
  }

  public int compareTo(Object o){
	if (o instanceof Integer){
	  return compareTo(((Integer)o).intValue());
	}

	if (this.key == ((IntObjectPair) o).key())
	  return 0;
	if (this.key > ((IntObjectPair) o).key())
	  return 1;
	else
	  return -1;
  }

  public int compareTo(int s){
	if (key < s)
	  return -1; 
	if (key > s)
	  return 1;
	else
	  return 0;
  }

  public int key(){
	return key;
  }
  
  public Object value(){
	return value;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy