Package net.sourceforge.jiu.color.data

# Class ArrayHistogram1D

java.lang.Object
net.sourceforge.jiu.color.data.ArrayHistogram1D

All Implemented Interfaces:
  `Histogram1D`

public class ArrayHistogram1D extends Object implements Histogram1D
A one-dimensional histogram data class that stores its counters in memory. Counters are stored in an `int` array of length `getMaxValue()``+ 1` so that `k` values will require `k * 4` bytes.

Author:
  Marco Schmidt

## Field Summary

Fields
Modifier and Type
Field
Description
`private int[]`
`data`

## Constructor Summary

Constructors
Constructor
Description
`ArrayHistogram1D(int numValues)`
Creates a histogram with the argument's number of values, from `0` to `numValues - 1`.

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
Sets all counters to zero.
`int`
`getEntry(int index)`
Returns the counter value for the given index.
`int`
`getMaxValue()`
Returns the maximum allowed index.
`int`
`getNumUsedEntries()`
Returns the number of used entries (those entries with a counter value larger than zero).
`void`
`increaseEntry(int index)`
Increases the counter value of the given index by one.
`void`
`setEntry(int index, int newValue)`
Sets one counter to a new value.

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

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

## Field Details

### data

private int[] data

## Constructor Details

### ArrayHistogram1D

public ArrayHistogram1D(int numValues)
Creates a histogram with the argument's number of values, from `0` to `numValues - 1`.

Parameters:
  `numValues` - the number of counters in the histogram; must be one or larger
Throws:
  `IllegalArgumentException` - if the argument is smaller than one

## Method Details

### clear

public void clear()
Description copied from interface: `Histogram1D`
Sets all counters to zero.

Specified by:
  `clear` in interface `Histogram1D`

### getEntry

public int getEntry(int index)
Description copied from interface: `Histogram1D`
Returns the counter value for the given index.

Specified by:
  `getEntry` in interface `Histogram1D`
Parameters:
  `index` - the zero-based index of the desired counter value
Returns:
  the counter value

### getMaxValue

public int getMaxValue()
Description copied from interface: `Histogram1D`
Returns the maximum allowed index. The minimum is always 0.

Specified by:
  `getMaxValue` in interface `Histogram1D`
Returns:
  the maximum index value

### getNumUsedEntries

public int getNumUsedEntries()
Description copied from interface: `Histogram1D`
Returns the number of used entries (those entries with a counter value larger than zero).

Specified by:
  `getNumUsedEntries` in interface `Histogram1D`
Returns:
  number of non-zero counter values

### increaseEntry

public void increaseEntry(int index)
Description copied from interface: `Histogram1D`
Increases the counter value of the given index by one. Same semantics as `setEntry(index, getEntry(index) + 1);`

Specified by:
  `increaseEntry` in interface `Histogram1D`
Parameters:
  `index` - index into the histogram

### setEntry

public void setEntry(int index, int newValue)
Description copied from interface: `Histogram1D`
Sets one counter to a new value.

Specified by:
  `setEntry` in interface `Histogram1D`
Parameters:
  `index` - index of the counter to be changed
  `newValue` - new value for that counter