X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=Novacoin%2FByteQueue.cs;h=9752c0217320ad40a7b001712ee974fd644cb9cf;hb=489d1c818f98777bc3f582312ac39a40b0709432;hp=dc18437479fcca5a9a9dbd41abbe1d838e329ce1;hpb=b8edf2030a6849511ea763b44990978b1dd7bd24;p=NovacoinLibrary.git diff --git a/Novacoin/ByteQueue.cs b/Novacoin/ByteQueue.cs index dc18437..9752c02 100644 --- a/Novacoin/ByteQueue.cs +++ b/Novacoin/ByteQueue.cs @@ -84,6 +84,18 @@ namespace Novacoin return _Elements[_Index++]; } + public bool TryGet(ref byte Element) + { + if (_Elements.Count <= _Index) + { + return false; + } + + Element = _Elements[_Index++]; + + return true; + } + public byte GetCurrent() { return _Elements[_Index]; @@ -99,6 +111,19 @@ namespace Novacoin return result; } + public bool TryGet(int nCount, ref byte[] Elements) + { + if (Count - Index < nCount) + { + return false; + } + + Elements = _Elements.GetRange(_Index, nCount).ToArray(); + _Index += nCount; + + return true; + } + public byte[] GetCurrent(int nCount) { Contract.Requires(Count - Index >= nCount, "nCount is greater than amount of elements."); @@ -108,6 +133,18 @@ namespace Novacoin return result; } + public bool TryGetCurrent(int nCount, ref byte[] Elements) + { + if (Count - Index < nCount) + { + return false; + } + + Elements = _Elements.GetRange(_Index, nCount).ToArray(); + + return true; + } + /// /// Current index value ///