当前位置: 首页>>代码示例>>C#>>正文


C# ByteBuffer.Remaining方法代码示例

本文整理汇总了C#中ByteBuffer.Remaining方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Remaining方法的具体用法?C# ByteBuffer.Remaining怎么用?C# ByteBuffer.Remaining使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.Remaining方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BoundedByteBufferSend

        public BoundedByteBufferSend(ByteBuffer buffer)
        {
            this.Buffer = buffer;

            if (buffer.Remaining() > int.MaxValue - this.sizeBuffer.Limit())
            {
                throw new ArgumentException("Attempt to create a bounded buffer of " + buffer.Length + "bytes, but the maximum allowable size for a bounded buffer is " + (int.MaxValue - this.sizeBuffer.Length));
            }

            this.sizeBuffer.PutInt(buffer.Limit());
            this.sizeBuffer.Rewind();
        }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:12,代码来源:BoundedByteBufferSend.cs

示例2: Put

 public ByteBuffer Put(ByteBuffer src)
 {
     if (src == this)
         throw new ArgumentException("Source cannot be destination");
     int n = src.Remaining();
     if (n > Remaining())
         throw new InternalBufferOverflowException();
     for (int i = 0; i < n; i++)
         Put(src.Get());
     return this;
 }
开发者ID:hasancelik,项目名称:hazelcast-csharp-client,代码行数:11,代码来源:ByteBuffer.cs

