Class ByteVector

  • All Implemented Interfaces:
    java.io.Serializable

    public class ByteVector
    extends java.lang.Object
    implements java.io.Serializable
    This class implements a simple byte vector with access to the underlying array.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] array
      The encapsulated array
      private int blockSize  
      private static int DEFAULT_BLOCK_SIZE
      Capacity increment size
      private int n
      Points to next free item
      private static long serialVersionUID  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int alloc​(int size)
      This is to implement memory allocation in the array.
      int capacity()
      returns current capacity of array
      byte get​(int index)  
      byte[] getArray()  
      int length()
      return number of items in array
      void put​(int index, byte val)  
      void trimToSize()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_BLOCK_SIZE

        private static final int DEFAULT_BLOCK_SIZE
        Capacity increment size
        See Also:
        Constant Field Values
      • blockSize

        private int blockSize
      • array

        private byte[] array
        The encapsulated array
      • n

        private int n
        Points to next free item
    • Constructor Detail

      • ByteVector

        public ByteVector()
      • ByteVector

        public ByteVector​(int capacity)
      • ByteVector

        public ByteVector​(byte[] a)
      • ByteVector

        public ByteVector​(byte[] a,
                          int capacity)
    • Method Detail

      • getArray

        public byte[] getArray()
      • length

        public int length()
        return number of items in array
      • capacity

        public int capacity()
        returns current capacity of array
      • put

        public void put​(int index,
                        byte val)
      • get

        public byte get​(int index)
      • alloc

        public int alloc​(int size)
        This is to implement memory allocation in the array. Like malloc().
      • trimToSize

        public void trimToSize()