// Read a set of strings var set = new HashSet(); var protocol = new TBinaryProtocol(new TMemoryBuffer(byteArray)); var elemType = protocol.ReadSetBegin(); for (var i = 0; i < elemType.Count; i++) { var elem = protocol.ReadString(); set.Add(elem); } protocol.ReadSetEnd(); // indicate end of set
// Read a map of integers to lists of doubles var map = new DictionaryIn this example, we use the TBinaryProtocol to deserialize a map of integers to lists of doubles from a byte array. We use the ReadMapBegin method to read the map header, then loop through the key-value pairs. For each value, we use the ReadListBegin method to read the list header, loop through the elements, and add them to a List>(); var protocol = new TBinaryProtocol(new TMemoryBuffer(byteArray)); var elemType = protocol.ReadMapBegin(); for (var i = 0; i < elemType.Count; i++) { var key = protocol.ReadInt32(); var list = new List (); var listType = protocol.ReadListBegin(); for (var j = 0; j < listType.Count; j++) { var elem = protocol.ReadDouble(); list.Add(elem); } protocol.ReadListEnd(); // indicate end of list map[key] = list; } protocol.ReadMapEnd(); // indicate end of map