commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [3/8] commons-rng git commit: New maven module.
Date Tue, 01 Nov 2016 23:03:18 GMT
New maven module.

Top-level API has been factored out.


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/b5c3ddb9
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/b5c3ddb9
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/b5c3ddb9

Branch: refs/heads/multimodule
Commit: b5c3ddb90e6be7e9e60c78823ef6416c402f71af
Parents: f2419b7
Author: Gilles <erans@apache.org>
Authored: Tue Nov 1 14:17:40 2016 +0100
Committer: Gilles <erans@apache.org>
Committed: Tue Nov 1 14:17:40 2016 +0100

----------------------------------------------------------------------
 commons-rng-client-api/pom.xml                  |  28 +++++
 .../apache/commons/rng/RandomProviderState.java |  25 ++++
 .../rng/RestorableUniformRandomProvider.java    |  49 ++++++++
 .../commons/rng/UniformRandomProvider.java      | 116 +++++++++++++++++++
 .../org/apache/commons/rng/package-info.java    |  28 +++++
 commons-rng-core/pom.xml                        |   8 ++
 .../apache/commons/rng/RandomProviderState.java |  25 ----
 .../rng/RestorableUniformRandomProvider.java    |  49 --------
 .../commons/rng/UniformRandomProvider.java      | 116 -------------------
 pom.xml                                         |   3 +-
 10 files changed, 256 insertions(+), 191 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-client-api/pom.xml
