001package squidpony.squidmath; 002 003/** 004 * A simple interface for RandomnessSources that have the additional property of a state that can be re-set. 005 * Created by Tommy Ettinger on 9/15/2015. 006 */ 007public interface StatefulRandomness extends RandomnessSource { 008 /** 009 * Get the current internal state of the StatefulRandomness as a long. 010 * @return the current internal state of this object. 011 */ 012 long getState(); 013 014 /** 015 * Set the current internal state of this StatefulRandomness with a long. 016 * 017 * @param state a 64-bit long. You should avoid passing 0, even though some implementations can handle that. 018 */ 019 void setState(long state); 020 021 /** 022 * Produces a copy of this StatefulRandomness that, if next() and/or nextLong() are called on this object and the 023 * copy, both will generate the same sequence of random numbers from the point copy() was called. This just needs to 024 * copy the state so it isn't shared, usually, and produce a new value with the same exact state. 025 * 026 * @return a copy of this StatefulRandomness 027 */ 028 @Override 029 RandomnessSource copy(); 030}