Skip to content

Commit

Permalink
Include C-API javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed May 12, 2019
1 parent b61e909 commit f28ccb5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 43 deletions.
38 changes: 23 additions & 15 deletions main/pom.xml
@@ -1,12 +1,13 @@
<!-- Citizens build file -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.25-SNAPSHOT</version>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.25-SNAPSHOT</version>
</parent>
<artifactId>citizens-main</artifactId>

Expand Down Expand Up @@ -162,17 +163,24 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<author>false</author>
<doclint>none</doclint>
<links>
<link>https://hub.spigotmc.org/javadocs/spigot</link>
</links>
</configuration>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<includeDependencySources>true</includeDependencySources>

<dependencySourceIncludes>
<dependencySourceInclude>net.citizensnpcs.api:*</dependencySourceInclude>
</dependencySourceIncludes>

<source>8</source>
<author>false</author>
<doclint>none</doclint>
<links>
<link>https://hub.spigotmc.org/javadocs/spigot</link>
</links>
</configuration>
</plugin>
</plugins>
</build>
</project>
44 changes: 16 additions & 28 deletions main/src/main/java/net/citizensnpcs/util/XORShiftRNG.java
Expand Up @@ -22,24 +22,21 @@
* <p>
* Very fast pseudo random number generator. See
* <a href= "http://school.anhb.uwa.edu.au/personalpages/kwessen/shared/Marsaglia03.html" >this page</a> for a
* description. This RNG has a period of about 2^160, which is not as long as the {@link MersenneTwisterRNG} but it is
* faster.
* description. This RNG has a period of about 2^160, which is not as long as the MersenneTwisterRNG but it is faster.
* </p>
*
*
* <p>
* <em>NOTE: Because instances of this class require 160-bit seeds, it is not
* possible to seed this RNG using the {@link #setSeed(long)} method inherited
* from {@link Random}. Calls to this method will have no effect.
* Instead the seed must be set by a constructor.</em>
* <em>NOTE: Because instances of this class require 160-bit seeds, it is not possible to seed this RNG using the
* {@link #setSeed(long)} method inherited from {@link Random}. Calls to this method will have no effect. Instead the
* seed must be set by a constructor.</em>
* </p>
*
*
* @author Daniel Dyer
* @since 1.2
*/
public class XORShiftRNG extends Random {
// Lock to prevent concurrent modification of the RNG's internal state.
private final ReentrantLock lock = new ReentrantLock();

private final byte[] seed;

// Previously used an array for state but using separate fields proved to be
Expand All @@ -52,9 +49,7 @@ public class XORShiftRNG extends Random {

/**
* Creates an RNG and seeds it with the specified seed data.
*
* @param seed
* The seed data used to initialise the RNG.
*
*/
public XORShiftRNG() {
this.seed = new byte[SEED_SIZE_BYTES];
Expand All @@ -67,16 +62,10 @@ public XORShiftRNG() {
this.state5 = state[4];
}

/**
* {@inheritDoc}
*/
public byte[] getSeed() {
return seed.clone();
}

/**
* {@inheritDoc}
*/
@Override
protected int next(int bits) {
try {
Expand All @@ -94,18 +83,10 @@ protected int next(int bits) {
}
}

// Mask for casting a byte to an int, bit-by-bit (with
// bitwise AND) with no special consideration for the sign bit.
private static final int BITWISE_BYTE_TO_INT = 0x000000FF;

private static Random SEED_GENERATOR = new Random();
private static final int SEED_SIZE_BYTES = 20; // Needs 5 32-bit integers.
private static final long serialVersionUID = -1843001897066722618L;

/**
* Take four bytes from the specified position in the specified block and convert them into a 32-bit int, using the
* big-endian convention.
*
*
* @param bytes
* The data to read from.
* @param offset
Expand All @@ -120,7 +101,7 @@ public static int convertBytesToInt(byte[] bytes, int offset) {
/**
* Convert an array of bytes into an array of ints. 4 bytes from the input data map to a single int in the output
* data.
*
*
* @param bytes
* The data to read from.
* @return An array of 32-bit integers constructed from the data.
Expand All @@ -136,4 +117,11 @@ public static int[] convertBytesToInts(byte[] bytes) {
}
return ints;
}

// Mask for casting a byte to an int, bit-by-bit (with
// bitwise AND) with no special consideration for the sign bit.
private static final int BITWISE_BYTE_TO_INT = 0x000000FF;
private static Random SEED_GENERATOR = new Random();
private static final int SEED_SIZE_BYTES = 20; // Needs 5 32-bit integers.
private static final long serialVersionUID = -1843001897066722618L;
}

0 comments on commit f28ccb5

Please sign in to comment.