Ejemplo n.º 1
0
    public ValueContainerImpl<T> read(final DataInput in) throws IOException {
      DataInputStream stream = (DataInputStream) in;
      final ValueContainerImpl<T> valueContainer = new ValueContainerImpl<T>();

      while (stream.available() > 0) {
        final int valueCount = DataInputOutputUtil.readSINT(in);
        if (valueCount < 0) {
          valueContainer.removeAllValues(-valueCount);
          valueContainer.setNeedsCompacting(true);
        } else {
          for (int valueIdx = 0; valueIdx < valueCount; valueIdx++) {
            final T value = myExternalizer.read(in);
            final int idCount = DataInputOutputUtil.readSINT(in);
            for (int i = 0; i < idCount; i++) {
              final int id = DataInputOutputUtil.readSINT(in);
              if (id < 0) {
                valueContainer.removeValue(-id, value);
                valueContainer.setNeedsCompacting(true);
              } else {
                valueContainer.addValue(id, value);
              }
            }
          }
        }
      }
      return valueContainer;
    }
 @Override
 public TIntArrayList read(final DataInput in) throws IOException {
   int size = DataInputOutputUtil.readSINT(in);
   if (size == Integer.MAX_VALUE) {
     return new TIntArrayList();
   } else if (size <= 0) {
     TIntArrayList result = new TIntArrayList(1);
     result.add(-size);
     return result;
   } else {
     TIntArrayList result = new TIntArrayList(size);
     for (int i = 0; i < size; i++) {
       result.add(DataInputOutputUtil.readINT(in));
     }
     return result;
   }
 }