001 /* 002 * Histogram1D 003 * 004 * Copyright (c) 2001, 2002, 2003 Marco Schmidt. 005 * All rights reserved. 006 */ 007 008 package net.sourceforge.jiu.color.data; 009 010 /** 011 * An interface for a one-dimensional histogram. 012 * 013 * @author Marco Schmidt 014 * @see Histogram3D 015 */ 016 public interface Histogram1D 017 { 018 /** 019 * Sets all counters to zero. 020 */ 021 void clear(); 022 023 /** 024 * Returns the counter value for the given index. 025 * @param index the zero-based index of the desired counter value 026 * @return the counter value 027 * @throws IllegalArgumentException if the argument is not a valid index 028 */ 029 int getEntry(int index); 030 031 /** 032 * Returns the maximum allowed index. 033 * The minimum is always 0. 034 * @return the maximum index value 035 */ 036 int getMaxValue(); 037 038 /** 039 * Returns the number of used entries (those entries with 040 * a counter value larger than zero). 041 * @return number of non-zero counter values 042 */ 043 int getNumUsedEntries(); 044 045 /** 046 * Increases the counter value of the given index by one. 047 * Same semantics as 048 * <code>setEntry(index, getEntry(index) + 1);</code> 049 * @param index index into the histogram 050 * @return the counter value of the given index 051 * @throws IllegalArgumentException if the argument index is invalid 052 */ 053 void increaseEntry(int index); 054 055 /** 056 * Sets one counter to a new value. 057 * @param index index of the counter to be changed 058 * @param newValue new value for that counter 059 * @throws IllegalArgumentException if the index is invalid 060 */ 061 void setEntry(int index, int newValue); 062 }