Class DirectCircularList<E>
java.lang.Object
math.DirectCircularList<E>
Title: Direct Circular List
Description: This class implements a direct access O(1) fixed size circular list extremely useful for caching purposes.
- Author:
- Bertoli Marco Date: 14-feb-2006 Time: 11.17.24
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDirectCircularList(int size) Creates a new DirectCircularList with specified size -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists(int index) Tells if specified element is present in the list.get(int index) Returns value for item in position index or null if it does not exist.intgetSize()Returns size of this Circular List.voidSets element in position index to specified value.toString()Used for debugging purposes: provides a string representation of every object in the data structure
-
Field Details
-
last
protected int last -
lastIndex
protected int lastIndex -
data
-
size
protected int size
-
-
Constructor Details
-
DirectCircularList
public DirectCircularList(int size) Creates a new DirectCircularList with specified size- Parameters:
size- maximum size of the data structure
-
-
Method Details
-
set
Sets element in position index to specified value. This method is O(1) if values are inserted with adiacent indices, otherwise some computation is needed to mark null elements.- Parameters:
index- position of item to be setvalue- value for the item
-
get
-
exists
public boolean exists(int index) Tells if specified element is present in the list. This method is O(1).- Parameters:
index- index of specified element- Returns:
- true iff element is not null
-
getSize
public int getSize()Returns size of this Circular List. This method is O(1).- Returns:
- size of this Circular List
-
toString
-