Ejemplo n.º 1
0
        private ByteCharUnion Get(int index)
        {
            ByteCharUnion node = head;

            while (index > 0 && node != null)
            {
                node = node.next;
                index--;
            }
            return(node);
        }
Ejemplo n.º 2
0
 /// <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++;
 }
Ejemplo n.º 3
0
        /// <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--;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new empty resizeable byte buffer
 /// </summary>
 public ByteBuffer()
 {
     count = 0;
     tail  = null;
     head  = null;
 }
Ejemplo n.º 5
0
 public ByteCharUnion(char value)
 {
     this.value = value;
     binary     = (byte)value;
     next       = null;
 }
Ejemplo n.º 6
0
 public ByteCharUnion(byte value)
 {
     next       = null;
     this.value = (char)value;
     binary     = value;
 }