T
- the type of the Pool's elements. T must implement reasonable
hashCode and equals methods. Notably, if it uses identity semantics then you
will probably end up with duplicate entries in the constant pool.public final class Pool<T> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Pool.DefaultType
A type-safe flag callers pass to the constructor to indicate whether or
not the Pool has a default zero entry.
|
Constructor and Description |
---|
Pool(Pool.DefaultType default_type)
Construct a new Pool.
|
Modifier and Type | Method and Description |
---|---|
int |
add(T e)
Add an element to the pool if it's not already present.
|
int |
getNominalSize()
When the only entry in a pool with a default zero entry is the default
zero entry the nominal size of the pool is 0, otherwise the nominal size
of the pool is the same as its size.
|
ArrayList<T> |
getValues() |
int |
id(T e) |
int |
size() |
String |
toString() |
public Pool(Pool.DefaultType default_type)
default_type
- - one of HasDefaultZero or NoDefaultZero; the Pool
will have a default meaning for its 0th entry if HasDefaultZero is passed
in.public int add(T e)
e
- - the element to add.public int id(T e)
e
- - the element of interest.IllegalArgumentException
- if the element isn't in the pool.public int size()
public int getNominalSize()
This method is need to compute the pool size to write into the ABC.
size()
Copyright © 2016 The Apache Software Foundation. All rights reserved.