code: public static int writeShorts(final BitOutput bitOutput, final int lengthSize, final int shortSize,
                                    final short[] value)
              throws IOException {
          if (bitOutput == null) {
              throw new NullPointerException("bitOutput is null");
          }
          requireValidSizeInt(true, lengthSize);
          requireValidSizeShort(false, shortSize);
          if (value == null) {
              throw new NullPointerException("value is null");
          }
          final int length = value.length & ((1 << lengthSize) - 1);
          bitOutput.writeInt(true, lengthSize, length);
          for (int i = 0; i < length; i++) {
              bitOutput.writeShort(false, shortSize, value[i]);
          }
          return length;
      }
docs: -----------------------------------------------------------------------------------------------------------------