Added more support for fast enums
This commit is contained in:
parent
a91383f9c4
commit
814e6fe339
|
@ -343,13 +343,12 @@ public enum FourCornerDotCake {
|
|||
/// NOTE: Every lowest (512) numerator trigger a fraction.
|
||||
FC_NCR1632_XN(0x38000, 32768, "New Counting Rods X-Numerator"),
|
||||
;
|
||||
|
||||
private static final FourCornerDotCake[] VALUES = values();
|
||||
private final int start;
|
||||
private final int stop;
|
||||
private final String nameSpec;
|
||||
private final String description;
|
||||
private final FourCornerX00PetitVide[] videPoints;
|
||||
private static final FourCornerDotCake[] VALUES = values();
|
||||
|
||||
private FourCornerDotCake(int start, int size) {
|
||||
this(start, size, new FourCornerX00PetitVide[] {}, null);
|
||||
|
@ -471,6 +470,14 @@ public enum FourCornerDotCake {
|
|||
return videPoints;
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FourCornerDotCake valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
|
||||
public static Optional<FourCornerDotCake> valueFromCakePoint(int cakePoint) {
|
||||
for (FourCornerDotCake cakeSlice : VALUES) {
|
||||
if (cakeSlice.contains(cakePoint)) {
|
||||
|
|
|
@ -44,9 +44,18 @@ public enum FCDotAMD0110DashSA implements FourCornerDotColleGram5 {
|
|||
T010__DECIMAL_8,
|
||||
T010__DECIMAL_9,
|
||||
;
|
||||
static final private FCDotAMD0110DashSA[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_AMD0110_SA.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotAMD0110DashSA valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,18 @@ public enum FCDotBMW0102DashS2 implements FourCornerDotColleGram5 {
|
|||
T002__BIT_0,
|
||||
T002__BIT_1,
|
||||
;
|
||||
static final private FCDotBMW0102DashS2[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_BMW0102_S2.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotBMW0102DashS2 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,9 +38,18 @@ public enum FCDotDNA0104DashS4 implements FourCornerDotColleGram5 {
|
|||
T004__DNA_ADENINE,
|
||||
T004__DNA_THYMINE,
|
||||
;
|
||||
static final private FCDotDNA0104DashS4[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_DNA0104_S4.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotDNA0104DashS4 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -290,9 +290,36 @@ public enum FCDotIBM1616DashH8 implements FourCornerDotColleGram5 {
|
|||
T256__HEX_FE,
|
||||
T256__HEX_FF,
|
||||
;
|
||||
static final private FCDotIBM1616DashH8[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_IBM1616_H8.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotIBM1616DashH8 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
|
||||
public static FCDotIBM1616DashH8[] convertAll(final byte[] data) {
|
||||
final int dataLength = data.length;
|
||||
final FCDotIBM1616DashH8[] result = new FCDotIBM1616DashH8[dataLength];
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
result[i] = VALUES[Byte.toUnsignedInt(data[i])];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static byte[] convertAll(final FCDotIBM1616DashH8[] data) {
|
||||
final int dataLength = data.length;
|
||||
final byte[] result = new byte[dataLength];
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
result[i] = (byte)data[i].ordinal();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,9 +60,18 @@ public enum FCDotICL0126Dash9B implements FourCornerDotColleGram5 {
|
|||
T026__LOW_Y,
|
||||
T026__LOW_Z,
|
||||
;
|
||||
static final private FCDotICL0126Dash9B[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_ICL0126_9B.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotICL0126Dash9B valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,9 +39,18 @@ public enum FCDotNEC0105DashS5 implements FourCornerDotColleGram5 {
|
|||
T005__NXX_004,
|
||||
T005__NXX_005,
|
||||
;
|
||||
static final private FCDotNEC0105DashS5[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_NEC0105_S5.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotNEC0105DashS5 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,9 +61,18 @@ public enum FCDotNES0127Dash9C implements FourCornerDotColleGram5 {
|
|||
T027__NXX_026,
|
||||
T027__NXX_027,
|
||||
;
|
||||
static final private FCDotNES0127Dash9C[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_NES0127_9C.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotNES0127Dash9C valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,9 +39,18 @@ public enum FCDotNXP0103DashS3 implements FourCornerDotColleGram5 {
|
|||
/// And this has a higher cake point dot index number as STATE_LOW.
|
||||
T003__STATE_HIGH,
|
||||
;
|
||||
static final private FCDotNXP0103DashS3[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_NXP0103_S3.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotNXP0103DashS3 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,9 +42,18 @@ public enum FCDotOCE0801DashH3 implements FourCornerDotColleGram5 {
|
|||
T008__NXX_007,
|
||||
T008__NXX_008,
|
||||
;
|
||||
static final private FCDotOCE0801DashH3[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_OCE0801_H3.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotOCE0801DashH3 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,9 +98,18 @@ public enum FCDotOCE0808DashH6 implements FourCornerDotColleGram5 {
|
|||
T064__NXX_063,
|
||||
T064__NXX_064,
|
||||
;
|
||||
static final private FCDotOCE0808DashH6[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_OCE0808_H6.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotOCE0808DashH6 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -546,9 +546,18 @@ public enum FCDotOCE0864DashH9 implements FourCornerDotColleGram5 {
|
|||
T512__NXX_511,
|
||||
T512__NXX_512,
|
||||
;
|
||||
static final private FCDotOCE0864DashH9[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_OCE0864_H9.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotOCE0864DashH9 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,18 @@ public enum FCDotSCO0106DashS6 implements FourCornerDotColleGram5 {
|
|||
T006__NXX_005,
|
||||
T006__NXX_006,
|
||||
;
|
||||
static final private FCDotSCO0106DashS6[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_SCO0106_S6.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotSCO0106DashS6 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,18 @@ import org.x4o.fc18.cake2.FourCornerDotColleGram5;
|
|||
public enum FCDotUWU0101DashS1 implements FourCornerDotColleGram5 {
|
||||
T001__WORD_SPACE,
|
||||
;
|
||||
static final private FCDotUWU0101DashS1[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_UWU0101_S1.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotUWU0101DashS1 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,18 @@ public enum FCDotW3C0107DashS7 implements FourCornerDotColleGram5 {
|
|||
T007__NXX_006,
|
||||
T007__NXX_007,
|
||||
;
|
||||
static final private FCDotW3C0107DashS7[] VALUES = values(); // values() is slow method
|
||||
|
||||
@Override
|
||||
public int cakePointDotIndex() {
|
||||
return FourCornerDotCake.FC_W3C0107_S7.getStart() + ordinal();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotW3C0107DashS7 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public enum FCDotCMD5401Dash2D implements FourCornerX06BaklavaPointSequence, Fou
|
|||
/// Write out an nether line which goes to the line below, also called a line feed with automatic carriage return.
|
||||
CMD_F4TTY0001_NL(FCDotCDC1604DashP6.NX02_B),
|
||||
;
|
||||
|
||||
private static final FCDotCMD5401Dash2D[] VALUES = values();
|
||||
private final FCDotCDC1604DashP6 selector;
|
||||
|
||||
private FCDotCMD5401Dash2D(FCDotCDC1604DashP6 selector) {
|
||||
|
@ -82,4 +82,12 @@ public enum FCDotCMD5401Dash2D implements FourCornerX06BaklavaPointSequence, Fou
|
|||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotCMD5401Dash2D valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ public enum FCDotDEC0801DashE10 implements FourCornerX06BaklavaPointSequence, Fo
|
|||
/// 8 gram of OCE (octals)
|
||||
E10_OCE0801_H3(FourCornerDotCake.FC_OCE0801_H3),
|
||||
;
|
||||
private static final FCDotDEC0801DashE10[] VALUES = values();
|
||||
|
||||
private final FourCornerDotCake displayCake;
|
||||
|
||||
|
@ -111,4 +112,12 @@ public enum FCDotDEC0801DashE10 implements FourCornerX06BaklavaPointSequence, Fo
|
|||
//result.add(FCDotCDC1604DashP6.SEQ_SALAH__EXCLAMATION.cakePointDotIndex()); // TODO: add api layer snake for head
|
||||
return result;
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotDEC0801DashE10 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public enum FCDotINC0801DashP8 implements FourCornerX06BaklavaPointSequence, Fou
|
|||
// Select lower case mode.
|
||||
INC_PIE9C_26(FourCornerDotCake.FC_PIE9C_26),
|
||||
;
|
||||
|
||||
private static final FCDotINC0801DashP8[] VALUES = values();
|
||||
private final FourCornerDotCake displayCake;
|
||||
|
||||
private FCDotINC0801DashP8(FourCornerDotCake displayCake) {
|
||||
|
@ -106,4 +106,12 @@ public enum FCDotINC0801DashP8 implements FourCornerX06BaklavaPointSequence, Fou
|
|||
//result.add(FCDotCDC1604DashP6.SEQ_SALAH__EXCLAMATION.cakePointDotIndex()); // TODO: add api layer snake for head
|
||||
return result;
|
||||
}
|
||||
|
||||
static public int valuesLength() {
|
||||
return VALUES.length;
|
||||
}
|
||||
|
||||
static public FCDotINC0801DashP8 valueOf(int idx) {
|
||||
return VALUES[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -631,7 +631,7 @@ public class FourCornerZionStenoLexer {
|
|||
private boolean handleINC(FourCornerZionStenoLexer lexer) {
|
||||
int cdcPoint = lexer.input.get(lexer.cdcDECScanIndex);
|
||||
if (FCDotCDC1604DashP6.isEscapePepper(cdcPoint)) {
|
||||
lexer.cdcDECModeInc = FCDotINC0801DashP8.values()[readEscapePepper3(lexer)];
|
||||
lexer.cdcDECModeInc = FCDotINC0801DashP8.valueOf(readEscapePepper3(lexer));
|
||||
return true;
|
||||
}
|
||||
if (FCDotCDC1604DashP6._SALAH_EXCLAMATION.baklavaPointDotIndex() == cdcPoint) {
|
||||
|
@ -650,7 +650,7 @@ public class FourCornerZionStenoLexer {
|
|||
private boolean handleE10(FourCornerZionStenoLexer lexer) {
|
||||
int cdcPoint = lexer.input.get(lexer.cdcDECScanIndex);
|
||||
if (FCDotCDC1604DashP6.isEscapePepper(cdcPoint)) {
|
||||
lexer.cdcDECModeE10 = FCDotDEC0801DashE10.values()[readEscapePepper3(lexer)];
|
||||
lexer.cdcDECModeE10 = FCDotDEC0801DashE10.valueOf(readEscapePepper3(lexer));
|
||||
return true;
|
||||
}
|
||||
if (FCDotCDC1604DashP6._SALAH_EXCLAMATION.baklavaPointDotIndex() == cdcPoint) {
|
||||
|
@ -735,7 +735,7 @@ public class FourCornerZionStenoLexer {
|
|||
}
|
||||
int terminatorOffZero = lexer.cdcDECModePie - FCDotCDC1604DashP6.NX01_A.ordinal();
|
||||
int numberIdxOffZero = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal();
|
||||
FourCornerDotCake slice = FourCornerDotCake.values()[terminatorOffZero + FourCornerDotCake.FC_PIE9C_01.ordinal()];
|
||||
FourCornerDotCake slice = FourCornerDotCake.valueOf(terminatorOffZero + FourCornerDotCake.FC_PIE9C_01.ordinal());
|
||||
lexer.handler.strobeWord(slice, numberIdxOffZero);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue