/*

CLASS {NATIVE_Random}, NATIVE, TESTED :

*/
import java.util.Random;
import java.util.ArrayList;

public class NATIVE_Random
{

    public static ArrayList<Random> All_random = new ArrayList<Random>();
    
    public static int New_random_object()
    {
        int h = All_random.lastIndexOf(null);
        if (h < 0)
        {
            h = All_random.size();
            All_random.add(null);
        }
        All_random.set(h, new Random());
        return h;
    }
    
    public static void Release_random_object(int H)
    {
        All_random.set(H, null);
        while (All_random.size() > 0 && All_random.get(All_random.size()-1) == null)
            All_random.remove(All_random.size()-1);
    }
    
    public static void Random_object_set_seed(int H, int Seed)
    {
        All_random.set(H, new Random(Seed));
    }
    
    public static int Random_object_next_in_range(int H, int Max)
    {
        Random R = All_random.get(H);
        if (Max < 0) Max = 0;
        return R.nextInt(Max);
    }
    
    public static double Random_object_probable_value(int H)
    {
        Random R = All_random.get(H);
        return R.nextDouble();
    }
}
/*

CONST STR :
    NATIVE_Random_import = ""

    NATIVE_new_random_object = @
    "    RESULT = NATIVE_Random.New_random_object();"
    
    NATIVE_release_random_object = @
    "   NATIVE_Random.Release_random_object(X_Handle);"
    
    NATIVE_Set_seed = @
    "    NATIVE_Random.Random_object_set_seed(X_Handle, X_Seed);"
    
    NATIVE_Next = @
    "    RESULT = NATIVE_Random.Random_object_next_in_range("
    "       X_Handle, X_Max);"
    
    NATIVE_Probable = @
    "    RESULT = NATIVE_Random.Random_object_probable_value(X_Handle);" 
    
    .
         
END
*/


