diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-19 13:49:03 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-19 13:49:03 +0000 |
commit | ac849228490d5a0e2d3f048d649297d5c59b6ade (patch) | |
tree | 6314f2c06f37e67dec5827c3f94e25cf844a085c /src/library/scala/runtime/BoxedShort.java | |
parent | d6c0efe5b4b89a0337f1cdcdabf8c607d81f4ae1 (diff) | |
download | scala-ac849228490d5a0e2d3f048d649297d5c59b6ade.tar.gz scala-ac849228490d5a0e2d3f048d649297d5c59b6ade.tar.bz2 scala-ac849228490d5a0e2d3f048d649297d5c59b6ade.zip |
Switching to the new build system and to the ne...
Switching to the new build system and to the new build system. This is a
MAJOR commit, so be careful when updating.
Diffstat (limited to 'src/library/scala/runtime/BoxedShort.java')
-rw-r--r-- | src/library/scala/runtime/BoxedShort.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/library/scala/runtime/BoxedShort.java b/src/library/scala/runtime/BoxedShort.java new file mode 100644 index 0000000000..f1074c7b7f --- /dev/null +++ b/src/library/scala/runtime/BoxedShort.java @@ -0,0 +1,59 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2005, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ +package scala.runtime; + +public final class BoxedShort extends BoxedNumber + implements java.io.Serializable +{ + + private static final int MinHashed = -128; + private static final int MaxHashed = 127; + private static BoxedShort[] canonical = new BoxedShort[MaxHashed - MinHashed + 1]; + + static { + for (int i = MinHashed; i <= MaxHashed; i++) + canonical[i - MinHashed] = new BoxedShort((short)i); + } + + public static BoxedShort box(short value) { + if (MinHashed <= value && value <= MaxHashed) return canonical[value - MinHashed]; + else return new BoxedShort(value); + } + + public final short value; + + private BoxedShort(short value) { this.value = value; } + + public byte byteValue() { return (byte)value; } + public short shortValue() { return (short)value; } + public char charValue() { return (char)value; } + public int intValue() { return (int)value; } + public long longValue() { return (long)value; } + public float floatValue() { return (float)value; } + public double doubleValue() { return (double)value; } + + public final boolean $eq$eq(java.lang.Object other) { + return equals(other); + } + + public final boolean $bang$eq(java.lang.Object other) { + return !equals(other); + } + + public boolean equals(java.lang.Object other) { + return other instanceof BoxedNumber && value == ((BoxedNumber) other).shortValue(); + } + + public int hashCode() { + return value; + } + + public String toString() { + return String.valueOf(value); + } +} |