AnimationHandlerHash


This class is used to animate the algorithm by drawing to the off screen image.  This class is essentially the same for all hash algorithms.  It receives calls from the algorithm object and draws the animations.

 

Method Index


public AnimationHandlerHash(Graphics dg, Dimension dd)

Arguments:

  1. dg is the graphics object
  2. dd is the size of the draw panel

The size of an index in the hash table is defined.  Some colors are defined.


public void setSpeed(int i)

Arguments:

  1. i is the delay time

Sets the speed of animation.


public void createTable(int s)

Arguments:

  1. s is how many indexes are in the hash table.

Sets up the skeleton of the hash table.  One column has 11 indexes.  The numbering of the indexes starts from the bottom.


public void insert(int hashVal, int item)

Arguments:

  1. hashVal is the index of the hash table
  2. item is the number to insert in the hash table

Move item into hashVal index of the hash table.


public void delete(int hashVal, int item)

Arguments:

  1. hashVal is the index of the hash table
  2. item is the number to insert in the hash table

Erase item from hashVal in hash table.


Not in ChainHash:

private void moveStringIn(int hashVal, int item)

Arguments:

  1. hashVal is the index of the hash table
  2. item is the number to insert in the hash table

Move item from outside hashVal to inside the rectangle of hash table index hashVal.


private void drawItem(int hashVal, int item)

Arguments:

  1. hashVal is the index of the hash table
  2. item is the number to insert in the hash table

Draws item inside hashVal rectangle


public void check(int hashVal, int item)

Arguments:

  1. hashVal is the index of the hash table
  2. item is the number to insert in the hash table

Draws item and a pointer outside of rectangle hashVal.  Color hashVal rectangle.


public void eraseCheck(int hashVal, int item)

Arguments:

  1. hashVal is the index of the hash table
  2. item is the number to insert in the hash table

Uncolor hashVal and erase item and pointer.


private void drawPointer(int hashVal, boolean draw)

Arguments:

  1. hashVal is the index of the hash table
  2. if draw is true draw pointer, else erase

Draw or erase a pointer from a string to rectangle hashVal


Ted Jenks