public EncodedElement addInt(int input, int bitCount) {
    if(next != null) {
      EncodedElement end = EncodedElement.getEnd_S(next);
      return end.addInt(input, bitCount);
    }
    else if(data.length*8 < usableBits+bitCount) {
      //create child and attach to next.
      //Set child's offset appropriately(i.e, manually set usable bits)
      int tOff = usableBits %8;
      //int size = data.length/2+1;
      int size = 1000;
      //guarantee that our new element can store our given value
      //if(size <= bitCount+tOff) size = (size+tOff+bitCount)*10;
      next = new EncodedElement(size, tOff);
      System.err.println("creating next node of size:bitCount "+size+
              ":"+bitCount+":"+usableBits+":"+data.length);
      System.err.println("value: "+input);
              //+this.toString()+"::"+next.toString());
      //add int to child
      return next.addInt(input, bitCount);
    }
    else {
      //At this point, we have the space, and we are the end of the chain.
      int startPos = this.usableBits;
      byte[] dest = this.data;
      EncodedElement.addInt_new(input, bitCount, startPos, dest);
      //EncodedElement.addInt_buf2(input, bitCount, startPos, dest);
      /*if(startPos/8+8 > dest.length)
         EncodedElement.addInt(input, bitCount, startPos, dest);
      else
         EncodedElement.addInt_new(input, bitCount, startPos, dest);*/
      usableBits +=  bitCount;
      return this;
    }
  }
public EncodedElement addInt ( int input , int bitCount ) { if ( next != null ) { EncodedElement end = EncodedElement . getEnd_S ( next ) ; return end . addInt ( input , bitCount ) ; } else if ( data . length * 8 < usableBits + bitCount ) { int tOff = usableBits % 8 ; int size = 1000 ; next = new EncodedElement ( size , tOff ) ; System . err . println ( "creating next node of size:bitCount " + size + ":" + bitCount + ":" + usableBits + ":" + data . length ) ; System . err . println ( "value: " + input ) ; return next . addInt ( input , bitCount ) ; } else { int startPos = this . usableBits ; byte [ ] dest = this . data ; EncodedElement . addInt_new ( input , bitCount , startPos , dest ) ; usableBits += bitCount ; return this ; } }
Add a number of bits from an int to the end of this list's data. Will
add a new element if necessary. The bits stored are taken from the lower-
order of input.

@param input Int containing bits to append to end.
@param bitCount Number of bits to append.
@return EncodedElement which actually contains the appended value.