uses plain Java arrays directly to keep heap allocation to a minimum. Includes some unit tests that seem to indicate the basic operations are correct. However, the following things are not implemented: * Shrinking the capacity when elements are removed * Optimal storage of each element in array vs. hash when entries are added out of order. A junit test case is there for this.
28 lines
569 B
Java
28 lines
569 B
Java
package lua.value;
|
|
|
|
import lua.Lua;
|
|
|
|
abstract
|
|
public class LNumber extends LValue {
|
|
|
|
public static final LString TYPE_NAME = new LString("number");
|
|
|
|
/** Compare for equivalence by using lua op comparator */
|
|
public boolean equals(Object o) {
|
|
if ( ! ( o instanceof LValue) )
|
|
return false;
|
|
LValue v = (LValue) o;
|
|
return this.luaBinCmpUnknown(Lua.OP_EQ, v );
|
|
}
|
|
|
|
public LString luaGetType() {
|
|
return TYPE_NAME;
|
|
}
|
|
|
|
/**
|
|
* Returns false by default for non-LNumbers, but subclasses of LNumber must
|
|
* override.
|
|
*/
|
|
public abstract boolean isInteger();
|
|
}
|