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(Class<E> enumClass)
Construct counters for the given enum constants.
|
EnumCounters(Class<E> enumClass,
long defaultVal) |
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.
|
boolean |
allLessOrEqual(long val) |
boolean |
anyGreaterOrEqual(long val) |
long[] |
asArray() |
boolean |
equals(Object obj) |
long |
get(E e) |
int |
hashCode() |
void |
negation()
Negate all counters.
|
void |
reset()
Reset all counters to zero.
|
void |
reset(long val) |
void |
set(E e,
long value)
Set counter e to the given value.
|
void |
set(EnumCounters<E> that)
Set this counters to that counters.
|
void |
subtract(E e,
long value)
Subtract the given value from counter e.
|
void |
subtract(EnumCounters<E> that)
Subtract this counters from that counters.
|
long |
sum() |
String |
toString() |
public EnumCounters(Class<E> enumClass)
enumClass
- the enum class of the counters.public final long get(E e)
public long[] asArray()
public final void negation()
public final void set(E e, long value)
public final void set(EnumCounters<E> that)
public final void reset()
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)
public final long sum()
public final void reset(long val)
public boolean allLessOrEqual(long val)
public boolean anyGreaterOrEqual(long val)
Copyright © 2017 Apache Software Foundation. All Rights Reserved.