private ByteCharUnion Get(int index) { ByteCharUnion node = head; while (index > 0 && node != null) { node = node.next; index--; } return(node); }
/// <summary> /// Adds a new item to the buffer /// </summary> /// <param name="b"></param> public void Add(byte b) { if (head == null) { head = new ByteCharUnion(b); tail = head; } else { ByteCharUnion union = new ByteCharUnion(b); tail.next = union; tail = union; } count++; }
/// <summary> /// Removes an item by its index /// </summary> /// <param name="index"></param> public void RemoveAt(int index) { if (index >= count) { throw new IndexOutOfRangeException(); } if (index == 0) { if (tail == head) { tail = null; } head = head.next; } else { ByteCharUnion u = Get(index - 1); u.next = u.next.next; } count--; }
/// <summary> /// Creates a new empty resizeable byte buffer /// </summary> public ByteBuffer() { count = 0; tail = null; head = null; }
public ByteCharUnion(char value) { this.value = value; binary = (byte)value; next = null; }
public ByteCharUnion(byte value) { next = null; this.value = (char)value; binary = value; }