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


Constructor Index

 o SyncSimpleArray(int)
Creates a new array object of a given size and fills it up with null.

Method Index

 o active()
Returns the number of nonnull objects in the array.
 o get(int)
Reads the object value at the specified index in the array.
 o remove(int)
Removes a given object at a specified index in the array.
 o set(int, Object)
Puts a object at a specified index in the array.
 o size()
Returns the number of static allocated slots.

Constructors

 o 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

Methods

 o active
 public synchronized int active()
Returns the number of nonnull objects in the array.

 o 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)
 o 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
 o 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
 o size
 public int size()
Returns the number of static allocated slots.