* Map index operator * @this {!FieldModelMap} * @param {!number} index Map index * @returns {[!FieldModel]} Base field model value
(index)
| 2978 | * @returns {[!FieldModel]} Base field model value |
| 2979 | */ |
| 2980 | getItem (index) { |
| 2981 | console.assert(((this._buffer.offset + this.fbeOffset + this.fbeSize) <= this._buffer.size), 'Model is broken!') |
| 2982 | |
| 2983 | let fbeMapOffset = this.readUInt32(this.fbeOffset) |
| 2984 | console.assert(((fbeMapOffset > 0) && ((this._buffer.offset + fbeMapOffset + 4) <= this._buffer.size)), 'Model is broken!') |
| 2985 | |
| 2986 | let fbeMapSize = this.readUInt32(fbeMapOffset) |
| 2987 | if (index >= fbeMapSize) { |
| 2988 | throw new Error('Index is out of bounds!') |
| 2989 | } |
| 2990 | |
| 2991 | this._modelKey.fbeOffset = fbeMapOffset + 4 |
| 2992 | this._modelValue.fbeOffset = fbeMapOffset + 4 + this._modelKey.fbeSize |
| 2993 | this._modelKey.fbeShift(index * (this._modelKey.fbeSize + this._modelValue.fbeSize)) |
| 2994 | this._modelValue.fbeShift(index * (this._modelKey.fbeSize + this._modelValue.fbeSize)) |
| 2995 | return [this._modelKey, this._modelValue] |
| 2996 | } |
| 2997 | |
| 2998 | /** |
| 2999 | * Resize the map and get its first model |
no test coverage detected