Package com.treemap

# Class PivotByAlgorithm.Middle

java.lang.Object
com.treemap.PivotByAlgorithm.Middle

All Implemented Interfaces:
  `PivotByAlgorithm.Type`

Enclosing class:
  `PivotByAlgorithm`

public static class PivotByAlgorithm.Middle extends Object implements PivotByAlgorithm.Type
The pivot is taken to be the middle item of the list since this is more likely to create a balanced layout.

Complexity: O(n log n) worst case,, where n is the number of nodes in the tree.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Middle()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `computePivotIndex(TreeMapNode[] children)`
  Compute the pivot index
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### Middle

    public Middle()

- ## Method Details

  - ### computePivotIndex

    public int computePivotIndex(TreeMapNode[] children)
    Description copied from interface: `PivotByAlgorithm.Type`
    Compute the pivot index
    Specified by:
      `computePivotIndex` in interface `PivotByAlgorithm.Type`
    Parameters:
      `children` - the nodes
    Returns:
      the index of the node to use as a pivot

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`