com.mhhe.clrs2e
Class RadixSort.RadixKeyExtractor

java.lang.Object
  |
  +--com.mhhe.clrs2e.RadixSort.RadixKeyExtractor
All Implemented Interfaces:
CountingSort.KeyExtractor
Enclosing class:
RadixSort

private static class RadixSort.RadixKeyExtractor
extends java.lang.Object
implements CountingSort.KeyExtractor

Interface that allows us to pull out the sort key from an object.


Field Summary
private  int divisor
          The divisor for extracting.
private  int extractorRadix
          The radix for extracting.
 
Constructor Summary
RadixSort.RadixKeyExtractor(int radix, int divisor)
          Initializes the radix and divisor.
 
Method Summary
 int extract(int value)
          Extracts the key from an int, where the key is the ith digit in base extractorRadix, and assuming that divisor equals extractorRadix^i.
 int extract(com.mhhe.clrs2e.NonNegativeInteger value)
          Extracts the key from an NonNegativeInteger, where the key is the ith digit in base extractorRadix, and assuming that divisor equals extractorRadix^i.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extractorRadix

private int extractorRadix
The radix for extracting.


divisor

private int divisor
The divisor for extracting.

Constructor Detail

RadixSort.RadixKeyExtractor

public RadixSort.RadixKeyExtractor(int radix,
                                   int divisor)
Initializes the radix and divisor.

Parameters:
radix - Radix used.
divisor - Divisor used.
Method Detail

extract

public int extract(int value)
Extracts the key from an int, where the key is the ith digit in base extractorRadix, and assuming that divisor equals extractorRadix^i.

Specified by:
extract in interface CountingSort.KeyExtractor
Parameters:
value - The int whose key is to be extracted.
Returns:
The extracted key.

extract

public int extract(com.mhhe.clrs2e.NonNegativeInteger value)
Extracts the key from an NonNegativeInteger, where the key is the ith digit in base extractorRadix, and assuming that divisor equals extractorRadix^i.

Specified by:
extract in interface CountingSort.KeyExtractor
Parameters:
value - The NonNegativeInteger whose key is to be extracted.
Returns:
The extracted key.