commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1307) Create a base class for all RNGs
Date Tue, 29 Dec 2015 00:52:49 GMT

    [ https://issues.apache.org/jira/browse/MATH-1307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15073323#comment-15073323
] 

Gilles commented on MATH-1307:
------------------------------

bq. Zero length must be considered correct as well.

It is a possibility; not a _must_ IMHO. I wouldn't mind changing it if others agree that a
no-op call should not be guarded against as a probable bug.

bq. The max variable is allocated on the stack \[...\] this is just waste of resources.

Are you sure?
I usually leave such considerations to the JIT compiler in favour of self-documenting code.

bq. changed [...\] method parameter names

I found it slightly clearer. YMMV.
I agree that we could abide by a stricter convention; but not everyone is OK with that here.

About "start" as a parameter name, see our "o.a.c.m.util.MathArrays" class...

Parameter names of "nextBytesFill" changed in commit d1123894d33922e7c8ca838f9dac9bdceefa3f7a
(master) ;)


> Create a base class for all RNGs
> --------------------------------
>
>                 Key: MATH-1307
>                 URL: https://issues.apache.org/jira/browse/MATH-1307
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Gilles
>            Assignee: Gilles
>            Priority: Minor
>              Labels: api, inheritance
>             Fix For: 4.0
>
>         Attachments: BaseRandomGenerator.java
>
>
> I proposed to create a base class which the existing abstract classes {{AbstractRandomGenerator}}
and {{BitsStreamGenerator}} will extend.
> This would allow to define {{nextBytes(byte[])}} at the base class level.
> The code for that method is almost identical in the two hierarchies: they only differ
in a call to either {{nextInt()}} or {{next(32)}} respectively; the latter is however the
same as the former, in disguise, and is not subject to change given the type of return value.
> As a corollary, the new base class can be the unique place where to add utilities such
as the one proposed in MATH-1306.
> *Update:* {{AbstractRandomGenerator}} and {{BitsStreamGenerator}} are both obsoleted
by the class proposed in this report.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message