fulmine.util.reference
Class ReferenceCounter<TYPE>

java.lang.Object
  extended by fulmine.util.reference.ReferenceCounter<TYPE>
Type Parameters:
TYPE - the type of objects this counter works with
All Implemented Interfaces:
IReferenceCounter<TYPE>

public final class ReferenceCounter<TYPE>
extends Object
implements IReferenceCounter<TYPE>

Standard implementation, not thread safe.

Author:
Ramon Servadei

Constructor Summary
ReferenceCounter()
          Construct the counter with a default entry size of 2
ReferenceCounter(int size)
          Construct the counter with a specific entry size
 
Method Summary
 int adjustCount(TYPE target, int delta)
          Adjust the number of reference counts for the target object by the delta.
 void clear()
          Clear all reference counts.
 int getCount(TYPE target)
          Get the number of references for the target.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReferenceCounter

public ReferenceCounter()
Construct the counter with a default entry size of 2


ReferenceCounter

public ReferenceCounter(int size)
Construct the counter with a specific entry size

Parameters:
size - the entry size
Method Detail

adjustCount

public int adjustCount(TYPE target,
                       int delta)
Description copied from interface: IReferenceCounter
Adjust the number of reference counts for the target object by the delta. The delta can be positive or negative. This operation never results in a negative reference count. This operation uses Object.equals(Object) to find the reference counts for the target.

Specified by:
adjustCount in interface IReferenceCounter<TYPE>
Parameters:
target - the target object to adjust the number of references for
delta - the change in the reference count for the object
Returns:
the number of references for the target after this operation completes. This is never less than 0.

getCount

public int getCount(TYPE target)
Description copied from interface: IReferenceCounter
Get the number of references for the target. This operation uses Object.equals(Object) to find the reference counts for the target.

Specified by:
getCount in interface IReferenceCounter<TYPE>
Parameters:
target - the target object to find the number of references for
Returns:
the number of references for the target

clear

public void clear()
Description copied from interface: IReferenceCounter
Clear all reference counts.

Specified by:
clear in interface IReferenceCounter<TYPE>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2009. All Rights Reserved.