Package overit.geocall.util
Class SizedRegistry
java.lang.Object
overit.geocall.util.SizedRegistry
This class implements a registry that can contain a customizable maximum number of object elements. The elements are
recorded in a
LinkedList; if an insertion causes the maximum number of elements to be exceeded, the first
element will be removed from the list. The class exposes the methods to record the objects, to retrieve the current and
the max size, and the current elements, in the form of ArrayList.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSizedRegistry(int maxsize) Creates a new SizedRegistry, with the desired maximum size -
Method Summary
Modifier and TypeMethodDescriptionReturns anArrayListcontaining the elements of the SizedRegistryintReturns the current size of the SizedRegistryintReturns the maximum size of the SizedRegistryInserts the object in the last position of the SizedRegistry.
-
Field Details
-
_maxsize
protected int _maxsize -
_ll
-
-
Constructor Details
-
SizedRegistry
public SizedRegistry(int maxsize) Creates a new SizedRegistry, with the desired maximum size- Parameters:
maxsize- The maximum number of element that the registry can contain
-
-
Method Details
-
getMaxSize
public int getMaxSize()Returns the maximum size of the SizedRegistry- Returns:
- The maximum number of element that the registry can contain
-
getCurrentSize
public int getCurrentSize()Returns the current size of the SizedRegistry- Returns:
- The number of elements currently recorded in the registry
-
record
Inserts the object in the last position of the SizedRegistry. If, after the insertion, the number of objects inserted in the registry is greater than the maximum number allowed, then the first element of the list is removed from the registry and returned by the function. Otherwise is returnednull.- Parameters:
o- The object to record in the registry- Returns:
nullor the first element of the registry if the entry causes the maximum number of elements to be exceeded
-
getCurrentContent
Returns anArrayListcontaining the elements of the SizedRegistry- Returns:
- The ArrayList that contains the elements recorded in the registry
-