Package overit.geocall.util
Class SizedList
java.lang.Object
overit.geocall.util.SizedList
The class implements a list with a specific size.
The add method, adds the object always as the first element of the list, shifting the others and the elements
that are in excess are eliminated. The class also exposes the classic get, remove and clear methods, in addition
to the contains, used to search for a specific object in the SizedList
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the object always as the first element of the list, shifting the others.voidclear()Empties the SizedListbooleanChecks if the SizedList contains a specific objectget(int pos) Returns the object element in the specific positionremove(int pos) Removes the object element in the specific positionintsize()Returns the list size, that is fixed by the value used to create the SizedList (SizedList(maxSize))
-
Field Details
-
_maxSize
protected int _maxSize -
_values
-
-
Constructor Details
-
SizedList
public SizedList(int maxSize) Creates a SizedList, with the desired size- Parameters:
maxSize- The size of the list
-
-
Method Details
-
size
public int size()Returns the list size, that is fixed by the value used to create the SizedList (SizedList(maxSize))- Returns:
- The list size
-
add
Adds the object always as the first element of the list, shifting the others. If, after addition, the number of items in the list exceeds the maximum allowed size defined by the constructor method, the elements that are in excess are eliminated- Parameters:
o- The object to add- Returns:
- The SizedList with the added object
-
get
Returns the object element in the specific position- Parameters:
pos- The position of the element- Returns:
- The object in the desired position, or
nullif the position passed as parameter is greater than the list size
-
remove
Removes the object element in the specific position- Parameters:
pos- The position of the element that must be removed- Returns:
- The SizedList without the element removed, or
nullif the position passed as parameter is greater than the list size
-
contains
Checks if the SizedList contains a specific object- Parameters:
o- The object searched- Returns:
trueif the object is in the SizedList,falseotherwise
-
clear
public void clear()Empties the SizedList
-