Custom non-iterable interval types

There are circumstances where a range of numbers is non-iterable. For example, suppose you want to encapsulate an inclusive range of real numbers between two endpoints. Such a set would be inclusive to a theoretically infinite set of numbers even between the values 1 and 1.001. Iterating across the set is meaningless.

To create a non-iterable interval type, create a new class that descends from the class AbstractInterval, parameterized using Gosu generics on the class of the object across which it iterates. For example, to iterate across MyClass objects, mark your class to extend AbstractInterval<MyClass>.

The class to iterate across must implement the Comparable interface.

A non-iterable interval cannot be used in for loop declarations or other types of iteration.