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:
tianyapiaozi
2017-03-30 00:51:12 +08:00
committed by Wouter van Oortmerssen
parent 89041a1686
commit a5cc2092a6
20 changed files with 564 additions and 17 deletions

View File

@@ -1291,7 +1291,9 @@ void GenStruct(StructDef &struct_def, std::string *code_ptr) {
code += "); }\n";
}
}
if (struct_def.has_key) {
// Only generate key compare function for table,
// because `key_field` is not set for struct
if (struct_def.has_key && !struct_def.fixed) {
if (lang_.language == IDLOptions::kJava) {
code += "\n @Override\n protected int keysCompare(";
code += "Integer o1, Integer o2, ByteBuffer _bb) {";