edu.duke.cs.banjo.bayesnet
Class NodeScoreCacheItem

java.lang.Object
  extended byedu.duke.cs.banjo.bayesnet.NodeScoreCacheItem
All Implemented Interfaces:
NodeScoreCacheItemI

public class NodeScoreCacheItem
extends java.lang.Object
implements NodeScoreCacheItemI

Implements storing the (already computed) node scores in a hash.

Details:
- Computes the hash code needed for storing an item in a hash
- Implements comparison ('equal') between items

Change History:
Created on May 4, 2004

Author:
Jurgen Sladeczek (hjs)
For the latest info, please visit www.cs.duke.edu.

Field Summary
private  int hashCode
           
private  int nodeID
           
private  double nodeScore
           
private  int[][] parentIDlist
           
 
Constructor Summary
NodeScoreCacheItem()
          Basic constructor for creating a cached item.
NodeScoreCacheItem(int _nodeID, int[][] _parentIDlist, double _nodeScore)
          constructor for creating a cached item from the set of underlying parameters.
 
Method Summary
 void assignNodeScoreHashItem(int _nodeID, int[][] _parentIDlist, double _nodeScore)
          Assigns a cached item using the underlying parameters that describe it.
 boolean equals(java.lang.Object _objToCompareTo)
           
 int getHashCode()
           
 int getHashCode(int _nodeID, int[][] _parentIDlist)
           
 int getNodeID()
           
 double getNodeScore()
           
 boolean hasIdenticalParentList(int[][] listToCheck)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nodeID

private int nodeID

parentIDlist

private int[][] parentIDlist

nodeScore

private double nodeScore

hashCode

private int hashCode
Constructor Detail

NodeScoreCacheItem

public NodeScoreCacheItem()
Basic constructor for creating a cached item. Any object created with this constructor will need to get assigned a "valid" cache item.


NodeScoreCacheItem

public NodeScoreCacheItem(int _nodeID,
                          int[][] _parentIDlist,
                          double _nodeScore)
constructor for creating a cached item from the set of underlying parameters.

Parameters:
_nodeID - The node ID of the item.
_parentIDlist - The list of parent IDs of the item.
_nodeScore - The nodeScore of the item.
Method Detail

assignNodeScoreHashItem

public void assignNodeScoreHashItem(int _nodeID,
                                    int[][] _parentIDlist,
                                    double _nodeScore)
Assigns a cached item using the underlying parameters that describe it. Note that the associated hashcode is being computed within this method

Specified by:
assignNodeScoreHashItem in interface NodeScoreCacheItemI
Parameters:
_nodeID - The node ID of the item.
_parentIDlist - The list of parent IDs of the item.
_nodeScore - The nodeScore of the item.

getHashCode

public int getHashCode()
Specified by:
getHashCode in interface NodeScoreCacheItemI
Returns:
Returns the hash code of the cached item.

getHashCode

public int getHashCode(int _nodeID,
                       int[][] _parentIDlist)
Specified by:
getHashCode in interface NodeScoreCacheItemI
Parameters:
_nodeID - The node ID of the item.
_parentIDlist - The list of parent IDs of the item.
Returns:
Returns the hash code of the cached item after it is computed based on the supplied parameters.

equals

public boolean equals(java.lang.Object _objToCompareTo)
Specified by:
equals in interface NodeScoreCacheItemI
Returns:
Returns the result of comparing this item to another cached item.

toString

public java.lang.String toString()
Returns:
A custom string representation for a cached item. Note: Used internally for testing only. (Inefficient)

getNodeScore

public double getNodeScore()
Specified by:
getNodeScore in interface NodeScoreCacheItemI
Returns:
Returns the nodeScore.

getNodeID

public int getNodeID()
Specified by:
getNodeID in interface NodeScoreCacheItemI
Returns:
Returns the nodeID.

hasIdenticalParentList

public boolean hasIdenticalParentList(int[][] listToCheck)
Specified by:
hasIdenticalParentList in interface NodeScoreCacheItemI
Parameters:
listToCheck - The list of parent IDs to compare with.
Returns:
Returns the result of comparing to a supplied parent list.