Class SyncSimpleArray
java.lang.Object
|
+----SyncSimpleArray
- public class SyncSimpleArray
- extends Object
A simple synchronized static allocated array class.
The only difference from a normal array of objects is that the
access is synchronized. Is this enough ;-) ?
Written: Radu Sion
Version: 0.1
Source: SyncSimpleArray.java
-
SyncSimpleArray(int)
- Creates a new array object of a given size and fills it up with null.
-
active()
- Returns the number of nonnull objects in the array.
-
get(int)
- Reads the object value at the specified index in the array.
-
remove(int)
- Removes a given object at a specified index in the array.
-
set(int, Object)
- Puts a object at a specified index in the array.
-
size()
- Returns the number of static allocated slots.
SyncSimpleArray
public SyncSimpleArray(int size)
- Creates a new array object of a given size and fills it up with null.
No parameter checkings are performed.
- Parameters:
- size - Number of empty slots to allocate static
active
public synchronized int active()
- Returns the number of nonnull objects in the array.
set
public synchronized void set(int index,
Object obj)
- Puts a object at a specified index in the array.
No parameter checkings are performed.
- Parameters:
- index - The position inside the array where to put that object
- obj - The object to use (may be also null)
remove
public synchronized void remove(int index)
- Removes a given object at a specified index in the array.
Is equivalent (for now) to .set(index,null).
No parameter checkings are performed.
- Parameters:
- index - The position inside the array from where to remove that object
get
public synchronized Object get(int index)
- Reads the object value at the specified index in the array.
No parameter checkings are performed.
- Parameters:
- index - The position inside the array where to read from
- Returns:
- The value at that position
size
public int size()
- Returns the number of static allocated slots.