Background:I'm writing a genetic algorithm to be used to control the weights of a neural net.To specify the bases (bits of the code) of the DNA, I'm allowing the caller to pass in a List<T> of all the possible bases. When I need to mutate a base or generate a random sequence, it will be based on this passed List.So what's the problem?I didn't realize this until now, but the neural net may require a massive List of possible weights (possibly thousands of different bases; our DNA has 4). Obviously, passing in a List that actually contains every possible base would be very inefficient; it could potentially be huge.My solution was to implement a Range class that implements List that can represent all the possible bases by only storing 3 numbers (assuming they follow a regular pattern). My attempt is on CR here: Range Code Review.It kind of solves the problem, but has its own problems:It barely implements List; half of the required methods throw an UnsupportedOperationException, since most of the operations don't make sense for a Range.Since Java doesn't seem to have a usable Number interface that allows for math, I'm using the most general number type I could think of; a Double. Anyone using the Range will need to and from Double if they're using another type.The container is subject to floating-point errors since the whole container relies heavily on math to get elements.My question:I need to be able to allow the user of the genetic algorithm to specify the bases that they want it to use. The bases could be of any type, and there could be any number of possible bases.How can I allow them to specify all the possible bases without using a potentially inefficient like storing every possible base explicitly in a list? 
How can my genetic algorithm accept an arbitrary number of bases of any type, without accepting a List?
java
Make an interface for the features you need for bases, or use an already existing interface.Just need to generate new random bases?  Make an interface to do thatinterface BaseGenerator<T> {    T randomBase();}or use an already existing interface, like Supplier<T>.Chromosome<T> mutate(Chromosome<T> old, Supplier<T> randomBaseGenerator) {    [...]}