# Distribution (ARX Developer Documentation)

org.deidentifier.arx.framework.check.distribution

## Class Distribution

- java.lang.Object
- - org.deidentifier.arx.framework.check.distribution.Distribution

-     public class Distribution
      extends java.lang.Object

  This class can be utilized to track the distributions of values. It is backed by a hash table implementing open addressing with linear probing.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Distribution()` Default constructor.
    `Distribution(int[] element, int[] frequency)` Constructor used to create frequency set from a history entry.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(int element)` Adds a element to the hashtable.
    `void` | `clear()` Clears the table.
    `int[]` | `getBuckets()` Gets all buckets of the hash table.
    `int[]` | `getPackedElements()` Gets all elements of the packed table.
    `int[]` | `getPackedFrequency()` Gets the frequency of the packed table.
    `void` | `merge(Distribution other)` Merges two frequency sets.
    `void` | `merge(int[] elements, int[] frequency)` Merge a frequency set with a history entry.
    `void` | `pack()` Packs the frequency table; removes null values and generates sortedElements and sortedFrequency arrays.
    `int` | `size()` Gets the current size.
    `java.lang.String` | `toString()`

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

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

- - ### Constructor Detail

    - #### Distribution

          public Distribution()

      Default constructor.

    - #### Distribution

          public Distribution(int[] element,
                      int[] frequency)

      Constructor used to create frequency set from a history entry.
      Parameters:
        `element` -
        `frequency` -

  - ### Method Detail

    - #### add

          public final void add(int element)

      Adds a element to the hashtable. Frequency value 1.
      Parameters:
        `element` -

    - #### clear

          public void clear()

      Clears the table.

    - #### getBuckets

          public int[] getBuckets()

      Gets all buckets of the hash table.
      Returns:

    - #### getPackedElements

          public int[] getPackedElements()

      Gets all elements of the packed table.
      Returns:

    - #### getPackedFrequency

          public int[] getPackedFrequency()

      Gets the frequency of the packed table.
      Returns:

    - #### merge

          public void merge(Distribution other)

      Merges two frequency sets.
      Parameters:
        `other` -

    - #### merge

          public void merge(int[] elements,
                   int[] frequency)

      Merge a frequency set with a history entry.
      Parameters:
        `elements` -
        `frequency` -

    - #### pack

          public void pack()

      Packs the frequency table; removes null values and generates sortedElements and sortedFrequency arrays. In case a collission occured this method also sorts the elements.

    - #### size

          public int size()

      Gets the current size.
      Returns:

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`