-\feffusing System;
+\feff/**
+ * Novacoin classes library
+ * Copyright (C) 2015 Alex D. (balthazar.ad@gmail.com)
+
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Novacoin
{
private int Index;
private List<byte> Elements;
- public ByteQueue(IList<byte> List, int Start)
+ public ByteQueue(byte[] List, int Start)
{
Elements = new List<byte>(List);
Index = Start;
}
- public ByteQueue(IList<byte> List)
+ public ByteQueue(byte[] List)
+ {
+ Elements = new List<byte>(List);
+ Index = 0;
+ }
+
+ public ByteQueue(List<byte> List, int Start)
+ {
+ Elements = new List<byte>(List);
+ Index = Start;
+ }
+
+ public ByteQueue(List<byte> List)
{
Elements = new List<byte>(List);
Index = 0;
throw new ByteQueueException("Unable to read requested amount of data.");
}
- byte[] result = Elements.Skip(Index).Take(Count).ToArray();
+ var result = Elements.GetRange(Index, Count).ToArray();
Index += Count;
return result;
throw new ByteQueueException("Unable to read requested amount of data.");
}
- byte[] result = Elements.Skip(Index).Take(Count).ToArray();
+ var result = Elements.GetRange(Index, Count).ToArray();
return result;
}
get { return Index; }
}
- public IEnumerable<byte> GetEnumerable(int Count)
- {
- if (Elements.Count - Index < Count)
- {
- throw new ByteQueueException("Unable to read requested amount of data.");
- }
-
- IEnumerable<byte> result = Elements.Skip(Index).Take(Count);
- Index += Count;
-
- return result;
- }
-
public ulong GetVarInt()
{
byte prefix = Get();