----------------------------------------------------------------------
diff --git a/commons-rng-client-api/pom.xml b/commons-rng-client-api/pom.xml
new file mode 100644
index 0000000..bf2ac48
--- /dev/null
+++ b/commons-rng-client-api/pom.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>commons-rng</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.commons</groupId>
+  <artifactId>commons-rng-client-api</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Apache Commons RNG Client API</name>
+  <url>http://maven.apache.org</url>
+
+  <inceptionYear>2016</inceptionYear>
+  <description>The Apache Commons RNG API module defines the API for client code that
uses random numbers generators.</description>
+
+  <scm>
+    <connection>scm:git:http://git-wip-us.apache.org/repos/asf/commons-rng.git</connection>
+    <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/commons-rng.git</developerConnection>
+    <url>https://git-wip-us.apache.org/repos/asf?p=commons-rng.git</url>
+  </scm>
+
+</project>

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-client-api/src/main/java/org/apache/commons/rng/RandomProviderState.java
----------------------------------------------------------------------
diff --git a/commons-rng-client-api/src/main/java/org/apache/commons/rng/RandomProviderState.java
b/commons-rng-client-api/src/main/java/org/apache/commons/rng/RandomProviderState.java
new file mode 100644
index 0000000..f4af719
--- /dev/null
+++ b/commons-rng-client-api/src/main/java/org/apache/commons/rng/RandomProviderState.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng;
+
+/**
+ * Marker interface for objects that represents the state of a random
+ * generator.
+ *
+ * @since 1.0
+ */
+public interface RandomProviderState {}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-client-api/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java
----------------------------------------------------------------------
diff --git a/commons-rng-client-api/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java
b/commons-rng-client-api/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java
new file mode 100644
index 0000000..476ce7f
--- /dev/null
+++ b/commons-rng-client-api/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng;
+
+/**
+ * Applies to generators whose internal state can be saved and restored.
+ *
+ * @since 1.0
+ */
+public interface RestorableUniformRandomProvider extends UniformRandomProvider {
+    /**
+     * Saves the state of a generator.
+     *
+     * @return the current state of this instance. It is a value that can
+     * subsequently be passed to the {@link #restoreState(RandomProviderState)
+     * restore} method.
+     * @throws UnsupportedOperationException if the underlying source of
+     * randomness does not support this functionality.
+     */
+    RandomProviderState saveState();
+
+    /**
+     * Restores the state of a generator.
+     *
+     * @param state State which this instance will be set to.
+     * This parameter would usually have been obtained by a call to
+     * {@link #saveState() saveState} performed either on the same
+     * object as this one, or an object of the exact same class.
+     * @throws UnsupportedOperationException if the underlying source of
+     * randomness does not support this functionality.
+     * @throws IllegalArgumentException if it was detected that the
+     * {@code state} argument is incompatible with this intance.
+     */
+    void restoreState(RandomProviderState state);
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-client-api/src/main/java/org/apache/commons/rng/UniformRandomProvider.java
----------------------------------------------------------------------
diff --git a/commons-rng-client-api/src/main/java/org/apache/commons/rng/UniformRandomProvider.java
b/commons-rng-client-api/src/main/java/org/apache/commons/rng/UniformRandomProvider.java
new file mode 100644
index 0000000..2b974ad
--- /dev/null
+++ b/commons-rng-client-api/src/main/java/org/apache/commons/rng/UniformRandomProvider.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng;
+
+/**
+ * Applies to generators of random number sequences that follow a uniform
+ * distribution.
+ *
+ * @since 1.0
+ */
+public interface UniformRandomProvider {
+    /**
+     * Generates {@code byte} values and places them into a user-supplied array.
+     * <p>
+     * The number of random bytes produced is equal to the length of the
+     * the byte array.
+     * </p>
+     *
+     * @param bytes Byte array in which to put the random bytes.
+     * Cannot be {@code null}.
+     */
+    void nextBytes(byte[] bytes);
+
+    /**
+     * Generates {@code byte} values and places them into a user-supplied array.
+     *
+     * <p>
+     * The array is filled with bytes extracted from random integers.
+     * This implies that the number of random bytes generated may be larger than
+     * the length of the byte array.
+     * </p>
+     *
+     * @param bytes Array in which to put the generated bytes.
+     * Cannot be {@code null}.
+     * @param start Index at which to start inserting the generated bytes.
+     * @param len Number of bytes to insert.
+     * @throws IndexOutOfBoundsException if {@code start < 0} or
+     * {@code start >= bytes.length}.
+     * @throws IndexOutOfBoundsException if {@code len < 0} or
+     * {@code len > bytes.length - start}.
+     */
+    void nextBytes(byte[] bytes,
+                   int start,
+                   int len);
+
+    /**
+     * Generates an {@code int} value.
+     *
+     * @return the next random value.
+     */
+    int nextInt();
+
+    /**
+     * Generates an {@code int} value between 0 (inclusive) and the
+     * specified value (exclusive).
+     *
+     * @param n Bound on the random number to be returned.  Must be positive.
+     * @return a random {@code int} value between 0 (inclusive) and n
+     * (exclusive).
+     * @throws IllegalArgumentException if {@code n} is negative.
+     */
+    int nextInt(int n);
+
+    /**
+     * Generates a {@code long} value.
+     *
+     * @return the next random value.
+     */
+    long nextLong();
+
+    /**
+     * Generates a {@code long} value between 0 (inclusive) and the specified
+     * value (exclusive).
+     *
+     * @param n Bound on the random number to be returned.  Must be positive.
+     * @return a random {@code long} value between 0 (inclusive) and n
+     * (exclusive).
+     * @throws IllegalArgumentException if {@code n} is negative.
+     */
+    long nextLong(long n);
+
+    /**
+     * Generates a {@code boolean} value.
+     *
+     * @return the next random value.
+     */
+    boolean nextBoolean();
+
+    /**
+     * Generates a {@code float} value between 0 and 1.
+     *
+     * @return the next random value between 0 and 1.
+     */
+    float nextFloat();
+
+    /**
+     * Generates a {@code double} value between 0 and 1.
+     *
+     * @return the next random value between 0 and 1.
+     */
+    double nextDouble();
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-client-api/src/main/java/org/apache/commons/rng/package-info.java
----------------------------------------------------------------------
diff --git a/commons-rng-client-api/src/main/java/org/apache/commons/rng/package-info.java
b/commons-rng-client-api/src/main/java/org/apache/commons/rng/package-info.java
new file mode 100644
index 0000000..9f5c52d
--- /dev/null
+++ b/commons-rng-client-api/src/main/java/org/apache/commons/rng/package-info.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <h3>Randomness Providers API</h3>
+ *
+ * <p>
+ * This package contains the library's interface to be used by client
+ * code that needs a generator of sequences of pseudo-random numbers
+ * that are <i>uniformly distributed</i> in a specified range.
+ * </p>
+ */
+
+package org.apache.commons.rng;

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-core/pom.xml
----------------------------------------------------------------------
diff --git a/commons-rng-core/pom.xml b/commons-rng-core/pom.xml
index 114a2e5..a4c138f 100644
--- a/commons-rng-core/pom.xml
+++ b/commons-rng-core/pom.xml
@@ -19,6 +19,14 @@
   <inceptionYear>2016</inceptionYear>
   <description>The Apache Commons RNG Core module includes implementations of random
numbers generators.</description>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-rng-client-api</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
   <scm>
     <connection>scm:git:http://git-wip-us.apache.org/repos/asf/commons-rng.git</connection>
     <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/commons-rng.git</developerConnection>

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-core/src/main/java/org/apache/commons/rng/RandomProviderState.java
----------------------------------------------------------------------
diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/RandomProviderState.java
b/commons-rng-core/src/main/java/org/apache/commons/rng/RandomProviderState.java
deleted file mode 100644
index f4af719..0000000
--- a/commons-rng-core/src/main/java/org/apache/commons/rng/RandomProviderState.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.rng;
-
-/**
- * Marker interface for objects that represents the state of a random
- * generator.
- *
- * @since 1.0
- */
-public interface RandomProviderState {}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-core/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java
----------------------------------------------------------------------
diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java
b/commons-rng-core/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java
deleted file mode 100644
index 476ce7f..0000000
--- a/commons-rng-core/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.rng;
-
-/**
- * Applies to generators whose internal state can be saved and restored.
- *
- * @since 1.0
- */
-public interface RestorableUniformRandomProvider extends UniformRandomProvider {
-    /**
-     * Saves the state of a generator.
-     *
-     * @return the current state of this instance. It is a value that can
-     * subsequently be passed to the {@link #restoreState(RandomProviderState)
-     * restore} method.
-     * @throws UnsupportedOperationException if the underlying source of
-     * randomness does not support this functionality.
-     */
-    RandomProviderState saveState();
-
-    /**
-     * Restores the state of a generator.
-     *
-     * @param state State which this instance will be set to.
-     * This parameter would usually have been obtained by a call to
-     * {@link #saveState() saveState} performed either on the same
-     * object as this one, or an object of the exact same class.
-     * @throws UnsupportedOperationException if the underlying source of
-     * randomness does not support this functionality.
-     * @throws IllegalArgumentException if it was detected that the
-     * {@code state} argument is incompatible with this intance.
-     */
-    void restoreState(RandomProviderState state);
-}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/commons-rng-core/src/main/java/org/apache/commons/rng/UniformRandomProvider.java
----------------------------------------------------------------------
diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/UniformRandomProvider.java
b/commons-rng-core/src/main/java/org/apache/commons/rng/UniformRandomProvider.java
deleted file mode 100644
index 2b974ad..0000000
--- a/commons-rng-core/src/main/java/org/apache/commons/rng/UniformRandomProvider.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.rng;
-
-/**
- * Applies to generators of random number sequences that follow a uniform
- * distribution.
- *
- * @since 1.0
- */
-public interface UniformRandomProvider {
-    /**
-     * Generates {@code byte} values and places them into a user-supplied array.
-     * <p>
-     * The number of random bytes produced is equal to the length of the
-     * the byte array.
-     * </p>
-     *
-     * @param bytes Byte array in which to put the random bytes.
-     * Cannot be {@code null}.
-     */
-    void nextBytes(byte[] bytes);
-
-    /**
-     * Generates {@code byte} values and places them into a user-supplied array.
-     *
-     * <p>
-     * The array is filled with bytes extracted from random integers.
-     * This implies that the number of random bytes generated may be larger than
-     * the length of the byte array.
-     * </p>
-     *
-     * @param bytes Array in which to put the generated bytes.
-     * Cannot be {@code null}.
-     * @param start Index at which to start inserting the generated bytes.
-     * @param len Number of bytes to insert.
-     * @throws IndexOutOfBoundsException if {@code start < 0} or
-     * {@code start >= bytes.length}.
-     * @throws IndexOutOfBoundsException if {@code len < 0} or
-     * {@code len > bytes.length - start}.
-     */
-    void nextBytes(byte[] bytes,
-                   int start,
-                   int len);
-
-    /**
-     * Generates an {@code int} value.
-     *
-     * @return the next random value.
-     */
-    int nextInt();
-
-    /**
-     * Generates an {@code int} value between 0 (inclusive) and the
-     * specified value (exclusive).
-     *
-     * @param n Bound on the random number to be returned.  Must be positive.
-     * @return a random {@code int} value between 0 (inclusive) and n
-     * (exclusive).
-     * @throws IllegalArgumentException if {@code n} is negative.
-     */
-    int nextInt(int n);
-
-    /**
-     * Generates a {@code long} value.
-     *
-     * @return the next random value.
-     */
-    long nextLong();
-
-    /**
-     * Generates a {@code long} value between 0 (inclusive) and the specified
-     * value (exclusive).
-     *
-     * @param n Bound on the random number to be returned.  Must be positive.
-     * @return a random {@code long} value between 0 (inclusive) and n
-     * (exclusive).
-     * @throws IllegalArgumentException if {@code n} is negative.
-     */
-    long nextLong(long n);
-
-    /**
-     * Generates a {@code boolean} value.
-     *
-     * @return the next random value.
-     */
-    boolean nextBoolean();
-
-    /**
-     * Generates a {@code float} value between 0 and 1.
-     *
-     * @return the next random value between 0 and 1.
-     */
-    float nextFloat();
-
-    /**
-     * Generates a {@code double} value between 0 and 1.
-     *
-     * @return the next random value between 0 and 1.
-     */
-    double nextDouble();
-}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/b5c3ddb9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1da716f..bb56df2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -659,8 +659,9 @@
   </profiles>
 
   <modules>
-    <module>commons-rng-core</module>
     <module>commons-rng-build-tools</module>
+    <module>commons-rng-client-api</module>
+    <module>commons-rng-core</module>
   </modules>
 
 </project>
\ No newline at end of file


Mime
View raw message