@@ -9,6 +9,7 @@ namespace DotNetty.Buffers
99 using System . Threading ;
1010 using System . Threading . Tasks ;
1111 using DotNetty . Common ;
12+ using DotNetty . Common . Utilities ;
1213
1314 /// <summary>
1415 /// Inspired by the Netty ByteBuffer implementation (https://github.com/netty/netty/blob/master/buffer/src/main/java/io/netty/buffer/ByteBuf.java)
@@ -504,7 +505,7 @@ public interface IByteBuffer : IReferenceCounted
504505 IByteBuffer ReadBytes ( byte [ ] destination , int dstIndex , int length ) ;
505506
506507 IByteBuffer ReadBytes ( Stream destination , int length ) ;
507-
508+
508509 /// <summary>
509510 /// Increases the current <see cref="ReaderIndex"/> by the specified <see cref="length"/> in this buffer.
510511 /// </summary>
@@ -590,5 +591,47 @@ public interface IByteBuffer : IReferenceCounted
590591 string ToString ( Encoding encoding ) ;
591592
592593 string ToString ( int index , int length , Encoding encoding ) ;
594+
595+ /// <summary>
596+ /// Iterates over the readable bytes of this buffer with the specified <c>processor</c> in ascending order.
597+ /// </summary>
598+ /// <returns><c>1</c> if the processor iterated to or beyond the end of the readable bytes.
599+ /// The last-visited index If the <see cref="ByteProcessor.Process(byte)"/> returned <c>false</c>.
600+ /// </returns>
601+ /// <param name="processor">Processor.</param>
602+ int ForEachByte ( ByteProcessor processor ) ;
603+
604+ /// <summary>
605+ /// Iterates over the specified area of this buffer with the specified {@code processor} in ascending order.
606+ /// (i.e. {@code index}, {@code (index + 1)}, .. {@code (index + length - 1)})
607+ /// </summary>
608+ /// <returns>{@code -1} if the processor iterated to or beyond the end of the specified area.
609+ /// The last-visited index If the {@link ByteProcessor#process(byte)} returned {@code false}.
610+ /// </returns>
611+ /// <param name="index">Index.</param>
612+ /// <param name="length">Length.</param>
613+ /// <param name="processor">Processor.</param>
614+ int ForEachByte ( int index , int length , ByteProcessor processor ) ;
615+
616+ /// <summary>
617+ /// Iterates over the readable bytes of this buffer with the specified {@code processor} in descending order.
618+ /// </summary>
619+ /// <returns>{@code -1} if the processor iterated to or beyond the beginning of the readable bytes.
620+ /// The last-visited index If the {@link ByteProcessor#process(byte)} returned {@code false}.
621+ /// </returns>
622+ /// <param name="processor">Processor.</param>
623+ int ForEachByteDesc ( ByteProcessor processor ) ;
624+
625+ /// <summary>
626+ /// Iterates over the specified area of this buffer with the specified {@code processor} in descending order.
627+ /// (i.e. {@code (index + length - 1)}, {@code (index + length - 2)}, ... {@code index})
628+ /// </summary>
629+ /// <returns>{@code -1} if the processor iterated to or beyond the beginning of the specified area.
630+ /// The last-visited index If the {@link ByteProcessor#process(byte)} returned {@code false}.
631+ /// </returns>
632+ /// <param name="index">Index.</param>
633+ /// <param name="length">Length.</param>
634+ /// <param name="processor">Processor.</param>
635+ int ForEachByteDesc ( int index , int length , ByteProcessor processor ) ;
593636 }
594637}
0 commit comments