blob: 30444212e36c52ea61ee674504841bd1d017b003 [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001// automatically generated by the FlatBuffers compiler, do not modify
2
3package MyGame.Example;
4
5import java.nio.*;
6import java.lang.*;
7import java.util.*;
8import com.google.flatbuffers.*;
9
10@SuppressWarnings("unused")
11public final class Stat extends Table {
Austin Schuh2dd86a92022-09-14 21:19:23 -070012 public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_8(); }
Austin Schuhe89fa2d2019-08-14 20:24:23 -070013 public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); }
14 public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
15 public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
16 public Stat __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
17
18 public String id() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
19 public ByteBuffer idAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
20 public ByteBuffer idInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
21 public long val() { int o = __offset(6); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
22 public boolean mutateVal(long val) { int o = __offset(6); if (o != 0) { bb.putLong(o + bb_pos, val); return true; } else { return false; } }
23 public int count() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
James Kuszmaul8e62b022022-03-22 09:33:25 -070024 public boolean mutateCount(int count) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos, (short) count); return true; } else { return false; } }
Austin Schuhe89fa2d2019-08-14 20:24:23 -070025
26 public static int createStat(FlatBufferBuilder builder,
27 int idOffset,
28 long val,
29 int count) {
30 builder.startTable(3);
31 Stat.addVal(builder, val);
32 Stat.addId(builder, idOffset);
33 Stat.addCount(builder, count);
34 return Stat.endStat(builder);
35 }
36
37 public static void startStat(FlatBufferBuilder builder) { builder.startTable(3); }
38 public static void addId(FlatBufferBuilder builder, int idOffset) { builder.addOffset(0, idOffset, 0); }
39 public static void addVal(FlatBufferBuilder builder, long val) { builder.addLong(1, val, 0L); }
Austin Schuh2dd86a92022-09-14 21:19:23 -070040 public static void addCount(FlatBufferBuilder builder, int count) { builder.addShort((short) count); builder.slot(2); }
Austin Schuhe89fa2d2019-08-14 20:24:23 -070041 public static int endStat(FlatBufferBuilder builder) {
42 int o = builder.endTable();
43 return o;
44 }
Austin Schuh272c6132020-11-14 16:37:52 -080045
James Kuszmaul8e62b022022-03-22 09:33:25 -070046 @Override
47 protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) {
48 int val_1 = _bb.getShort(__offset(8, o1, _bb)) & 0xFFFF;
49 int val_2 = _bb.getShort(__offset(8, o2, _bb)) & 0xFFFF;
50 return val_1 > val_2 ? 1 : val_1 < val_2 ? -1 : 0;
51 }
52
53 public static Stat __lookup_by_key(Stat obj, int vectorLocation, int key, ByteBuffer bb) {
54 int span = bb.getInt(vectorLocation - 4);
55 int start = 0;
56 while (span != 0) {
57 int middle = span / 2;
58 int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
59 int val = bb.getShort(__offset(8, bb.capacity() - tableOffset, bb)) & 0xFFFF;
60 int comp = val > key ? 1 : val < key ? -1 : 0;
61 if (comp > 0) {
62 span = middle;
63 } else if (comp < 0) {
64 middle++;
65 start += middle;
66 span -= middle;
67 } else {
68 return (obj == null ? new Stat() : obj).__assign(tableOffset, bb);
69 }
70 }
71 return null;
72 }
73
Austin Schuh272c6132020-11-14 16:37:52 -080074 public static final class Vector extends BaseVector {
75 public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
76
77 public Stat get(int j) { return get(new Stat(), j); }
78 public Stat get(Stat obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
James Kuszmaul8e62b022022-03-22 09:33:25 -070079 public Stat getByKey(int key) { return __lookup_by_key(null, __vector(), key, bb); }
80 public Stat getByKey(Stat obj, int key) { return __lookup_by_key(obj, __vector(), key, bb); }
81 }
82 public StatT unpack() {
83 StatT _o = new StatT();
84 unpackTo(_o);
85 return _o;
86 }
87 public void unpackTo(StatT _o) {
88 String _oId = id();
89 _o.setId(_oId);
90 long _oVal = val();
91 _o.setVal(_oVal);
92 int _oCount = count();
93 _o.setCount(_oCount);
94 }
95 public static int pack(FlatBufferBuilder builder, StatT _o) {
96 if (_o == null) return 0;
97 int _id = _o.getId() == null ? 0 : builder.createString(_o.getId());
98 return createStat(
99 builder,
100 _id,
101 _o.getVal(),
102 _o.getCount());
Austin Schuh272c6132020-11-14 16:37:52 -0800103 }
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700104}
105