
 function StringBuffer() { 
   this.buffer = []; 
   this.length = 0;
  
 } 

 StringBuffer.prototype.append = function append(string) { 
   this.buffer.push(string); 
   this.length+=string.length;
   return this; 
 }; 

 StringBuffer.prototype.toString = function toString() { 
   return this.buffer.join(""); 
 }; 
 StringBuffer.prototype.replace = function(oldstr,newstr)
 {
    for(var i =0;i<this.buffer.length;++i)
        this.buffer[i]=this.buffer[i].replace(oldstr,newstr);
    
    this.length=this.toString().length;
    
 
 }
 
 StringBuffer.prototype.concat=function(buf)
 {
    this.buffer = this.buffer.concat(buf.buffer);
    return this;
 }

 StringBuffer.prototype.splice=function(a,b,c)
 {
    if(c)
        this.buffer.splice(a,b,c);
    else
        this.buffer.splice(a,b);

 }

 
 StringBuffer.prototype.length=function()
 {
    return  this.buffer.length;

 }

 StringBuffer.prototype.clear = function()
 {
    this.buffer  = new Array();
     this.length = 0;
 }