示例3: Encode

		// end input remaining
		/// <summary>
		/// Performs Base64 encoding on the <code>raw</code> ByteBuffer,
		/// writing it to the <code>encoded</code> CharBuffer.
		/// </summary>
		/// <remarks>
		/// Performs Base64 encoding on the <code>raw</code> ByteBuffer,
		/// writing it to the <code>encoded</code> CharBuffer.
		/// This is an experimental feature. Currently it does not
		/// pass along any options (such as
		/// <see cref="DoBreakLines">DoBreakLines</see>
		/// or
		/// <see cref="Gzip">Gzip</see>
		/// .
		/// </remarks>
		/// <param name="raw">input buffer</param>
		/// <param name="encoded">output buffer</param>
		/// <since>2.3</since>
		public static void Encode(ByteBuffer raw, CharBuffer encoded)
		{
			byte[] raw3 = new byte[3];
			byte[] enc4 = new byte[4];
			while (raw.HasRemaining())
			{
				int rem = Math.Min(3, raw.Remaining());
				raw.Get(raw3, 0, rem);
				Couchbase.Lite.Support.Base64.Encode3to4(enc4, raw3, rem, Couchbase.Lite.Support.Base64
					.NoOptions);
				for (int i = 0; i < 4; i++)
				{
					encoded.Put((char)(enc4[i] & unchecked((int)(0xFF))));
				}
			}
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:34,代码来源:Base64.cs

示例4: Put

        /// <summary>
        /// Relative bulk <c>Put</c> method.  This method transfers the butes remaining in the given source buffer 
        /// into this buffer, starting at each buffer's current position.  The positions of both buffers are
        /// then incrementend by <c>n</c>.
        /// </summary>
        /// <param name="src">the source buffer from which bytes are to be read; must not be this buffer.</param>
        /// <returns>This buffer</returns>
        public ByteBuffer Put( ByteBuffer src )
        {
            if( src == this )
                throw new ArgumentException( "The source buffer cannot be the same as this buffer." );
            if( src.Remaining() > Remaining() )
                throw new OverflowException("There is insufficient space in this buffer for the remaining bytes in the source buffer.");

            while( src.HasRemaining )
                _bytes[_pos++] = src.Get();

            return this;
        }
开发者ID:patrickmaster,项目名称:electre-tri,代码行数:19,代码来源:ByteBuffer.cs

示例5: Equals

        protected bool Equals(ByteBuffer other)
        {
            if (this.Remaining() != other.Remaining())
            {
                return false;
            }

            var p = (int)this.Position;

            for (int i = this.Limit() - 1, j = other.Limit() - 1; i >= p; i--, j--)
            {
                if (!Equals(this.Get(i), other.Get(j)))
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:19,代码来源:ByteBuffer.cs

示例6: Put

        public ByteBuffer Put(ByteBuffer src)
        {
            if (ReferenceEquals(src, this))
            {
                throw new ArgumentNullException("src");
            }
                
            var n = src.Remaining();
            if (n > this.Remaining())
            {
                throw new IndexOutOfRangeException();
            }

            Buffer.BlockCopy(src.hb, src.Ix(src.position), this.hb, this.Ix(this.position), n);
            this.position += n;
            src.position += n;

            return this;
        }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:19,代码来源:ByteBuffer.cs

示例7: ReadToByteBuffer

        /// <summary>
        /// Reads the data into a <c>ByteBuffer</c>.
        /// </summary>
        /// <param name="dest">The destination <c>ByteBuffer</c></param>
        /// <param name="elements">The number of elements to read into a buffer</param>
        /// <param name="storage">The backing <c>ByteStorageSupport</c> that
        /// gives information on how data should be interpreted</param>
        /// <returns>Reference to the destination <c>ByteBuffer</c></returns>
        /// <exception cref="NotSupportedException">When attempting to read an unsupported
        /// class type from the buffer</exception>
        public ByteBuffer ReadToByteBuffer( ByteBuffer dest, int elements, 
			ByteStorageSupport storage )
        {
            int bytesAllocated = storage.GetBytesAllocated;
            int size = elements * bytesAllocated;

            // direct buffer copy
            if( MatDataTypes.SizeOf( _type ) == bytesAllocated )
            {
                int bufMaxSize = 1024;
                int bufSize = Math.Min( (int)(_buf.BaseStream.Length - _buf.BaseStream.Position), bufMaxSize );
                int bufPos = (int)_buf.BaseStream.Position;

                byte[] tmp = new byte[ bufSize ];

                while( dest.Remaining() > 0 )
                {
                    int length = Math.Min(dest.Remaining(), tmp.Length);
                    _buf.Read( tmp, 0, length );
                    dest.Put( tmp, 0, length );
                }
                _buf.BaseStream.Position = bufPos + size;
            }
            else
            {
                // Because Matlab writes data not respectively to the declared
                // matrix type, the reading is not straight forward (as above)
                Type clazz = storage.GetStorageType;
                while( dest.Remaining() > 0 )
                {
                    if( clazz.Equals( typeof(double) ) )
                    {
                        dest.PutDouble( ReadDouble() );
                        continue;
                    }
                    if( clazz.Equals( typeof(byte) ) )
                    {
                        dest.PutDouble( ReadByte() );
                        continue;
                    }
                    if( clazz.Equals( typeof(int) ) )
                    {
                        dest.PutDouble( ReadInt() );
                        continue;
                    }
                    if( clazz.Equals( typeof(long) ) )
                    {
                        dest.PutDouble( ReadLong() );
                        continue;
                    }
                    throw new NotSupportedException("Not supported buffer reader for " + clazz );
                }
            }
            dest.Rewind();
            return dest;
        }
开发者ID:patrickmaster,项目名称:electre-tri,代码行数:66,代码来源:MatFileInputStream.cs

示例8: InitFrameSize

 private int InitFrameSize(ByteBuffer byteBuffer)
 {
     if (byteBuffer.Remaining() < Bits.IntSizeInBytes)
     {
         return 0;
     }
     return Accumulate(byteBuffer, Bits.IntSizeInBytes);
 }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:8,代码来源:ClientMessage.cs

示例9: Accumulate

 private int Accumulate(ByteBuffer byteBuffer, int length)
 {
     var remaining = byteBuffer.Remaining();
     var readLength = remaining < length ? remaining : length;
     if (readLength > 0)
     {
         var requiredCapacity = Index() + readLength;
         EnsureCapacity(requiredCapacity);
         Buffer.PutBytes(Index(), byteBuffer.Array(), byteBuffer.Position, readLength);
         byteBuffer.Position = byteBuffer.Position + readLength;
         Index(Index() + readLength);
         return readLength;
     }
     return 0;
 }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:15,代码来源:ClientMessage.cs

示例10: WriteTo

 public virtual bool WriteTo(ByteBuffer destination)
 {
     var byteArray = Buffer.ByteArray();
     var size = GetFrameLength();
     // the number of bytes that can be written to the bb.
     var bytesWritable = destination.Remaining();
     // the number of bytes that need to be written.
     var bytesNeeded = size - _writeOffset;
     int bytesWrite;
     bool done;
     if (bytesWritable >= bytesNeeded)
     {
         // All bytes for the value are available.
         bytesWrite = bytesNeeded;
         done = true;
     }
     else
     {
         // Not all bytes for the value are available. Write as much as is available.
         bytesWrite = bytesWritable;
         done = false;
     }
     destination.Put(byteArray, _writeOffset, bytesWrite);
     _writeOffset += bytesWrite;
     if (done)
     {
         //clear the write offset so that same client message can be resend if needed.
         _writeOffset = 0;
     }
     return done;
 }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:31,代码来源:ClientMessage.cs

示例11: PayLoadSourceBuffer

        private static ByteBuffer PayLoadSourceBuffer(ByteBuffer buffer, DeflateStream decompressor, int expectedCapacity, IHeader header)
        {
            ByteBuffer payLoadSourceBuffer;
            if (decompressor == null)
            {
                // No compressed source buffer. Payload is in buffer, after header.
                if (expectedCapacity > buffer.Remaining())
                {
                    throw new ArgumentException("The buffer does not contain the full Histogram payload");
                }
                payLoadSourceBuffer = buffer;
            }
            else
            {
                payLoadSourceBuffer = ByteBuffer.Allocate(expectedCapacity);
                var decompressedByteCount = payLoadSourceBuffer.ReadFrom(decompressor, expectedCapacity);

                if ((header.PayloadLengthInBytes != int.MaxValue) && (decompressedByteCount < header.PayloadLengthInBytes))
                {
                    throw new ArgumentException("The buffer does not contain the indicated payload amount");
                }
            }
            return payLoadSourceBuffer;
        }
开发者ID:HdrHistogram,项目名称:HdrHistogram.NET,代码行数:24,代码来源:HistogramEncoding.cs


注:本文中的ByteBuffer.Remaining方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。