Example #1
0
        /// <inheritdoc />
        public bool Equals(CtfFloatingPointDescriptor other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (Align != other.Align)
            {
                return(false);
            }
            if (!ByteOrder.Equals(other.ByteOrder))
            {
                return(false);
            }
            if (Exponent != other.Exponent)
            {
                return(false);
            }
            return(Mantissa == other.Mantissa);
        }
Example #2
0
        /// <summary>
        ///     Creates a new big-endian buffer whose content  is a merged copy of the specified <see cref="Array" />.
        ///     The new buffer's <see cref="IByteBuffer.ReaderIndex" /> and <see cref="IByteBuffer.WriterIndex" />
        ///     are <c>0</c> and <see cref="IByteBuffer.Capacity" /> respectively.
        /// </summary>
        /// <param name="buffers">Buffers we're going to copy.</param>
        /// <returns>The new buffer that copies the contents of <see cref="buffers" />.</returns>
        public static IByteBuffer CopiedBuffer(params IByteBuffer[] buffers)
        {
            if (buffers.Length == 0)
            {
                return(Empty);
            }

            if (buffers.Length == 1)
            {
                return(CopiedBuffer(buffers[0]));
            }

            long      newlength = 0;
            ByteOrder order     = buffers[0].Order;

            foreach (IByteBuffer buffer in buffers)
            {
                newlength += buffer.ReadableBytes;
            }

            var mergedArray = new byte[newlength];

            for (int i = 0, j = 0; i < buffers.Length; i++)
            {
                IByteBuffer b = buffers[i];
                if (!order.Equals(b.Order))
                {
                    throw new ArgumentException($"The byte orders in {nameof(buffers)} are inconsistent ");
                }

                int bLen = b.ReadableBytes;
                b.GetBytes(b.ReaderIndex, mergedArray, j, bLen);
                j += bLen;
            }

            return(WrappedBuffer(mergedArray).WithOrder(order));
        }