another method
authorbdemsky <bdemsky>
Wed, 25 Oct 2006 00:50:31 +0000 (00:50 +0000)
committerbdemsky <bdemsky>
Wed, 25 Oct 2006 00:50:31 +0000 (00:50 +0000)
Robust/src/ClassLibrary/StringBuffer.java

index 4ac60a2b5ac1353f82f8b846c2f62fe4abc9d292..e47a7e1e0bbd87496ae881b6a3d2c9d398997167 100644 (file)
@@ -43,6 +43,25 @@ public class StringBuffer {
        }
     }
 
+    public void append(StringBuffer s) {
+       if ((s.count+count+offset)>value.length) {
+           // Need to allocate
+           char newvalue[]=new char[s.count+count+16]; //16 is DEFAULTSIZE
+           for(int i=0;i<count;i++)
+               newvalue[i]=value[i+offset];
+           for(int i=0;i<s.count;i++)
+               newvalue[i+count]=s.value[i+s.offset];
+           value=newvalue;
+           count+=s.count;
+           offset=0;
+       } else {
+           for(int i=0;i<s.count;i++) {
+               value[i+count+offset]=s.value[i+s.offset];
+           }
+           count+=s.count;
+       }
+    }
+
     public String toString() {
        return new String(this);
     }