如何在协议缓冲区中表示二维数组? [英] How can I represent a 2-dimensional array in Protocol Buffers?

查看:35
本文介绍了如何在协议缓冲区中表示二维数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在协议缓冲区中表示二维数组?

How can I represent a 2-dimensional array in Protocol Buffers?

我需要将 intdouble 二维数组存储为 PB 消息上的一个字段,例如:

I need to store int and double 2d arrays as a field on a PB message, for example:

int[][] multi = new int[5][10];

我使用 C++、Java 和 C#.

I'm using C++, Java and C#.

提前致谢.

推荐答案

协议中没有直接支持.最好的办法是拥有一组重复的对象,每个对象 有一个数组 - 即

There is no direct support in the protocol for this. Your best bet is to have a repeated set of objects that have an array each - i.e.

message Foo {
    repeated int items = 1;
}
...
repeated Foo foos = 1;

这篇关于如何在协议缓冲区中表示二维数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