1 // automatically generated by the FlatBuffers compiler, do not modify
2 
3 package MyGame.Example
4 
5 import java.nio.*
6 import kotlin.math.sign
7 import com.google.flatbuffers.*
8 
9 @Suppress("unused")
10 @ExperimentalUnsignedTypes
11 class Stat : Table() {
12 
__initnull13     fun __init(_i: Int, _bb: ByteBuffer)  {
14         __reset(_i, _bb)
15     }
__assignnull16     fun __assign(_i: Int, _bb: ByteBuffer) : Stat {
17         __init(_i, _bb)
18         return this
19     }
20     val id : String?
21         get() {
22             val o = __offset(4)
23             return if (o != 0) __string(o + bb_pos) else null
24         }
25     val idAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1)
idInByteBuffernull26     fun idInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
27     val val_ : Long
28         get() {
29             val o = __offset(6)
30             return if(o != 0) bb.getLong(o + bb_pos) else 0L
31         }
mutateVal_null32     fun mutateVal_(val_: Long) : Boolean {
33         val o = __offset(6)
34         return if (o != 0) {
35             bb.putLong(o + bb_pos, val_)
36             true
37         } else {
38             false
39         }
40     }
41     val count : UShort
42         get() {
43             val o = __offset(8)
44             return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
45         }
mutateCountnull46     fun mutateCount(count: UShort) : Boolean {
47         val o = __offset(8)
48         return if (o != 0) {
49             bb.putShort(o + bb_pos, count.toShort())
50             true
51         } else {
52             false
53         }
54     }
keysComparenull55     override fun keysCompare(o1: Int, o2: Int, _bb: ByteBuffer) : Int {
56         val val_1 = _bb.getShort(__offset(8, o1, _bb))
57         val val_2 = _bb.getShort(__offset(8, o2, _bb))
58         return (val_1 - val_2).sign
59     }
60     companion object {
validateVersionnull61         fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
62         fun getRootAsStat(_bb: ByteBuffer): Stat = getRootAsStat(_bb, Stat())
63         fun getRootAsStat(_bb: ByteBuffer, obj: Stat): Stat {
64             _bb.order(ByteOrder.LITTLE_ENDIAN)
65             return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
66         }
createStatnull67         fun createStat(builder: FlatBufferBuilder, idOffset: Int, val_: Long, count: UShort) : Int {
68             builder.startTable(3)
69             addVal_(builder, val_)
70             addId(builder, idOffset)
71             addCount(builder, count)
72             return endStat(builder)
73         }
startStatnull74         fun startStat(builder: FlatBufferBuilder) = builder.startTable(3)
75         fun addId(builder: FlatBufferBuilder, id: Int) = builder.addOffset(0, id, 0)
76         fun addVal_(builder: FlatBufferBuilder, val_: Long) = builder.addLong(1, val_, 0L)
77         fun addCount(builder: FlatBufferBuilder, count: UShort) = builder.addShort(2, count.toShort(), 0)
78         fun endStat(builder: FlatBufferBuilder) : Int {
79             val o = builder.endTable()
80             return o
81         }
__lookup_by_keynull82         fun __lookup_by_key(obj: Stat?, vectorLocation: Int, key: UShort, bb: ByteBuffer) : Stat? {
83             var span = bb.getInt(vectorLocation - 4)
84             var start = 0
85             while (span != 0) {
86                 var middle = span / 2
87                 val tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb)
88                 val value = bb.getShort(__offset(8, bb.capacity() - tableOffset, bb)).toUShort()
89                 val comp = value.compareTo(key)
90                 when {
91                     comp > 0 -> span = middle
92                     comp < 0 -> {
93                         middle++
94                         start += middle
95                         span -= middle
96                     }
97                     else -> {
98                         return (obj ?: Stat()).__assign(tableOffset, bb)
99                     }
100                 }
101             }
102             return null
103         }
104     }
105 }
106