weka.classifiers.lazy
Class IBk.NeighborList

java.lang.Object
  extended byweka.classifiers.lazy.IBk.NeighborList
Enclosing class:
IBk

private class IBk.NeighborList
extends java.lang.Object


Field Summary
private  IBk.NeighborNode m_First
          The first node in the list
private  IBk.NeighborNode m_Last
          The last node in the list
private  int m_Length
          The number of nodes to attempt to maintain in the list
 
Constructor Summary
IBk.NeighborList(int length)
          Creates the neighborlist with a desired length
 
Method Summary
 int currentLength()
          Gets the current length of the list.
 void insertSorted(double distance, Instance instance)
          Inserts an instance neighbor into the list, maintaining the list sorted by distance.
 boolean isEmpty()
          Gets whether the list is empty.
 void printList()
          Prints out the contents of the neighborlist
 void pruneToK(int k)
          Prunes the list to contain the k nearest neighbors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_First

private IBk.NeighborNode m_First
The first node in the list


m_Last

private IBk.NeighborNode m_Last
The last node in the list


m_Length

private int m_Length
The number of nodes to attempt to maintain in the list

Constructor Detail

IBk.NeighborList

public IBk.NeighborList(int length)
Creates the neighborlist with a desired length

Parameters:
length - the length of list to attempt to maintain
Method Detail

isEmpty

public boolean isEmpty()
Gets whether the list is empty.

Returns:
true if so

currentLength

public int currentLength()
Gets the current length of the list.

Returns:
the current length of the list

insertSorted

public void insertSorted(double distance,
                         Instance instance)
Inserts an instance neighbor into the list, maintaining the list sorted by distance.

Parameters:
distance - the distance to the instance
instance - the neighboring instance

pruneToK

public void pruneToK(int k)
Prunes the list to contain the k nearest neighbors. If there are multiple neighbors at the k'th distance, all will be kept.

Parameters:
k - the number of neighbors to keep in the list.

printList

public void printList()
Prints out the contents of the neighborlist