package editor;

public class ByteArray
{ static final int increment = 0x1000;
  public byte[] array = null;
  public int size = 0;
//------------------------------------------------------------------------------
  public ByteArray()
  { array = new byte[increment]; }
////////////////////////////////////////////////////////////////////////////////
  public void insert(int offset,int length)
  { int oldSize = size;
    size+=length;
    if(size>array.length)
    { int newSize = size+increment;
      if(newSize<0) newSize = Integer.MAX_VALUE;
      byte[] newArray = new byte[newSize];
      System.arraycopy(array,0,newArray,0,oldSize);
      array = newArray;
    }
    System.arraycopy(array,offset,array,offset+length,oldSize-offset);
  }
//------------------------------------------------------------------------------
  public void remove(int offset,int length)
  { size-=length;
    System.arraycopy(array,offset+length,array,offset,size-offset);
  }
//------------------------------------------------------------------------------
}
