Mega Code Archive

 
Categories / Android / Game
 

Bit Vector

public class BitVector {   private final int DEFAULT_SIZE = 1024;   private byte[] buffer = null;   private int index = 0;   public BitVector( int size ) {     buffer = new byte[ size ];   }   public void append( byte[] buffer , int offSet , int length ){     if( index + length > this.buffer.length ){       byte[] tmp = new byte[ index + length ];       System.arraycopy( this.buffer , 0 , tmp , 0 , index );       System.arraycopy( buffer , offSet , tmp , index , length );       this.buffer = tmp;       this.index += length;     }else{       System.arraycopy( buffer , offSet , this.buffer , index , length );       index += length;     }   }      public byte[] getBuffer(){     return buffer;   } }