| java.lang.Object | |
| ↳ | com.pnfsoftware.jeb.util.collect.ReferenceCounter<K> |
A simple, thread-safe object reference counter.
Note that this utility class has nothing to do with Garbage Collection reference counting.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
ReferenceCounter()
Create a new reference counter.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| synchronized int |
dec(K key)
Unrecord an object, ie decrement its reference counter by one.
| ||||||||||
| synchronized String | formatTopReferences(int top) | ||||||||||
| synchronized int |
get(K key)
Get the reference counter for an object.
| ||||||||||
| synchronized boolean |
has(K key)
Check if an object is currently referenced, ie its reference counter is greater or equal than
zero.
| ||||||||||
| synchronized int |
inc(K key)
Record an object, ie increment its reference counter.
| ||||||||||
| synchronized void | load(Collection<? extends K> coll) | ||||||||||
| synchronized boolean |
remove(K key)
Remove an object from tracking.
| ||||||||||
| synchronized String | toString() | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Create a new reference counter.
Unrecord an object, ie decrement its reference counter by one. If the object is currently tracked, an exception will be raised.
| key | object |
|---|
| IllegalArgumentException | if the object is not present |
|---|
Get the reference counter for an object.
| key | object |
|---|
Check if an object is currently referenced, ie its reference counter is greater or equal than zero.
| key | object |
|---|
Record an object, ie increment its reference counter.
| key | object |
|---|
Remove an object from tracking. This method is equivalent to decrementing the object counter until zero.
| key | object |
|---|