class FilterHolder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
count
Number of filters currently installed.
|
private Filter[] |
filters
The array of filters.
|
Constructor and Description |
---|
FilterHolder()
Constructs a new
FilterHolder with an intial capacity of 2. |
FilterHolder(int initialSize)
Constructs a new
FilterHolder with the given initial capacity. |
Modifier and Type | Method and Description |
---|---|
void |
addFilter(Filter filter)
Adds a filter to the end of the array, possibly enlarging it if it is full.
|
void |
addFilter(Filter filter,
int index)
Adds a filter at the given index.
|
private void |
compact()
Shrinks the array to save space if it is 75% empty.
|
Filter |
getFilter(int index)
Returns a filter at the given array index.
|
int |
getFilterCount()
Returns the number of filters current installed.
|
private void |
makeSpace()
Enlarges the size of the array to make room for more filters.
|
void |
removeFilter(Filter filter)
Removes a filter from the set.
|
void |
removeFilter(int index)
Removes a filter at a given index.
|
private Filter[] filters
private int count
FilterHolder()
FilterHolder
with an intial capacity of 2.FilterHolder(int initialSize)
FilterHolder
with the given initial capacity.initialSize
- the initial size for the array.public void addFilter(Filter filter)
filter
- the filter to add.public void addFilter(Filter filter, int index)
filter
- the filter to add.index
- the position to add the filter.public void removeFilter(Filter filter)
f
, satisfying the condition
f.equals (filter)
is removed and the remaining filters shifted to close the gap.filter
- the filter to remove.public void removeFilter(int index)
index
- the array index to remove the filter.public Filter getFilter(int index)
public int getFilterCount()
private void makeSpace()
private void compact()