}
/// @endcond
+ /**
+ * Create a new array/vector and return a ByteBuffer to be filled later.
+ * Call {@link #endVector} after this method to get an offset to the beginning
+ * of vector.
+ *
+ * @param elem_size the size of each element in bytes.
+ * @param num_elems number of elements in the vector.
+ * @param alignment byte alignment.
+ * @return ByteBuffer with position and limit set to the space allocated for the array.
+ */
+ public ByteBuffer createUnintializedVector(int elem_size, int num_elems, int alignment) {
+ int length = elem_size * num_elems;
+ startVector(elem_size, num_elems, alignment);
+
+ bb.position(space -= length);
+
+ // Slice and limit the copy vector to point to the 'array'
+ ByteBuffer copy = bb.slice().order(ByteOrder.LITTLE_ENDIAN);
+ copy.limit(length);
+ return copy;
+ }
+
/**
+ * Create a vector of tables.
+ *
+ * @param offsets Offsets of the tables.
+ * @return Returns offset of the vector.
+ */
+ public int createVectorOfTables(int[] offsets) {
+ notNested();
+ startVector(Constants.SIZEOF_INT, offsets.length, Constants.SIZEOF_INT);
+ for(int i = offsets.length - 1; i >= 0; i--) addOffset(offsets[i]);
+ return endVector();
+ }
+
+ /**
+ * Create a vector of sorted by the key tables.
+ *
+ * @param obj Instance of the table subclass.
+ * @param offsets Offsets of the tables.
+ * @return Returns offset of the sorted vector.
+ */
+ public <T extends Table> int createSortedVectorOfTables(T obj, int[] offsets) {
+ obj.sortTables(offsets, bb);
+ return createVectorOfTables(offsets);
+ }
+
+ /**
* Encode the string `s` in the buffer using UTF-8. If {@code s} is
* already a {@link CharBuffer}, this method is allocation free.
*