mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 06:05:17 +00:00
Support binary search for struct in cpp (#4245)
* Support binary search for struct in cpp CreateVectorOfSortedStruct is provided for convenience. * fix continuous-integration error * add generated files * compile Ability.cs in csharp test * compile Ability.cs in csharp * modify according to code review
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
89041a1686
commit
a5cc2092a6
@@ -379,22 +379,41 @@ class Monster extends Table
|
||||
return $o != 0 ? $this->__vector_len($o) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returnVectorOffset
|
||||
*/
|
||||
public function getTestarrayofsortedstruct($j)
|
||||
{
|
||||
$o = $this->__offset(62);
|
||||
$obj = new Ability();
|
||||
return $o != 0 ? $obj->init($this->__vector($o) + $j *8, $this->bb) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTestarrayofsortedstructLength()
|
||||
{
|
||||
$o = $this->__offset(62);
|
||||
return $o != 0 ? $this->__vector_len($o) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return void
|
||||
*/
|
||||
public static function startMonster(FlatBufferBuilder $builder)
|
||||
{
|
||||
$builder->StartObject(29);
|
||||
$builder->StartObject(30);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return Monster
|
||||
*/
|
||||
public static function createMonster(FlatBufferBuilder $builder, $pos, $mana, $hp, $name, $inventory, $color, $test_type, $test, $test4, $testarrayofstring, $testarrayoftables, $enemy, $testnestedflatbuffer, $testempty, $testbool, $testhashs32_fnv1, $testhashu32_fnv1, $testhashs64_fnv1, $testhashu64_fnv1, $testhashs32_fnv1a, $testhashu32_fnv1a, $testhashs64_fnv1a, $testhashu64_fnv1a, $testarrayofbools, $testf, $testf2, $testf3, $testarrayofstring2)
|
||||
public static function createMonster(FlatBufferBuilder $builder, $pos, $mana, $hp, $name, $inventory, $color, $test_type, $test, $test4, $testarrayofstring, $testarrayoftables, $enemy, $testnestedflatbuffer, $testempty, $testbool, $testhashs32_fnv1, $testhashu32_fnv1, $testhashs64_fnv1, $testhashu64_fnv1, $testhashs32_fnv1a, $testhashu32_fnv1a, $testhashs64_fnv1a, $testhashu64_fnv1a, $testarrayofbools, $testf, $testf2, $testf3, $testarrayofstring2, $testarrayofsortedstruct)
|
||||
{
|
||||
$builder->startObject(29);
|
||||
$builder->startObject(30);
|
||||
self::addPos($builder, $pos);
|
||||
self::addMana($builder, $mana);
|
||||
self::addHp($builder, $hp);
|
||||
@@ -423,6 +442,7 @@ class Monster extends Table
|
||||
self::addTestf2($builder, $testf2);
|
||||
self::addTestf3($builder, $testf3);
|
||||
self::addTestarrayofstring2($builder, $testarrayofstring2);
|
||||
self::addTestarrayofsortedstruct($builder, $testarrayofsortedstruct);
|
||||
$o = $builder->endObject();
|
||||
$builder->required($o, 10); // name
|
||||
return $o;
|
||||
@@ -871,6 +891,40 @@ class Monster extends Table
|
||||
$builder->startVector(4, $numElems, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param VectorOffset
|
||||
* @return void
|
||||
*/
|
||||
public static function addTestarrayofsortedstruct(FlatBufferBuilder $builder, $testarrayofsortedstruct)
|
||||
{
|
||||
$builder->addOffsetX(29, $testarrayofsortedstruct, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param array offset array
|
||||
* @return int vector offset
|
||||
*/
|
||||
public static function createTestarrayofsortedstructVector(FlatBufferBuilder $builder, array $data)
|
||||
{
|
||||
$builder->startVector(8, count($data), 4);
|
||||
for ($i = count($data) - 1; $i >= 0; $i--) {
|
||||
$builder->addOffset($data[$i]);
|
||||
}
|
||||
return $builder->endVector();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param int $numElems
|
||||
* @return void
|
||||
*/
|
||||
public static function startTestarrayofsortedstructVector(FlatBufferBuilder $builder, $numElems)
|
||||
{
|
||||
$builder->startVector(8, $numElems, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return int table offset
|
||||
|
||||
Reference in New Issue
Block a user