org.knime.base.node.mine.decisiontree2.learner
Class ValueMapper<S>

java.lang.Object
  extended by org.knime.base.node.mine.decisiontree2.learner.ValueMapper<S>
Type Parameters:
S - the type to map to an integer

public class ValueMapper<S>
extends Object

A mapper mapping the objects of the defined class S to integer indices and vice versa.

Author:
Christoph Sieb, University of Konstanz

Constructor Summary
ValueMapper()
          Constructs an empty mapper.
 
Method Summary
 int getIndex(S mappedObject)
          Returns the integer index for the corresponding mapped object.
 int getIndexMayBeAdded(S mappedObject)
          Returns the integer index for the corresponding mapped object.
 S getMappedObject(int index)
          Returns the mapped object for the corresponding index.
 S[] getMappedObjectsInMappingOrder()
          Returns all mapped objects in the order they were inserted.
 int getNumMappings()
          Returns the number of mappings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueMapper

public ValueMapper()
Constructs an empty mapper. The indices are used in a consecutive manner. I.e. the first integer mapping is 0 the second 1 and so on.

Method Detail

getMappedObject

public S getMappedObject(int index)
Returns the mapped object for the corresponding index.

Parameters:
index - the index for which to return the corresponding mapped object
Returns:
the mapped object for the corresponding index, null if there exists no mapping for the given index

getMappedObjectsInMappingOrder

public S[] getMappedObjectsInMappingOrder()
Returns all mapped objects in the order they were inserted.

Returns:
the mapped objects

getIndex

public int getIndex(S mappedObject)
Returns the integer index for the corresponding mapped object.

Parameters:
mappedObject - the mapped object for which to return the corresponding integer index
Returns:
the integer index for the corresponding mapped object, -1 if there exists no mapping for the given mapped object

getIndexMayBeAdded

public int getIndexMayBeAdded(S mappedObject)
Returns the integer index for the corresponding mapped object. If there exists no mapping for the given mapped object a new mapping is created and the new integer index is returned.

Parameters:
mappedObject - the mapped object for which to return the corresponding integer index
Returns:
the integer index for the corresponding mapped object, a new integer index if the mapped object mapping did not existed. The new mapping index is the next available integer according to the previous mapping

getNumMappings

public int getNumMappings()
Returns the number of mappings.

Returns:
the number of mappings


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.