E
- the enum typepublic class EnumCounters<E extends Enum<E>> extends Object
enum Fruit { APPLE, ORANGE, GRAPE }An
EnumCounters
object can be created for counting the numbers of
APPLE, ORANGLE and GRAPE.Modifier and Type | Class and Description |
---|---|
static interface |
EnumCounters.Factory<E extends Enum<E>,C extends EnumCounters<E>>
A factory for creating counters.
|
static class |
EnumCounters.Map<K,E extends Enum<E>,C extends EnumCounters<E>>
A key-value map which maps the keys to
EnumCounters . |
Constructor and Description |
---|
EnumCounters(E[] enumConstants)
Construct counters for the given enum constants.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E e,
long value)
Add the given value to counter e.
|
void |
add(EnumCounters<E> that)
Add that counters to this counters.
|
long |
get(E e) |
void |
negation()
Negate all counters.
|
void |
set(E e,
long value)
Set counter e to the given value.
|
void |
subtract(E e,
long value)
Subtract the given value from counter e.
|
void |
subtract(EnumCounters<E> that)
Subtract that counters from this counters.
|
String |
toString() |
public EnumCounters(E[] enumConstants)
enumConstants
- an array of enum constants such that,
for all i, enumConstants[i].ordinal() == i.public final long get(E e)
public final void negation()
public final void set(E e, long value)
public final void add(E e, long value)
public final void add(EnumCounters<E> that)
public final void subtract(E e, long value)
public final void subtract(EnumCounters<E> that)
Copyright © 2013 Apache Software Foundation. All rights reserved.